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 int
first_entry
The first entry in the block.private int
index_sector
The sector in the index file that this block can be found.private int
last_entry
The last entry in the block.private java.lang.Object
lock
Lock object.private boolean
mutable_block
Set 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 int
bottomInt()
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.int
getArrayLength()
Overwritten from IntArrayListBlock, returns the capacity of the block.int
getIndexSector()
Returns the sector in the file of this block.private void
prepareMutate(boolean immutable)
Makes the block mutable if it is immutable.int
topInt()
Overwritten from IntArrayListBlock, returns the last entry of the block.int
writeToStore()
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.IOException
Writes 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:
getArray
in classBlockIntegerList.IntArrayListBlock
-
getArrayLength
public int getArrayLength()
Overwritten from IntArrayListBlock, returns the capacity of the block.- Overrides:
getArrayLength
in 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:
topInt
in classBlockIntegerList.IntArrayListBlock
-
bottomInt
public int bottomInt()
Overwritten from IntArrayListBlock, returns the first entry of the block.- Overrides:
bottomInt
in classBlockIntegerList.IntArrayListBlock
-
-