|
deegree 2.5 (2011/06/29 09:44 build-8-official) | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.deegree.io.dbaseapi.DBaseIndex
public class DBaseIndex
A class for reading from and writing to DBase index files (*.ndx), maybe not 100% xbase compatible!
The fileformat is described at http://www.e-bachmann.dk/computing/databases/xbase/index.html
This index is suitable for indexing both unique and non-unique columns. Unique indexing is much faster than non-unique because it use a faster algorithm.
The index file is a B+tree (sometimes called a paged B-tree) that consist of pages. There are two page types, leaves and non-leafs. The starting page (eg. the page the search algorithm starts) is the root page.
Searching goes as follows:
Above algorithm is implemented in two different methods, one for unique indexes and one for non-unique indexes. Searching unique indexes is easier because the algorithm is finished as soon as it has found a key, the non-unique version of the algorithm has to find all keys present in the index.
Inserting goes as follows:
If a page that splits does not have a parent page then a new page is created. This page is the new starting page
Handling different data types: The index can handle strings and numbers. Numbers are always stored als IEEE doubles. The method addKey checks the given key and throws an exception if the datatype of the key doesn't suit the index
Nested Class Summary | |
---|---|
class |
DBaseIndex.Cache
Inner class for the cache. |
Field Summary | |
---|---|
protected byte[] |
b
|
protected int |
cacheSize
|
protected java.io.RandomAccessFile |
file
|
protected byte[] |
keyBytes
|
protected int |
keyLength
|
protected int |
keyType
|
protected int |
noOfKeysPerPage
|
protected int |
numberOfPages
|
protected byte[] |
page
|
protected int |
sizeOfKeyRecord
|
protected int |
startingPageNo
|
Constructor Summary | |
---|---|
DBaseIndex(java.lang.String name)
Open an existing .ndx file |
Method Summary | |
---|---|
void |
addKey(java.lang.Comparable key,
int record)
Add a key to the index |
void |
close()
Close the index file |
static DBaseIndex |
createIndex(java.lang.String name,
java.lang.String column,
int keyLength,
boolean uniqueFlag,
boolean numbers)
Create a new index |
void |
flush()
Flush all the buffers |
int |
getDepth()
Calculate the depth for the index |
protected org.deegree.io.dbaseapi.DBaseIndex.Page |
getPage(int number)
Get a page |
boolean |
isUnique()
Contains this index unique values? |
protected org.deegree.io.dbaseapi.DBaseIndex.Page |
newPage()
Create a new page |
int[] |
search(java.lang.Comparable key)
|
protected void |
setRoot(org.deegree.io.dbaseapi.DBaseIndex.Page page)
Set the root page |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.io.RandomAccessFile file
protected int startingPageNo
protected int numberOfPages
protected int sizeOfKeyRecord
protected int keyLength
protected int noOfKeysPerPage
protected int keyType
protected byte[] b
protected byte[] page
protected byte[] keyBytes
protected int cacheSize
Constructor Detail |
---|
public DBaseIndex(java.lang.String name) throws java.io.IOException
java.io.IOException
Method Detail |
---|
protected org.deegree.io.dbaseapi.DBaseIndex.Page getPage(int number) throws java.io.IOException
java.io.IOException
protected org.deegree.io.dbaseapi.DBaseIndex.Page newPage() throws java.io.IOException
java.io.IOException
protected void setRoot(org.deegree.io.dbaseapi.DBaseIndex.Page page)
public static DBaseIndex createIndex(java.lang.String name, java.lang.String column, int keyLength, boolean uniqueFlag, boolean numbers) throws java.io.IOException
java.io.IOException
public void flush() throws java.io.IOException
java.io.IOException
public void close() throws java.io.IOException
java.io.IOException
public int[] search(java.lang.Comparable key) throws java.io.IOException, KeyNotFoundException, InvalidKeyTypeException
java.io.IOException
KeyNotFoundException
InvalidKeyTypeException
public void addKey(java.lang.Comparable key, int record) throws java.io.IOException, KeyAlreadyExistException, InvalidKeyTypeException, KeyTooLongException
java.io.IOException
KeyAlreadyExistException
InvalidKeyTypeException
KeyTooLongException
public int getDepth() throws java.io.IOException
java.io.IOException
public boolean isUnique()
public java.lang.String toString()
toString
in class java.lang.Object
|
deegree 2.5 (2011/06/29 09:44 build-8-official) | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org