N
- the type of Node used in the indexE
- the type of Entry used in the indexpublic abstract class IndexTree<N extends Node<E>,E extends Entry> extends Object
Modifier and Type | Field and Description |
---|---|
protected int |
dirCapacity
The capacity of a directory node (= 1 + maximum number of entries in a
directory node).
|
protected int |
dirMinimum
The minimum number of entries in a directory node.
|
private PageFile<N> |
file
The file storing the entries of this index.
|
protected boolean |
initialized
True if this index is already initialized.
|
protected int |
leafCapacity
The capacity of a leaf node (= 1 + maximum number of entries in a leaf
node).
|
protected int |
leafMinimum
The minimum number of entries in a leaf node.
|
private E |
rootEntry
The entry representing the root node.
|
Constructor and Description |
---|
IndexTree(PageFile<N> pagefile)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
createEmptyRoot(E exampleLeaf)
Creates an empty root node and writes it to file.
|
protected TreeIndexHeader |
createHeader()
Creates a header for this index structure which is an instance of
TreeIndexHeader . |
protected abstract N |
createNewDirectoryNode()
Creates a new directory node with the specified capacity.
|
protected abstract N |
createNewLeafNode()
Creates a new leaf node with the specified capacity.
|
protected abstract E |
createRootEntry()
Creates an entry representing the root node.
|
protected void |
deleteNode(N node)
Delete a node from the backing storage.
|
protected PageFile<N> |
getFile()
Deprecated.
|
protected abstract Logging |
getLogger()
Get the (STATIC) logger for this class.
|
N |
getNode(E entry)
Returns the node that is represented by the specified entry.
|
N |
getNode(int nodeID)
Returns the node with the specified id.
|
protected int |
getPageID(Entry entry)
Convert a directory entry to its page id.
|
protected int |
getPageSize()
Get the page size of the backing storage.
|
N |
getRoot()
Reads the root node of this index from the file.
|
E |
getRootEntry()
Returns the entry representing the root if this index.
|
int |
getRootID()
Page ID of the root entry.
|
IndexTreePath<E> |
getRootPath()
Returns the path to the root of this tree.
|
void |
initialize()
Initialize the tree if the page file already existed.
|
protected void |
initialize(E exampleLeaf)
Initializes the index.
|
protected abstract void |
initializeCapacities(E exampleLeaf)
Determines the maximum and minimum number of entries in a node.
|
void |
initializeFromFile(TreeIndexHeader header,
PageFile<N> file)
Initializes this index from an existing persistent file.
|
protected boolean |
isRoot(N page)
Test if a given ID is the root.
|
void |
logStatistics()
Log some statistics, if enabled.
|
protected void |
postDelete(E entry)
Performs necessary operations after deleting the specified entry.
|
protected void |
preInsert(E entry)
Performs necessary operations before inserting the specified entry.
|
protected void |
writeNode(N node)
Write a node to the backing storage.
|
protected boolean initialized
protected int dirCapacity
protected int leafCapacity
protected int dirMinimum
protected int leafMinimum
public void initialize()
protected abstract Logging getLogger()
public final E getRootEntry()
public final int getRootID()
public N getRoot()
protected boolean isRoot(N page)
page
- Page to testprotected int getPageID(Entry entry)
entry
- Entrypublic N getNode(int nodeID)
nodeID
- the page id of the node to be returnedpublic final N getNode(E entry)
entry
- the entry representing the node to be returnedprotected void writeNode(N node)
node
- Node to writeprotected void deleteNode(N node)
node
- Node to deleteprotected TreeIndexHeader createHeader()
TreeIndexHeader
. Subclasses may need to overwrite this method if
they need a more specialized header.public void initializeFromFile(TreeIndexHeader header, PageFile<N> file)
header
- File headerfile
- Page fileprotected final void initialize(E exampleLeaf)
exampleLeaf
- an object that will be stored in the indexpublic final IndexTreePath<E> getRootPath()
protected abstract void initializeCapacities(E exampleLeaf)
exampleLeaf
- an object that will be stored in the indexprotected abstract void createEmptyRoot(E exampleLeaf)
exampleLeaf
- an object that will be stored in the indexprotected abstract E createRootEntry()
protected abstract N createNewLeafNode()
protected abstract N createNewDirectoryNode()
protected void preInsert(E entry)
entry
- the entry to be insertedprotected void postDelete(E entry)
entry
- the entry that was removedpublic void logStatistics()
protected int getPageSize()
@Deprecated protected PageFile<N> getFile()