| java.lang.Object com.sun.midp.rms.RecordStoreIndex
RecordStoreIndex | class RecordStoreIndex (Code) | | A class implementing a index of the record store.
Methods used by the RecordStoreImpl
close()
deleteIndex()
getRecordIDs()
getRecordHeader()
getFreeBlock()
updateBlock()
deleteRecordIndex()
removeBlock()
|
Method Summary | |
void | close() Closes the index file. | static boolean | deleteIndex(int suiteId, String recordStoreName) Deletes index files of the named record store. | int | deleteKey(Node node, int key) Searches the tree starting with the given node for the given key. | void | deleteRecordIndex(int recordId) The record is deleted from the record store index. | int | getBlockOffsetOfRecord(int recordId) | int | getFreeBlock(byte[] header) Searches for a free block large enough for the record. | int | getFreeBlockRootOffset() Gets the offset to the root of the free block tree. | int | getKeyValue(Node node, int key) | int | getRecordHeader(int recordId, byte[] header) Finds the record header for the given record and returns the
offset to the header. | int[] | getRecordIDs() Returns all of the recordId's currently in the record store index. | int | getRecordIdRootOffset() Gets the offset to the root of the recordId tree. | int | getRecordIds(int[] recordIdList) Returns places all of the recordId's in the index. | void | removeBlock(int blockOffset, byte[] header) Removes the given block from the list of free blocks. | void | setFreeBlockRootOffset(int newOffset) Sets the offset to the root of the free block tree. | void | setRecordIdRootOffset(int newOffset) Sets the offset to the root of the recordId tree. | void | updateBlock(int blockOffset, byte[] header) Updates the index of the given block and its offset. | int | updateKey(Node node, int key, int value) Updates the tree starting with the given node with the key value pair.
If the key is already in the tree, the value is updated. | void | updateRecordId(int recordId, int blockOffset) Updates the given recordId with the given offset. | int | walk(Node node, int[] keyList, int count) Walks the tree starting at the given node and loads all of the tree's
keys into the given array. |
IDX0_SIZE | final static int IDX0_SIZE(Code) | | IDX_SIZE offset
|
IDX1_ID_ROOT | final static int IDX1_ID_ROOT(Code) | | IDX_ID_ROOT offset
|
IDX2_FREE_BLOCK_ROOT | final static int IDX2_FREE_BLOCK_ROOT(Code) | | IDX_FREE_ROOT offset
|
IDX3_FREE_NODE_HEAD | final static int IDX3_FREE_NODE_HEAD(Code) | | IDX_FREE_NODES offset
|
IDX_HEADER_SIZE | final static int IDX_HEADER_SIZE(Code) | | Size of the index header
|
NODE_ELEMENTS | final static int NODE_ELEMENTS(Code) | | The maximum number of data elements in each node
|
NODE_SIZE | final static int NODE_SIZE(Code) | | The size of the tree blocks
|
RecordStoreIndex | RecordStoreIndex(AbstractRecordStoreImpl rs, int suiteId, String recordStoreName) throws IOException(Code) | | Constructor for creating an index object for the given Record Store.
Parameters: rs - record store that this object indexes Parameters: suiteId - unique ID of the suite that owns the store Parameters: recordStoreName - a string to name the record store exception: IOException - if there are any file errors |
deleteIndex | static boolean deleteIndex(int suiteId, String recordStoreName)(Code) | | Deletes index files of the named record store. MIDlet suites are
only allowed to delete their own record stores.
Parameters: suiteId - ID of the MIDlet suite that owns the record store Parameters: recordStoreName - the MIDlet suite unique record store todelete true if file was found and deleted successfully,false otherwise. |
deleteKey | int deleteKey(Node node, int key) throws IOException(Code) | | Searches the tree starting with the given node for the given key. If
the key is in the tree, the key value pair is deleted. If the key
is not in the tree, nothing happens. If the deletion causes the root
node to be merged, the offset to the new root is returned, otherwise 0
is returned.
Parameters: node - the root node of the tree to remove key from Parameters: key - the key to remove exception: IOException - if there is an error accessing the index file the offset of the new tree root if the old one was removed,otherwise 0 |
deleteRecordIndex | void deleteRecordIndex(int recordId) throws IOException(Code) | | The record is deleted from the record store index.
Parameters: recordId - the ID of the record index to delete exception: IOException - if there is an error accessing the db index |
getBlockOffsetOfRecord | int getBlockOffsetOfRecord(int recordId) throws IOException, InvalidRecordIDException(Code) | | Returns the offset to the header for the given recordId
Parameters: recordId - the ID of the record to use in this operation exception: IOException - if there is an error accessing the db file exception: InvalidRecordIDException - if the recordId is invalid the offset in the db file of the record block |
getFreeBlock | int getFreeBlock(byte[] header) throws IOException(Code) | | Searches for a free block large enough for the record.
Parameters: header - a block header with the size set to the record data size exception: IOException - if there is an error accessing the db file the offset in the db file of the block added |
getFreeBlockRootOffset | int getFreeBlockRootOffset() throws IOException(Code) | | Gets the offset to the root of the free block tree.
exception: IOException - if there is an error accessing the index file the offset of the free block tree |
getKeyValue | int getKeyValue(Node node, int key) throws IOException(Code) | | Searches the tree starting at the given node for the given key and
returns the value associated with the key
Parameters: node - the root node of the tree to search for the key Parameters: key - the search key exception: IOException - if there is an error accessing the index file the value for the key or 0 if the key was not found |
getRecordHeader | int getRecordHeader(int recordId, byte[] header) throws IOException, InvalidRecordIDException(Code) | | Finds the record header for the given record and returns the
offset to the header.
Parameters: recordId - the ID of the record to use in this operation Parameters: header - the header of the block to free exception: IOException - if there is an error accessing the db file exception: InvalidRecordIDException - if the recordId is invalid the offset in the db file of the block added |
getRecordIDs | int[] getRecordIDs()(Code) | | Returns all of the recordId's currently in the record store index.
an array of the recordId's currently in the index. |
getRecordIdRootOffset | int getRecordIdRootOffset() throws IOException(Code) | | Gets the offset to the root of the recordId tree.
exception: IOException - if there is an error accessing the index file the offset of the recordId tree root |
getRecordIds | int getRecordIds(int[] recordIdList)(Code) | | Returns places all of the recordId's in the index.
If the array is not big enough, the recordId list will be
limited to the size of the given array.
Parameters: recordIdList - array to place the recordId's the number of recordId's placed in the array. |
removeBlock | void removeBlock(int blockOffset, byte[] header) throws IOException(Code) | | Removes the given block from the list of free blocks.
Parameters: blockOffset - the offset in db file to the block to remove Parameters: header - the header of the block to remove exception: IOException - if there is an error accessing the db file |
setFreeBlockRootOffset | void setFreeBlockRootOffset(int newOffset) throws IOException(Code) | | Sets the offset to the root of the free block tree.
Parameters: newOffset - the new root offset exception: IOException - if there is an error accessing the index file |
setRecordIdRootOffset | void setRecordIdRootOffset(int newOffset) throws IOException(Code) | | Sets the offset to the root of the recordId tree.
Parameters: newOffset - the new root offset exception: IOException - if there is an error accessing the index file |
updateBlock | void updateBlock(int blockOffset, byte[] header) throws IOException(Code) | | Updates the index of the given block and its offset.
Parameters: blockOffset - the offset in db file to the block to update Parameters: header - the header of the block to update exception: IOException - if there is an error accessing the index file |
updateKey | int updateKey(Node node, int key, int value) throws IOException(Code) | | Updates the tree starting with the given node with the key value pair.
If the key is already in the tree, the value is updated. If the key
is not in the tree, it is inserted. If the insertion causes the root
node to be split, the offset to the new root is returned, otherwise 0
is returned.
Parameters: node - the root node of the tree to update the key with Parameters: key - the key to update Parameters: value - the new value exception: IOException - if there is an error accessing the index file the offset of the new tree root if one was added, 0 otherwise |
updateRecordId | void updateRecordId(int recordId, int blockOffset) throws IOException(Code) | | Updates the given recordId with the given offset. Adds the
recordId if it did not already exist.
Parameters: recordId - the id of the record Parameters: blockOffset - the offset in db file to the block to update exception: IOException - if there is an error accessing the index file |
walk | int walk(Node node, int[] keyList, int count) throws IOException(Code) | | Walks the tree starting at the given node and loads all of the tree's
keys into the given array.
Parameters: node - the root node of the tree to walk Parameters: keyList - array to fill with the tree's keys Parameters: count - must be 0 for user call, other value for recursive call exception: IOException - if there is an error accessing the index file the number of keys placed into the array. |
|
|