Package elki.index.tree
Class TreeIndexHeader
- java.lang.Object
-
- elki.persistent.DefaultPageHeader
-
- elki.index.tree.TreeIndexHeader
-
- All Implemented Interfaces:
PageHeader
- Direct Known Subclasses:
MkTreeHeader
,RdKNNTreeHeader
public class TreeIndexHeader extends DefaultPageHeader
Encapsulates the header information of a tree-like index structure. This information is needed for persistent storage.- Since:
- 0.1
- Author:
- Elke Achtert
-
-
Field Summary
Fields Modifier and Type Field Description (package private) int
dirCapacity
The capacity of a directory node (= 1 + maximum number of entries in a directory node).(package private) int
dirMinimum
The minimum number of entries in a directory node.private int
emptyPagesSize
The number of bytes additionally needed for the listing of empty pages of the headed page file.private int
largestPageID
The largest ID used so far(package private) int
leafCapacity
The capacity of a leaf node (= 1 + maximum number of entries in a leaf node).(package private) int
leafMinimum
The minimum number of entries in a leaf node.private static int
SIZE
The size of this header in Bytes, which is 20 Bytes ( 4 Bytes fordirCapacity
,leafCapacity
,dirMinimum
,leafMinimum
,emptyPagesSize
), andlargestPageID
.
-
Constructor Summary
Constructors Constructor Description TreeIndexHeader()
Empty constructor for serialization.TreeIndexHeader(int pageSize, int dirCapacity, int leafCapacity, int dirMinimum, int leafMinimum)
Creates a new header with the specified parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getDirCapacity()
Returns the capacity of a directory node (= 1 + maximum number of entries in a directory node).int
getDirMinimum()
Returns the minimum number of entries in a directory node.int
getEmptyPagesSize()
int
getLargestPageID()
int
getLeafCapacity()
Returns the capacity of a leaf node (= 1 + maximum number of entries in a leaf node).int
getLeafMinimum()
Returns the minimum number of entries in a leaf node.IntegerArray
readEmptyPages(java.nio.channels.FileChannel file)
Read the empty pages from the end offile
.void
readHeader(java.nio.ByteBuffer buffer)
Initializes this header from the specified file.void
setEmptyPagesSize(int emptyPagesSize)
Set the size required by the listing of empty pages.void
setLargestPageID(int largestPageID)
int
size()
ReturnsDefaultPageHeader.size()
plus the value ofSIZE
).void
writeEmptyPages(IntegerArray emptyPages, java.nio.channels.FileChannel file)
Write the indices of empty pages the the end offile
.void
writeHeader(java.nio.ByteBuffer buffer)
Writes this header to the specified file.-
Methods inherited from class elki.persistent.DefaultPageHeader
getPageSize, getReservedPages
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface elki.persistent.PageHeader
readHeader, writeHeader
-
-
-
-
Field Detail
-
SIZE
private static int SIZE
The size of this header in Bytes, which is 20 Bytes ( 4 Bytes fordirCapacity
,leafCapacity
,dirMinimum
,leafMinimum
,emptyPagesSize
), andlargestPageID
.
-
dirCapacity
int dirCapacity
The capacity of a directory node (= 1 + maximum number of entries in a directory node).
-
leafCapacity
int leafCapacity
The capacity of a leaf node (= 1 + maximum number of entries in a leaf node).
-
dirMinimum
int dirMinimum
The minimum number of entries in a directory node.
-
leafMinimum
int leafMinimum
The minimum number of entries in a leaf node.
-
emptyPagesSize
private int emptyPagesSize
The number of bytes additionally needed for the listing of empty pages of the headed page file.
-
largestPageID
private int largestPageID
The largest ID used so far
-
-
Constructor Detail
-
TreeIndexHeader
public TreeIndexHeader()
Empty constructor for serialization.
-
TreeIndexHeader
public TreeIndexHeader(int pageSize, int dirCapacity, int leafCapacity, int dirMinimum, int leafMinimum)
Creates a new header with the specified parameters.- Parameters:
pageSize
- the size of a page in bytesdirCapacity
- the maximum number of entries in a directory nodeleafCapacity
- the maximum number of entries in a leaf nodedirMinimum
- the minimum number of entries in a directory nodeleafMinimum
- the minimum number of entries in a leaf node
-
-
Method Detail
-
readHeader
public void readHeader(java.nio.ByteBuffer buffer)
Initializes this header from the specified file. CallsDefaultPageHeader#readHeader(file)
and reads the integer values ofdirCapacity
,leafCapacity
,dirMinimum
,leafMinimum
andemptyPagesSize
from the file.- Specified by:
readHeader
in interfacePageHeader
- Overrides:
readHeader
in classDefaultPageHeader
- Parameters:
buffer
- byte array with the page data.
-
writeHeader
public void writeHeader(java.nio.ByteBuffer buffer)
Writes this header to the specified file. Writes the integer values ofdirCapacity
,leafCapacity
,dirMinimum
,leafMinimum
andemptyPagesSize
to the file.- Specified by:
writeHeader
in interfacePageHeader
- Overrides:
writeHeader
in classDefaultPageHeader
- Parameters:
buffer
- Buffer to write to
-
getDirCapacity
public int getDirCapacity()
Returns the capacity of a directory node (= 1 + maximum number of entries in a directory node).- Returns:
- the capacity of a directory node (= 1 + maximum number of entries in a directory node)
-
getLeafCapacity
public int getLeafCapacity()
Returns the capacity of a leaf node (= 1 + maximum number of entries in a leaf node).- Returns:
- the capacity of a leaf node (= 1 + maximum number of entries in a leaf node)
-
getDirMinimum
public int getDirMinimum()
Returns the minimum number of entries in a directory node.- Returns:
- the minimum number of entries in a directory node
-
getLeafMinimum
public int getLeafMinimum()
Returns the minimum number of entries in a leaf node.- Returns:
- the minimum number of entries in a leaf node
-
getEmptyPagesSize
public int getEmptyPagesSize()
- Returns:
- the number of bytes needed for the listing of empty pages
-
setEmptyPagesSize
public void setEmptyPagesSize(int emptyPagesSize)
Set the size required by the listing of empty pages.- Parameters:
emptyPagesSize
- the number of bytes needed for this listing of empty pages
-
getLargestPageID
public int getLargestPageID()
-
setLargestPageID
public void setLargestPageID(int largestPageID)
-
size
public int size()
ReturnsDefaultPageHeader.size()
plus the value ofSIZE
). Note, this is only the base size and probably not the overall size of this header, as there may be empty pages to be maintained.- Specified by:
size
in interfacePageHeader
- Overrides:
size
in classDefaultPageHeader
- Returns:
- the size of this header in Bytes
-
writeEmptyPages
public void writeEmptyPages(IntegerArray emptyPages, java.nio.channels.FileChannel file) throws java.io.IOException
Write the indices of empty pages the the end offile
. Calling this method should be followed by aPageHeader.writeHeader(FileChannel)
.- Parameters:
emptyPages
- the stack of empty page ids which remain to be filledfile
- File to work with- Throws:
java.io.IOException
- thrown on IO errors
-
readEmptyPages
public IntegerArray readEmptyPages(java.nio.channels.FileChannel file) throws java.io.IOException, java.lang.ClassNotFoundException
Read the empty pages from the end offile
.- Parameters:
file
- File to work with- Returns:
- a stack of empty pages in
file
- Throws:
java.io.IOException
- thrown on IO errorsjava.lang.ClassNotFoundException
- if the stack of empty pages could not be correctly read from file
-
-