SSMStringHandler.h

Classes

SSMStringHandler -- Store strings in the Standard Storage Manager. (full description)

class SSMStringHandler

Interface

Public Members
SSMStringHandler (SSMBase* aBase)
~SSMStringHandler()
void setLastStringBucket (Int lastStringBucket)
Int lastStringBucket() const
void put (Int& bucketNr, Int& offset, Int& length, const String& string)
void put (Int& bucketNr, Int& offset, Int& length, const Array<String>& string, Bool handleShape)
void putShape (Int& bucketNr, Int& offset, Int& length, const IPosition& aShape)
void getShape (IPosition& aShape, Int bucket, Int& offset, Int length)
void remove (Int bucketNr, Int offset, Int length)
void get (String& string, Int bucket, Int offset, Int length)
void get (Array<String>& string, Int bucket, Int offset, Int length, Bool handleShape)
void flush()
void init()
void resync()
Private Members
SSMStringHandler (const SSMStringHandler&)
SSMStringHandler& operator= (const SSMStringHandler&)
void getBucket (uInt bucketNr, Bool isNew=False)
void getNewBucket (Bool doConcat)
void putData (Int length, const Char* data)
void getData (Int length, Char* data, Int& offset)
void replace (Int bucketNr, Int offset, Int length, const String& string)
void replace (Int bucketNr, Int offset, Int length, Int totalLength, const IPosition& aShape)
void replace (Int bucketNr, Int offset, Int length, Int totalLength, const Array<String>& string, Bool handleShape)
void replaceData (Int& offset,Int length, const Char* data)

Description

Review Status

Programs:
Tests:

Prerequisite

Etymology

SSMStringHandler handles strings for the Standard Storage Manager.

Synopsis

Variable length strings cannot be stored in the data bucket. Only short (<8 characters) strings can be stored directly. Class SSMStringhandler is used by the SSM to store strings in so-called string buckets. A string bucket has the following layout: SSMStringHandler keeps a copy of the current bucket in use to reduce the number of accesses to the bucket cache.

It also keeps the bucket number of the last bucket where data were added to. It tells which bucket to use when new data has to be stored.

Member Description

SSMStringHandler (SSMBase* aBase)

Default constructor initializes last string bucket to -1.

~SSMStringHandler()

void setLastStringBucket (Int lastStringBucket)
Int lastStringBucket() const

Set or get last string bucketnr. Setting is needed when an existing table is opened.

void put (Int& bucketNr, Int& offset, Int& length, const String& string)
void put (Int& bucketNr, Int& offset, Int& length, const Array<String>& string, Bool handleShape)

Put a single string or an array of strings into a bucket. If its length does not exceed the given length, it reuses the currently used space (given by bucketnr and offset). Otherwise it adds the data to the last string bucket. It fills the offset and bucketnr where the data are stored and the length occupied in the buckets. An array of strings is flattened first (a la SSMColumn::writeString).
If handleShape is True (for variable shaped arrays), the shape will be put first.

void putShape (Int& bucketNr, Int& offset, Int& length, const IPosition& aShape)

Put a single string or an array of strings into a bucket. If its length does not exceed the given length, it reuses the currently used space (given by bucketnr and offset). Otherwise it adds the data to the last string bucket. It fills the offset and bucketnr where stored and the length occupied in the buckets.

void getShape (IPosition& aShape, Int bucket, Int& offset, Int length)

Get the shape in the given bucket and offset. It sets the offset to the data right after the shape. The IPosition object is resized as needed.

void remove (Int bucketNr, Int offset, Int length)

Remove data with the given length from a bucket. If the data are continued in next bucket(s), they will be removed there as well.

void get (String& string, Int bucket, Int offset, Int length)
void get (Array<String>& string, Int bucket, Int offset, Int length, Bool handleShape)

Get a string or an array of strings. The array must have the correct shape. handleShape will be True for variable shaped arrays indicating that the data are preceeded by the shape.

void flush()

Flush the currently used string bucket.

void init()

Initialize the StringHandler

void resync()

Resynchronize (after a table lock was acquired). It clears the itsCurrentBucket variable to assure that buckets are reread.

SSMStringHandler (const SSMStringHandler&)
SSMStringHandler& operator= (const SSMStringHandler&)

Forbid copy constructor and assignment.

void getBucket (uInt bucketNr, Bool isNew=False)

Get the given bucket and make it current. It first writes the current bucket if it has changed.
If isNew is True the bucket is new, so the Ints at its beginning do not have to be interpreted.

void getNewBucket (Bool doConcat)

Get a new bucket and make it current. If doConcat is True, the new bucket is a continuation, so itsNextBucket in the currently used bucket is filled with the new bucket number.

void putData (Int length, const Char* data)

Put the data with the given length at the end of the current bucket. If they do not fit, they are continued in a new bucket.

void getData (Int length, Char* data, Int& offset)

Get the data with the given length from the curent bucket at the given offset. If sets the offset to the byte after the data read. Continuation buckets are followed (and made current).

void replace (Int bucketNr, Int offset, Int length, const String& string)
void replace (Int bucketNr, Int offset, Int length, Int totalLength, const IPosition& aShape)
void replace (Int bucketNr, Int offset, Int length, Int totalLength, const Array<String>& string, Bool handleShape)
void replaceData (Int& offset,Int length, const Char* data)

Replace the current data with the new data. It is used by put after having assured that the new length does not exceed the current one. It follows continuation buckets as needed.