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

      • MappedListBlock

        public MappedListBlock​(long first_e,
                               long last_e,
                               long mapped_p,
                               int size,
                               byte compact_type,
                               int max_block_size)
        Constructor.
      • MappedListBlock

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