Package com.mckoi.database
Class IndexSetStore.MappedListBlock
- java.lang.Object
-
- com.mckoi.util.IntegerListBlockInterface
-
- com.mckoi.util.BlockIntegerList.IntArrayListBlock
-
- com.mckoi.database.IndexSetStore.MappedListBlock
-
- Enclosing class:
- IndexSetStore
private final class IndexSetStore.MappedListBlock extends BlockIntegerList.IntArrayListBlock
An IntegerListBlockInterface implementation that maps a block of a list to an underlying file system representation.
-
-
Field Summary
Fields Modifier and Type Field Description private longblock_pA pointer to the area where this block can be found.private bytecompact_typeHow this block is compacted in the store.private longfirst_entryThe first entry in the block.private longlast_entryThe last entry in the block.private java.lang.ObjectlockLock object.private intmax_block_sizeThe maximum size of the block.private booleanmutable_blockSet to true if the loaded block is mutable.-
Fields inherited from class com.mckoi.util.BlockIntegerList.IntArrayListBlock
array, count
-
Fields inherited from class com.mckoi.util.IntegerListBlockInterface
next, previous
-
-
Constructor Summary
Constructors Constructor Description MappedListBlock(int block_size_in)Creates an empty block.MappedListBlock(long first_e, long last_e, long mapped_p, int size, byte compact_type, int max_block_size)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intbottomInt()Overwritten from IntArrayListBlock, returns the first entry of the block.longcopyTo(Store dest_store)Copies the index data in this block to a new block in the given store and returns a pointer to the new block.int[]getArray(boolean immutable)Overwritten from IntArrayListBlock, this returns the int[] array that contains the contents of the block.intgetArrayLength()Overwritten from IntArrayListBlock, returns the capacity of the block.longgetBlockPointer()Returns a pointer to the area that contains this block.bytegetCompactType()Returns the compact type of this block.private voidprepareMutate(boolean immutable)Makes the block mutable if it is immutable.inttopInt()Overwritten from IntArrayListBlock, returns the last entry of the block.longwriteToStore()Writes this block to a new sector in the index file and updates the information in this object accordingly.-
Methods inherited from class com.mckoi.util.BlockIntegerList.IntArrayListBlock
addInt, binarySearch, canContain, clear, copyTo, copyTo, insertIntAt, intAt, isEmpty, isFull, iterativeSearch, iterativeSearch, moveTo, removeIntAt, searchFirst, searchFirst, searchLast, searchLast, setIntAt, size, toString
-
Methods inherited from class com.mckoi.util.IntegerListBlockInterface
hasChanged
-
-
-
-
Field Detail
-
first_entry
private long first_entry
The first entry in the block.
-
last_entry
private long last_entry
The last entry in the block.
-
block_p
private long block_p
A pointer to the area where this block can be found.
-
lock
private java.lang.Object lock
Lock object.
-
mutable_block
private boolean mutable_block
Set to true if the loaded block is mutable.
-
compact_type
private byte compact_type
How this block is compacted in the store. If this is 1 the elements are stored as shorts, if it is 2 - ints, and if it is 3 - longs.
-
max_block_size
private final int max_block_size
The maximum size of the block.
-
-
Method Detail
-
getBlockPointer
public long getBlockPointer()
Returns a pointer to the area that contains this block.
-
getCompactType
public byte getCompactType()
Returns the compact type of this block.
-
copyTo
public long copyTo(Store dest_store) throws java.io.IOException
Copies the index data in this block to a new block in the given store and returns a pointer to the new block.- Throws:
java.io.IOException
-
writeToStore
public long writeToStore() throws java.io.IOExceptionWrites this block to a new sector in the index file and updates the information in this object accordingly.Returns the sector the block was written to.
- Throws:
java.io.IOException
-
getArray
public int[] getArray(boolean immutable)
Overwritten from IntArrayListBlock, this returns the int[] array that contains the contents of the block. In this implementation, we determine if the array has been read from the index file. If it hasn't we read it in, otherwise we use the version in memory.- Overrides:
getArrayin classBlockIntegerList.IntArrayListBlock
-
getArrayLength
public int getArrayLength()
Overwritten from IntArrayListBlock, returns the capacity of the block.- Overrides:
getArrayLengthin classBlockIntegerList.IntArrayListBlock
-
prepareMutate
private void prepareMutate(boolean immutable)
Makes the block mutable if it is immutable. We must be synchronized on 'lock' before this method is called.
-
topInt
public int topInt()
Overwritten from IntArrayListBlock, returns the last entry of the block.- Overrides:
topIntin classBlockIntegerList.IntArrayListBlock
-
bottomInt
public int bottomInt()
Overwritten from IntArrayListBlock, returns the first entry of the block.- Overrides:
bottomIntin classBlockIntegerList.IntArrayListBlock
-
-