Description
The CTIndex class deal with the index concept. The index is part of the table, and represent one field, or parts of one field, or parts of several fields. One single index may be composed of several segments.
See Also
CTBase, CTField, CTRecord, CTSegment, CTTable
Preconditions
Before any task is developed with a CTIndex object, a CTTable must have been initialized.
CTIndex Operators
- = : Assign a CTIndex object to another
CTIndex.operator=
Syntax
CTIndex operator=( CTIndex aIndex)
Parameters
- aIndex [in] The index object.
Description
Assigns one CTIndex object to another
Return
Returns a CTIndex object
CTIndex Methods
Constructor / Destructor
- CTIndex(): Creates a CTIndex object
- ~CTIndex(): Destroys a CTIndex object and resets all the dependent objects
Key Handling
- GetKeyLength(): Retrieves the key length
- GetKeyType(): Retrieves the key type
- GetEmptyChar(): Retrieves the index empty char
- GetDuplicateFlag(): Retrieves the allow duplicated flag for this index
- GetNullFlag(): Retrieve the null flag
- GetTemporaryFlag(): Retrieves the temporary flag
- SetEmptyChar(): Sets the empty char value
- SetDuplicateFlag(): Sets the allow duplicate flag
- SetNullFlag(): Sets the null flag
- SetTemporaryFlag(): Sets the temporary flag
- SetKeyType(): Set the key type of an index
Segment Handling
- GetSegmentCount(): Retrieves the index segments count
- AddSegment(): Adds a new segment to the index
- InsertSegment(): Inserts a segment to the index
- DelSegment(): Deletes a segment from the index
- GetSegment(): Retrieves an index segment
Index Handling
- GetNumber(): Retrieves the index position in table indexes list.
- GetName(): Retrieves the index name.
- GetUID(): Retrieves the index uid
- GetIdxNo(): Retrieve the index file number
- GetFilename(): Get the index filename
- SetFilename(): Set the index filename
- SetName(): Sets the index name.
CTIndex.CTIndex
Syntax
CTIndex ( )
CTIndex(CTIndex Index)
Parameters
- Index [in] The index object.
Description
This is the constructor for the CTIndex object.
See Also
~CTIndex()
CTIndex.~CTIndex
Syntax
~CTIndex
Parameters
This destructor has no parameters.
Description
This is the destructor for the CTIndex object.
See Also
CTIndex()
CTIndex.AddSegment
Syntax
CTSegment AddSegment( CTField Field, SEG_MODE SegMode)
CTSegment AddSegment(int offset, int length, SEG_MODE SegMode)
Parameters
- Field [in] The segment object to be inserted.
- SegMode [in] The field segment mode. The valid values for the segment mode are shown in "Segment Modes".
- offset [in] The segment offset to be inserted.
- length [in] The segment length to be inserted.
Description
Adds a new segment to the index at the end of the index.
Return
Returns a segment object
See Also
DelSegment(), GetSegmentCount(), InsertSegment()
CTIndex.DelSegment
Syntax
void DelSegment(int SegmentNumber)
Parameters
- SegmentNumber [in] The segment number to be deleted.
Description
Deletes a segment from the index.
Return
None.
See Also
AddSegment(), InsertSegment()
CTIndex.GetDuplicateFlag
Syntax
bool GetDuplicateFlag( )
Parameters
This method has no parameters.
Description
Retrieves the allowed duplicated flag for this index
Return
GetDuplicateFlag() returns true if the index allows duplicated keys, and false otherwise.
See Also
SetDuplicateFlag()
CTIndex.GetEmptyChar
Syntax
int GetEmptyChar( )
Parameters
This method has no parameters.
Description
Retrieves the index empty char.
Return
GetEmptyChar() returns the index empty char. The empty char property is expressed as the decimal equivalent of the ASCII table. See SetEmptyChar() for more information.
See Also
GetNullFlag(), SetEmptyChar()
CTIndex.GetIdxNo
Syntax
int GetIdxNo( )
Parameters
This method has no parameters.
Description
Retrieve the index file number from a index object. If GetIdxno() fails, a CTException is thrown.
Return
GetIdxNo() returns the index file number
CTIndex.GetFileName
Syntax
String GetFilename( )
Parameters
This method has no parameters.
Description
Retrieve the index file name.
Return
GetFileName() returns the index file name
See Also
SetFileName()
CTIndex.GetKeyLength
Syntax
int GetKeyLength( )
Parameters
This method has no parameters.
Description
Retrieves the key length.
Return
GetKeyLength() returns the key length.
See Also
GetKeyType()
CTIndex.GetKeyType
Syntax
KEY_TYPE GetKeyType( )
Parameters
This method has no parameters.
Description
Retrieves the key type.
Return
GetKeyType() returns the key type.
See Also
GetKeyLength(), SetKeyType()
CTIndex.GetName
Syntax
String GetName( )
Parameters
This method has no parameters.
Description
Retrieves the index name.
Return
GetName() returns the index name.
See Also
GetNumber(), GetSegment(), SetName()
CTIndex.GetNullFlag
Syntax
bool GetNullFlag( )
Parameters
This method has no parameters.
Description
Retrieves the null flag.
Return
GetNullFlag() returns true if the null flag is set, and false otherwise
See Also
GetEmptyChar(), SetNullFlag()
CTIndex.GetNumber
Syntax
int GetNumber( )
Parameters
This method has no parameters.
Description
Retrieves the index position in table indexes list.
Return
GetNumber() returns the index position.
See Also
GetName()
CTIndex.GetSegment
Syntax
CTSegment GetSegment(int SegmentNumber)
Parameters
- SegmentNumber [in] The segment number to be retrieved.
Description
Retrieves an index segment.
Return
GetSegment() returns a CTSegment object.
See Also
GetName(), GetNumber(), GetSegmentCount()
CTIndex.GetSegmentCount
Syntax
int GetSegmentCount( )
Parameters
This method has no parameters.
Description
Retrieves the index segments count.
Return
GetSegmentCount() returns the number of segments in the index.
See Also
GetSegment()
CTIndex.GetStatus
Retrieves the status of the index object .
Declaration
ULONG CTIndex.GetStatus() const;
Description
CTIndex.GetStatus() retrieves the status of a index object. The status of the index object is a bit map describing one or more changes that have occurred to the index object.
Return
CTIndex.GetStatus() returns a bitmap of the following:
Value |
Symbolic Constant |
Explanation |
|---|---|---|
0x00 |
CTDBINDEX_OLD |
Original value (no changes) |
0x01 |
CTDBINDEX_NEW |
Index added |
0x02 |
CTDBINDEX_DEL |
Original Index deleted |
0x04 |
CTDBINDEX_KEYTYPE |
Index key type changed |
0x10 |
CTDBINDEX_EMPCHAR |
Index empty char changed |
0x20 |
CTDBINDEX_DUPFLAG |
Index duplicate flag changed |
0x40 |
CTDBINDEX_NULLFLAG |
Index null flag changed |
0x80 |
CTDBINDEX_AIDXNAM |
Index file name changed |
Example
// if the index has been changed, call alter table
CTIndex hIndex = hTable.GetIndex(0);
if (hIndex.GetStatus() != CTDBINDEX_OLD)
if (hTable.Alter(CTDB_ALTER_NORMAL);
See Also
CTField.GetStatus(), CTSegment.GetStatus()
CTIndex.GetTemporaryFlag
Syntax
bool GetTemporaryFlag( )
Parameters
This method has no parameters.
Description
Retrieves the temporary flag.
Return
GetTemporaryFlag() returns true if the index is temporary, false otherwise
See Also
SetTemporaryFlag()
CTIndex.GetUID
Syntax
int GetUID( )
Parameters
This method has no parameters.
Description
Retrieves the index UID.
Return
GetUID() returns the index UID.
See Also
GetName()
CTIndex.InsertSegment
Syntax
CTSegment InsertSegment(int BeforeSegment, CTField Field,
SEG_MODE SegMode)
CTSegment InsertSegment(int BeforeSegment, int offset, int length,
SEG_MODE SegMode)
Parameters
- BeforeSegment [in] Insert the new segment before this segment.
- Field [in] The segment object to be inserted.
- SegMode [in] The field segment mode. The valid values for the segment mode are shown in "Segment Modes".
- offset [in] The segment offset to be inserted.
- length [in] The segment length to be inserted.
Description
Inserts a new segment to the index, in a specified position.
Return
Returns a segment object
See Also
AddSegment(), DelSegment(), GetSegmentCount()
CTIndex.MoveSegment
Moves a key segment.
Declaration
void CTIndex.MoveSegment(NINT segmentNumber, NINT newIndex);
Description
CTIndex.MoveSegment() moves a key segment to a location indicated by newIndex. segmentNumber is a relative number for a segment in an index definition and newIndex indicates the relative position were the key segment should be moved to.
Return
void
Example
// move the last segment to first
CTIndex hIndex = hTable.GetIndex(0);
NINT count = hIndex.GetSegmentCount();
if (count > 0)
hIndex.MoveSegment((count - 1), 0);
See Also
CTTable.MoveSegment(), CTSegment.MoveSegment()
CTIndex.SetDuplicateFlag
Syntax
void SetDuplicateFlag(bool DupFlag)
Parameters
- DupFlag [in] The allow duplicates flag
Description
Sets the allow duplicates flag. If set to true, this index allows duplicated values.
Return
None.
See Also
GetDuplicateFlag()
CTIndex.SetFilename
Syntax
void SetFilename(String Path, String Name)
Parameters
- Path [in] The index path
- Name [in] The index filename
Description
Set the index file path and filename. If filename is NULL the index file name is cleared.
Return
None.
See Also
GetFileName()
CTIndex.SetEmptyChar
Syntax
void SetEmptyChar(int EmptyChar)
Parameters
- EmptyChar [in] The empty char value. The empty char property is expressed as the decimal equivalent of the ASCII table. For instance, an ASCII space is specified as 32, and a NULL byte is specified as 0.
Description
Sets the empty char property.
Return
None.
See Also
GetEmptyChar(), SetNullFlag()
CTIndex.SetKeyType
Syntax
void SetKeyType(KEY_TYPE Type)
Parameters
- keytype [In] - The key type.
Description
SetKeyType() set the key type of an index. The key type can be one of the following values:
- KEY_TYPE.FIXED_INDEX fixed-length key
- KEY_TYPE.LEADING_INDEX leading-character compression
- KEY_TYPE.PADDING_INDEX padding compression
- KEY_TYPE.LEADPAD_INDEX leading/padding compression
Note: Key compression imposes a significant performance impact, especially when deleting records. Use this feature only when absolutely necessary to keep index space requirements to a minimum.
Return
None.
See Also
GetKeyType()
CTIndex.SetName
Syntax
void GetName(String Name )
Parameters
The index name
Description
Sets the index name.
Return
None
See Also
GetName(), GetNumber(), GetSegment()
CTIndex.SetNullFlag
Syntax
void SetNullFlag(bool NullFlag)
Parameters
- NullFlag [in] The new null flag.
Description
Sets the null flag. If set to true, the system checks for NULL or missing key values after the index has been concatenated.
Return
None.
See Also
GetNullFlag(), SetEmptyChar()
CTIndex.SetTemporaryFlag
Syntax
void SetTemporaryFlag(bool TempFlag)
Parameters
- TempFlag [in] The temporary flag.
Description
Sets the temporary flag. If set to true, this index is a temporary index.
Return
None.
See Also
GetTemporaryFlag()