STORING AND RETRIEVING RECORD DATA
Often it is useful to be able to store a piece of data along with every record indexed. The ability to store a piece of data with each record indexed allows you to store and do a wide variety of things such as:
- Store a record id to coordinate Onix's index with the index of another database system.
- Store the text of document that was indexed
- Store a URL or file path to the document that was indexed.
- Store the image of the indexed document.
- Store a summary of the indexed document.
The material stored as part of a record's data can be either ASCII/ANSI characters or may be purely binary data. There are no limitations on the amount of data that is associated with every record other than those naturally imposed by the operating systems file system. The record data is stored in the same data file as the index itself which makes it easy to treat the record data and the index as a single unit rather than forcing the user or developer to have to deal with many different data files.
There are two different ways to store record data. The record data may be stored in either fixed length segments or in variable length segments. If you store data in a fixed length segment, Onix will store a fixed size piece of data along with each record. This can be advantageous if speed is an issue as the retrieval of fixed size record data is slightly faster than the retrieval of variable length pieces of record data. Storing your record data as a variable length piece of information allows you the flexibility of storing data -- no matter what the size. Furthermore, this typically results in a slightly smaller data file if your data sizes vary.
To store record data in your index, you will need to set up your index for storing this information at the time you create it with ixCreateIndexEx. There are several index creation parameters that need to be set. These are:
- ixSetVariableLengthRecordInfo -- If you want to store record data in a variable length format within the index.
- ixSetFixedLengthRecordInfo -- If you would like to store record data in a fixed length format within the index.
- ixSet32BitRecordInfoOffset -- Stores the data offsets as 32 bit unsigned integers. This is what is used for virtually all systems and indexes.
- ixSet64BitRecordInfoOffset -- Stores the data offsets as 64 bit unsigned integers. This is only used for 64 bit operating systems.
These settings are set using the function ixSetIndexCreationParams.
Note: If you specify that you are going to store record data in the index, record data must be stored with every record indexed. If not, errors may occur.