#include <IndexManager.h>
Public Member Functions | |
| ReturnCode | createIndex (const char *fileName, int attrNo, AttributeType attrType, int attrLength) |
| Creates a new index on the specified record file. | |
| ReturnCode | removeIndex (const char *fileName, int attrNo) |
| Deletes an index for the specified record file. | |
| ReturnCode | openIndex (const char *fileName, int attrNo, IndexHandle **indexHandle) |
| Opens an index for the specified record file. | |
| ReturnCode | closeIndex (IndexHandle *indexHandle) |
| Closes an index for the specified record file. | |
Static Public Member Functions | |
| static IndexManager * | getInstance () |
| Gets the singleton IndexManager instance. | |
| static bool | getIndexFileName (const char *fileName, int attrNo, char *indexFileName, uint length) |
| Get the name to be used for the index file for the specified record file and attribute number. | |
Class for creating, destroying, opening, and closing B+ tree index files. This is a singleton class; a reference to the singleton is obtained by calling IndexManager::getInstance. Manipulation of the contents of index files is done via the IndexHandle class; while scans of the index are done via the IndexScan class.
| ReturnCode IndexManager::createIndex | ( | const char * | fileName, | |
| int | attrNo, | |||
| AttributeType | attrType, | |||
| int | attrLength | |||
| ) |
Creates a new index on the specified record file.
| fileName | The name of the record file being indexed. | |
| attrNo | A number specifying which attribute is being indexed | |
| attrType | The type of the record attribute begin indexed | |
| attrLength | The length in bytes of the attribute being indexed |
| ReturnCode IndexManager::removeIndex | ( | const char * | fileName, | |
| int | attrNo | |||
| ) |
Deletes an index for the specified record file.
| fileName | The name of the record file that was indexed | |
| attrNo | A number specifying which attribute was indexed |
| ReturnCode IndexManager::openIndex | ( | const char * | fileName, | |
| int | attrNo, | |||
| IndexHandle ** | indexHandle | |||
| ) |
Opens an index for the specified record file.
| fileName | The name of the record file associated with this index | |
| attrNo | A number specifying which attribute this index is on | |
| indexHandle | Out parameter where the newly allocated IndexHandle is returned |
The returned IndexHandle is used to insert and delete entries from the index, and it can be passed into an IndexScan object constructor for performing a scan using the index. As with the RecordManager components, clients should be able to open an index more than once for reading, using a different IndexHandle object each time. However, you may make the assumption that if a client is modifying an index, then no other clients are using an IndexHandle to read or modify that index. An opened index must eventually be closed using IndexManager::closeIndex.
| ReturnCode IndexManager::closeIndex | ( | IndexHandle * | indexHandle | ) |
Closes an index for the specified record file.
| indexHandle | The handle to the open index |
| bool IndexManager::getIndexFileName | ( | const char * | fileName, | |
| int | attrNo, | |||
| char * | indexFileName, | |||
| uint | length | |||
| ) | [static] |
Get the name to be used for the index file for the specified record file and attribute number.
| fileName | The file name for the record file | |
| attrNo | The logical index of the attribute in the record | |
| indexFileName | Out parameter where the index file name will be written | |
| length | The length in bytes of the indexFileName buffer |
1.5.6