Loading...
Searching...
No Matches
casacore::SSMIndex Class Reference
tables package (libcasa_tables) » DataMan_module » DataMan_module_internal_classes

More...

`#include <SSMIndex.h>`

## Public Member Functions

| SSMIndex (SSMBase *aPtrSSM, uInt rowsPerBucket=0)
| Create the object with the given number of rows per bucket.
| ~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 (rownr_t aNrRows)
| Add some rows.
void | showStatistics (ostream &anOs) const
| Show Statistics of index.
Int | removeColumn (Int anOffset, uInt nbits)
| A column is removed.
Int | getFree (Int &anOffset, uInt nbits) const
| Try to find free space for a field with a given length (best fit).
void | addColumn (Int anOffset, uInt nbits)
| reuse the space at offset for a field with the given nr of bits.
Int | deleteRow (rownr_t aRowNumber)
| Delete the given row.
uInt | getRowsPerBucket () const
| Get the number of rows that fits in ach bucket.
void | find (rownr_t aRowNumber, uInt &aBucketNr, rownr_t &aStartRow, rownr_t &anEndRow, const String &colName) const
| Find the bucket containing the given row.

## Private Member Functions

uInt | getIndex (rownr_t aRowNr, const String &colName) const
| Get the index of the bucket containing the given row.

## Private Attributes

SSMBase * | itsSSMPtr
uInt | itsNUsed
Block< rownr_t > | itsLastRow
Block< uInt > | itsBucketNumber
std::map< Int, Int > | itsFreeSpace
uInt | itsRowsPerBucket
Int | itsNrColumns

## Detailed Description

The bucket index for a group of columns in the Standard Storage Manager.

### Intended use:

Internal

### Review Status

Reviewed By:
  UNKNOWN
Date Reviewed:
  before2004/08/25
Test programs:
  tStandardStMan

### Prerequisite

- SSMBase

### 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

- recreate should recreate the itsLastRow && itsBucketNr as well (moving them to the front and rearrange the freespace as one concatenated block)

Definition at line 85 of file SSMIndex.h.

## Constructor & Destructor Documentation

## SSMIndex()

casacore::SSMIndex::SSMIndex | ( | SSMBase * | aPtrSSM,
|  | uInt | rowsPerBucket = 0 )

explicit

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()

casacore::SSMIndex::~SSMIndex | ( |  | ) |

## Member Function Documentation

## addColumn()

void casacore::SSMIndex::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.

## addRow()

void casacore::SSMIndex::addRow | ( | rownr_t | aNrRows | ) |

Add some rows.

## deleteRow()

Int casacore::SSMIndex::deleteRow | ( | rownr_t | aRowNumber | ) |

Delete the given row.

It returns the bucket nr if it gets empty, otherwise -1.

## find()

void casacore::SSMIndex::find | ( | rownr_t | aRowNumber,
|  | uInt & | aBucketNr,
|  | rownr_t & | aStartRow,
|  | rownr_t & | anEndRow,
|  | const String & | colName ) 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.

## get()

void casacore::SSMIndex::get | ( | AipsIO & | anOs | ) |

Read the bucket index from the AipsIO object.

## getBuckets()

Vector< uInt > casacore::SSMIndex::getBuckets | ( |  | ) | const

Return all the bucketnrs used in this index.

## getFree()

Int casacore::SSMIndex::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.

## getIndex()

uInt casacore::SSMIndex::getIndex | ( | rownr_t | aRowNr,
|  | const String & | colName ) const

private

Get the index of the bucket containing the given row.

## getNrBuckets()

uInt casacore::SSMIndex::getNrBuckets | ( |  | ) | const

Return the nr of buckets used.

## getRowsPerBucket()

uInt casacore::SSMIndex::getRowsPerBucket | ( |  | ) | const

inline

Get the number of rows that fits in ach bucket.

Definition at line 176 of file SSMIndex.h.

References itsRowsPerBucket.

## put()

void casacore::SSMIndex::put | ( | AipsIO & | anOs | ) | const

Write the bucket index into the AipsIO object.

## recreate()

void casacore::SSMIndex::recreate | ( |  | ) |

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

## removeColumn()

Int casacore::SSMIndex::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.

## setNrColumns()

void casacore::SSMIndex::setNrColumns | ( | Int | aNrColumns,
|  | uInt | aSizeUsed )

Set nr of columns use this index.

## showStatistics()

void casacore::SSMIndex::showStatistics | ( | ostream & | anOs | ) | const

Show Statistics of index.

## Member Data Documentation

## itsBucketNumber

Block<uInt> casacore::SSMIndex::itsBucketNumber

private

Definition at line 163 of file SSMIndex.h.

## itsFreeSpace

std::map<Int,Int> casacore::SSMIndex::itsFreeSpace

private

Definition at line 166 of file SSMIndex.h.

## itsLastRow

Block<rownr_t> casacore::SSMIndex::itsLastRow

private

Definition at line 158 of file SSMIndex.h.

## itsNrColumns

Int casacore::SSMIndex::itsNrColumns

private

Definition at line 172 of file SSMIndex.h.

## itsNUsed

uInt casacore::SSMIndex::itsNUsed

private

Definition at line 155 of file SSMIndex.h.

## itsRowsPerBucket

uInt casacore::SSMIndex::itsRowsPerBucket

private

Definition at line 169 of file SSMIndex.h.

Referenced by getRowsPerBucket().

## itsSSMPtr

SSMBase* casacore::SSMIndex::itsSSMPtr

private

Definition at line 152 of file SSMIndex.h.

The documentation for this class was generated from the following file:

- tables/DataMan/SSMIndex.h