SSMIndex.h

Classes

SSMIndex -- The bucket index for a group of columns in the Standard Storage Manager. (full description)

class SSMIndex

Interface

Public Members
explicit SSMIndex (SSMBase* aPtrSSM, uInt rowsPerBucket=0)
~SSMIndex()
void get (AipsIO& anOs)
void put (AipsIO& anOs) const
void recreate()
Vector<uInt> getBuckets() const
uInt getNrBuckets() const
void setNrColumns (Int aNrColumns, uInt aSizeUsed)
void addRow (uInt aNrRows)
void showStatistics (ostream& anOs) const
Int removeColumn (Int anOffset, uInt nbits)
Int getFree (Int& anOffset, uInt nbits) const
void addColumn (Int anOffset, uInt nbits)
Int deleteRow (uInt aRowNumber)
uInt getRowsPerBucket() const
void find (uInt aRowNumber, uInt& aBucketNr, uInt& aStartRow, uInt& anEndRow) const
Private Members
uInt getIndex (uInt aRowNr) const

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25
Programs:
Tests:

Prerequisite

Etymology

SSMIndex represent the bucket index in the Standard Storage Manager.

Synopsis

In SSMBase it is described that an index is used to map row number to data bucket in a bucket stream. This class implements this index. It serves 2 purposes:
  1. It keeps a block of row numbers giving the last row number stored in each data bucket.
    Note that each bucket does not need to contain the same number of rows, because rows might be deleted from it. When all rows are deleted from a bucket, the bucket is removed from the index and added to the free bucket list.
  2. When a column is deleted, the bucket will have a hole. SSMIndex maintains a map to know the size and offset of each hole. Adjacent holes are combined. When a new column is added SSMBase will scan the SSMIndex objects to find the hole fitting best.

To Do

Member Description

explicit SSMIndex (SSMBase* aPtrSSM, uInt rowsPerBucket=0)

Create the object with the given number of rows per bucket. Note that the default is needed to create the object for existing tables.

~SSMIndex()

void get (AipsIO& anOs)

Read the bucket index from the AipsIO object.

void put (AipsIO& anOs) const

Write the bucket index into the AipsIO object.

void recreate()

Recreate the object in case all rows are deleted from the table.

Vector<uInt> getBuckets() const

Return all the bucketnrs used in this index.

uInt getNrBuckets() const

Return the nr of buckets used.

void setNrColumns (Int aNrColumns, uInt aSizeUsed)

Set nr of columns use this index.

void addRow (uInt aNrRows)

Add some rows.

void showStatistics (ostream& anOs) const

Show Statistics of index.

Int removeColumn (Int anOffset, uInt nbits)

A column is removed. Set the free space at offset for a field with the given nr of bits. It returns the nr of columns still used in this index.

Int getFree (Int& anOffset, uInt nbits) const

Try to find free space for a field with a given length (best fit). -1 is returned if no fit is found. Otherwise it returns the nr of bytes left unused.

void addColumn (Int anOffset, uInt nbits)

reuse the space at offset for a field with the given nr of bits. This is used when column has been added to this bucket.

Int deleteRow (uInt aRowNumber)

Delete the given row.

uInt getRowsPerBucket() const

Get the number of rows that fits in ach bucket.

void find (uInt aRowNumber, uInt& aBucketNr, uInt& aStartRow, uInt& anEndRow) const

Find the bucket containing the given row. An exception is thrown if not found. It also sets the first and last row number fitting in that bucket.

uInt getIndex (uInt aRowNr) const

Get the index of the bucket containing the given row.