Package com.mckoi.database
Class IndexStore.MappedListBlock
- java.lang.Object
-
- com.mckoi.util.IntegerListBlockInterface
-
- com.mckoi.util.BlockIntegerList.IntArrayListBlock
-
- com.mckoi.database.IndexStore.MappedListBlock
-
- Enclosing class:
- IndexStore
private final class IndexStore.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 intfirst_entryThe first entry in the block.private intindex_sectorThe sector in the index file that this block can be found.private intlast_entryThe last entry in the block.private java.lang.ObjectlockLock object.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(int first_int, int last_int, int mapped_sector, int 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.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.intgetIndexSector()Returns the sector in the file 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.intwriteToStore()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 int first_entry
The first entry in the block.
-
last_entry
private int last_entry
The last entry in the block.
-
index_sector
private int index_sector
The sector in the index file that 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.
-
-
Method Detail
-
getIndexSector
public int getIndexSector()
Returns the sector in the file of this block.
-
writeToStore
public int 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
-
-