Package com.mckoi.database
Class IndexSetStore.IndexBlock
- java.lang.Object
-
- com.mckoi.database.IndexSetStore.IndexBlock
-
- Enclosing class:
- IndexSetStore
private class IndexSetStore.IndexBlock extends java.lang.Object
Represents a single 'Index block' area in the store.An index block area contains an entry for each index element in an index. Each entry is 28 bytes in size and the area has a 16 byte header.
HEADER: ( version (int), reserved (int), index size (long) )
ENTRY: ( first entry (long), last entry (long), index element pointer (long), type/element size (int) )type/element size contains the number of elements in the block, and the block compaction factor. For example, type 1 means the block contains short sized index values, 2 is int sized index values, and 3 is long sized index values.
-
-
Field Summary
Fields Modifier and Type Field Description private long
block_entries
The total number of entries in the index block.private int
block_size
The block size of elements in this block.private boolean
deleted
True if this block is marked as deleted.private java.util.ArrayList
deleted_areas
The list of deleted areas that can safely be disposed when this object is disposed.private boolean
freed
Set to true when this index block is freed from the index store.private long
index_block_p
A pointer that references the area in the store.private int
index_num
The index of this block in the index set.private IndexSetStore.IndexBlock
parent_block
The parent IndexBlock.private int
reference_count
The number of references to this object.
-
Constructor Summary
Constructors Constructor Description IndexBlock(int index_num, int block_size, long index_block_p)
Constructs the IndexBlock.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDeletedArea(long pointer)
Adds to the list of deleted areas in this block.void
addReference()
Adds a reference to this object.(package private) long
copyTo(Store dest_store)
Copies this index block to the given Store and returns a pointer to the block within the store.(package private) IndexSetStore.IndexIntegerList
createIndexIntegerList()
Creates and returns a mutable IndexIntegerList object based on this view of the index.private IndexSetStore.MappedListBlock[]
createMappedListBlocks()
Creates and returns an array of all the MappedListBlock objects that make up this view of the index integer list.private boolean
deleteBlockChain()
Recursively calls through the block hierarchy and deletes and blocks that can be deleted.(package private) long[]
getAllBlockPointers()
Returns a list of pointers to all mapped blocks.int
getBlockSize()
Returns the block size that has been set on this list.long
getPointer()
Returns the pointer to this index block in the store.int
getReferenceCount()
Returns the number of references to this object.void
markAsDeleted()
Marks this block as deleted.void
removeReference()
Removes a reference to this object.(package private) void
setParentIndexBlock(IndexSetStore.IndexBlock parent)
Sets the parent IndexBlock, the index that this index block succeeded.
-
-
-
Field Detail
-
reference_count
private int reference_count
The number of references to this object. When this reaches 0, it is safe to free any resources that this block deleted.
-
index_num
private int index_num
The index of this block in the index set.
-
index_block_p
private final long index_block_p
A pointer that references the area in the store.
-
block_entries
private long block_entries
The total number of entries in the index block.
-
block_size
private final int block_size
The block size of elements in this block.
-
deleted_areas
private java.util.ArrayList deleted_areas
The list of deleted areas that can safely be disposed when this object is disposed.
-
deleted
private boolean deleted
True if this block is marked as deleted.
-
freed
private boolean freed
Set to true when this index block is freed from the index store.
-
parent_block
private IndexSetStore.IndexBlock parent_block
The parent IndexBlock. This block is a child modification of the parent.
-
-
Method Detail
-
setParentIndexBlock
void setParentIndexBlock(IndexSetStore.IndexBlock parent)
Sets the parent IndexBlock, the index that this index block succeeded.
-
getAllBlockPointers
long[] getAllBlockPointers() throws java.io.IOException
Returns a list of pointers to all mapped blocks.- Throws:
java.io.IOException
-
createMappedListBlocks
private IndexSetStore.MappedListBlock[] createMappedListBlocks() throws java.io.IOException
Creates and returns an array of all the MappedListBlock objects that make up this view of the index integer list.- Throws:
java.io.IOException
-
createIndexIntegerList
IndexSetStore.IndexIntegerList createIndexIntegerList() throws java.io.IOException
Creates and returns a mutable IndexIntegerList object based on this view of the index.- Throws:
java.io.IOException
-
copyTo
long copyTo(Store dest_store) throws java.io.IOException
Copies this index block to the given Store and returns a pointer to the block within the store.- Throws:
java.io.IOException
-
deleteBlockChain
private boolean deleteBlockChain()
Recursively calls through the block hierarchy and deletes and blocks that can be deleted.
-
addReference
public void addReference()
Adds a reference to this object.
-
removeReference
public void removeReference()
Removes a reference to this object.
-
getReferenceCount
public int getReferenceCount()
Returns the number of references to this object.
-
getBlockSize
public int getBlockSize()
Returns the block size that has been set on this list.
-
getPointer
public long getPointer()
Returns the pointer to this index block in the store.
-
markAsDeleted
public void markAsDeleted()
Marks this block as deleted.
-
addDeletedArea
public void addDeletedArea(long pointer)
Adds to the list of deleted areas in this block.
-
-