|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractMap
ru.biosoft.access.BTreeIndex
Maps keys to entries. A index cannot contain duplicate keys; each key can map to at most one entry.
Key and entries stored in file as Balanced Tree.
Keys are strings and entryes are Index.IndexEntry.
Index.IndexEntry| Nested Class Summary | |
protected class |
BTreeIndex.Block
One block of index file. |
static class |
BTreeIndex.IntKey
|
static class |
BTreeIndex.NodeKey
|
| Nested classes inherited from class ru.biosoft.access.Index |
Index.IndexEntry, Index.StringIndexEntry |
| Nested classes inherited from class java.util.Map |
java.util.Map.Entry |
| Field Summary | |
protected int |
currSize
Current size of index |
static int |
DEFAULT_BLOCK_SIZE
Default file block size. |
protected java.io.RandomAccessFile |
indexFile
Index file |
protected BTreeIndex.Block |
root
Root |
static int |
ROOT_BLOCK_OFFSET
Root block offset |
| Fields inherited from interface ru.biosoft.access.Index |
DEFAULT_INDEX_NAME |
| Constructor Summary | |
BTreeIndex(java.io.File dataFile,
java.lang.String indexName,
java.lang.String indexPath)
Create index with DEFAULT_BLOCK_SIZE. |
|
BTreeIndex(java.io.File dataFile,
java.lang.String indexName,
java.lang.String indexPath,
int blockSize)
Construct index based on specified file. |
|
| Method Summary | |
void |
clear()
Removes all keys and entries from this index. |
void |
close()
Close this index and releases resources (index file). |
boolean |
containsKey(java.lang.Object key)
Returns true if this index contains entry for the specified key. |
java.lang.Object |
createNode(byte[] buffer,
int pos)
|
java.lang.Object |
createNode(byte[] buffer,
int pos,
java.lang.String key,
Index.IndexEntry value)
|
java.util.Set |
entrySet()
Returns a set view of the mappings contained in this index. |
protected void |
finalize()
|
java.lang.Object |
get(java.lang.Object key)
Returns the entry to which this index maps the specified key. |
protected BTreeIndex.Block |
getBlock(int offset)
|
java.io.File |
getIndexFile()
Returns index file. |
boolean |
isValid()
Check is index file is valid. |
java.util.Iterator |
keyIterator(Key key)
|
java.util.Iterator |
nodeIterator(Key key)
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object entry)
Associates the specified entry with the specified key in this index. |
java.lang.Object |
remove(java.lang.Object key)
Removes the entry for this key from this index if present. |
int |
size()
Returns the number of key-entry mappings in this index. |
| Methods inherited from class java.util.AbstractMap |
clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, toString, values |
| Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
containsValue, equals, hashCode, isEmpty, keySet, putAll, values |
| Field Detail |
public static final int DEFAULT_BLOCK_SIZE
public static final int ROOT_BLOCK_OFFSET
protected java.io.RandomAccessFile indexFile
protected int currSize
protected BTreeIndex.Block root
| Constructor Detail |
public BTreeIndex(java.io.File dataFile,
java.lang.String indexName,
java.lang.String indexPath,
int blockSize)
throws java.io.IOException
dataFile - File for which index will be created. (or already created)indexName - Name of the index. Will be added to index file name.blockSize - Size of block for file operations.
java.io.IOException - if an I/O error occurs.
public BTreeIndex(java.io.File dataFile,
java.lang.String indexName,
java.lang.String indexPath)
throws java.io.IOException
DEFAULT_BLOCK_SIZE.
dataFile - File for which index will be created. (or already created)indexName - Name of the index. Will be added to index file name.
java.io.IOException - if an I/O error occurs.#BTreeIndex(File,String,int)| Method Detail |
public java.lang.Object createNode(byte[] buffer,
int pos,
java.lang.String key,
Index.IndexEntry value)
public java.lang.Object createNode(byte[] buffer,
int pos)
public java.util.Iterator keyIterator(Key key)
public java.util.Iterator nodeIterator(Key key)
nodeIterator in interface Indexpublic boolean isValid()
isValid in interface Indextrue if index valid, false otherwise.clear()public int size()
size in interface java.util.Mappublic java.util.Set entrySet()
entrySet in interface java.util.Mappublic boolean containsKey(java.lang.Object key)
containsKey in interface java.util.Mapkey - key whose presence in this index is to be tested.
java.lang.ClassCastException - if the key is not of type String.
java.lang.NullPointerException - key is null and this index does not
permit null keys.
ChainRuntimeException - if an I/O error occurs.
public java.lang.Object put(java.lang.Object key,
java.lang.Object entry)
put in interface java.util.Mapentry - entry to be associated with the specified key.
java.lang.ClassCastException - if the key is not of type String.
or entry is not of type Index.IndexEntry.
java.lang.IllegalArgumentException - if some aspect of this key or entry
prevents it from being stored in this index.
java.lang.NullPointerException - this index does not permit null
keys or entries, and the specified key or entry is
null.
ChainRuntimeException - if an I/O error occurs.public java.lang.Object get(java.lang.Object key)
get in interface java.util.Mapkey - key whose associated entry is to be returned.
entry to which this index maps the specified key,
or null if the index not contains entry for this key.
java.lang.ClassCastException - if the key is not of type String.
java.lang.NullPointerException - key is null and this index does not
permit null keys.
ChainRuntimeException - if an I/O error occurs.Index.IndexEntrypublic java.lang.Object remove(java.lang.Object key)
remove in interface java.util.Mapkey - key whose entry is to be removed from the index.
entry associated with
specified key, or null if there was no entry for key.
java.lang.ClassCastException - if the key is not of type String.
ChainRuntimeException - if an I/O error occurs.public java.io.File getIndexFile()
getIndexFile in interface Indexpublic void clear()
clear in interface java.util.MapChainRuntimeException - if an I/O error occurs.
public void close()
throws java.io.IOException
close in interface Indexjava.io.IOException - if an I/O error occurs.
protected void finalize()
throws java.lang.Throwable
java.lang.Throwable
protected BTreeIndex.Block getBlock(int offset)
throws java.io.IOException
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||