Class 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 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.
    • Constructor Detail

      • MappedListBlock

        public MappedListBlock​(int first_int,
                               int last_int,
                               int mapped_sector,
                               int size)
        Constructor.
      • MappedListBlock

        public MappedListBlock​(int block_size_in)
        Creates an empty block.
    • 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 class BlockIntegerList.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.