public class TreeIndexHeader extends DefaultPageHeader
Modifier and Type | Field and 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 for
dirCapacity , leafCapacity , dirMinimum ,
leafMinimum , and emptyPagesSize ). |
Constructor and 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.
|
Modifier and Type | Method and 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.
|
java.util.Stack<java.lang.Integer> |
readEmptyPages(java.io.RandomAccessFile file)
Read the empty pages from the end of
file . |
void |
readHeader(java.io.RandomAccessFile file)
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()
Returns
DefaultPageHeader.size()
plus the value of SIZE ). |
void |
writeEmptyPages(java.util.Stack<java.lang.Integer> emptyPages,
java.io.RandomAccessFile file)
Write the indices of empty pages the the end of
file . |
void |
writeHeader(java.io.RandomAccessFile file)
Writes this header to the specified file.
|
asByteArray, getPageSize, getReservedPages, readHeader
private static int SIZE
dirCapacity
, leafCapacity
, dirMinimum
,
leafMinimum
, and emptyPagesSize
).int dirCapacity
int leafCapacity
int dirMinimum
int leafMinimum
private int emptyPagesSize
private int largestPageID
public TreeIndexHeader()
public TreeIndexHeader(int pageSize, int dirCapacity, int leafCapacity, int dirMinimum, int leafMinimum)
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 nodepublic void readHeader(java.io.RandomAccessFile file) throws java.io.IOException
DefaultPageHeader#readHeader(file)
and reads the integer values of
dirCapacity
, leafCapacity
, dirMinimum
,
leafMinimum
and emptyPagesSize
from the file.readHeader
in interface PageHeader
readHeader
in class DefaultPageHeader
file
- the file to which this header belongsjava.io.IOException
- if an I/O-error occurs during readingpublic void writeHeader(java.io.RandomAccessFile file) throws java.io.IOException
dirCapacity
, leafCapacity
, dirMinimum
,
leafMinimum
and emptyPagesSize
to the file.writeHeader
in interface PageHeader
writeHeader
in class DefaultPageHeader
file
- the file to which this header belongsjava.io.IOException
- IOException if an I/O-error occurs during writingpublic int getDirCapacity()
public int getLeafCapacity()
public int getDirMinimum()
public int getLeafMinimum()
public int getEmptyPagesSize()
public void setEmptyPagesSize(int emptyPagesSize)
emptyPagesSize
- the number of bytes needed for this listing of empty
pagespublic int getLargestPageID()
public void setLargestPageID(int largestPageID)
public int size()
DefaultPageHeader.size()
plus the value of SIZE
). 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.size
in interface PageHeader
size
in class DefaultPageHeader
public void writeEmptyPages(java.util.Stack<java.lang.Integer> emptyPages, java.io.RandomAccessFile file) throws java.io.IOException
file
. Calling
this method should be followed by a writeHeader(RandomAccessFile)
.emptyPages
- the stack of empty page ids which remain to be filledfile
- File to work withjava.io.IOException
- thrown on IO errorspublic java.util.Stack<java.lang.Integer> readEmptyPages(java.io.RandomAccessFile file) throws java.io.IOException, java.lang.ClassNotFoundException
file
.file
- File to work withfile
java.io.IOException
- thrown on IO errorsjava.lang.ClassNotFoundException
- if the stack of empty pages could not be
correctly read from fileCopyright © 2019 ELKI Development Team. License information.