Class SerializedMemoryBlock<K extends>

  • Type Parameters:
    K - the key type of its partitions.
    All Implemented Interfaces:

    public final class SerializedMemoryBlock<K extends>
    extends java.lang.Object
    implements Block<K>
    This class represents a block which is serialized and stored in local memory. Concurrent read is supported, but concurrent write is not supported.
    • Constructor Detail

      • SerializedMemoryBlock

        public SerializedMemoryBlock​(java.lang.String blockId,
                                     Serializer serializer,
                                     MemoryPoolAssigner memoryPoolAssigner)
        blockId - the ID of this block.
        serializer - the Serializer.
        memoryPoolAssigner - the MemoryPoolAssigner for memory allocation.
    • Method Detail

      • write

        public void write​(K key,
                          java.lang.Object element)
        Writes an element to non-committed block. Invariant: This should not be invoked after this block is committed. Invariant: This method does not support concurrent write.
        Specified by:
        write in interface Block<K extends>
        key - the key.
        element - the element to write.
        BlockWriteException - for any error occurred while trying to write a block.
      • readPartitions

        public java.lang.Iterable<NonSerializedPartition<K>> readPartitions​(KeyRange keyRange)
        Retrieves the NonSerializedPartitions in a specific hash range from this block. Because the data is stored in a serialized form, it have to be deserialized. Invariant: This should not be invoked before this block is committed.
        Specified by:
        readPartitions in interface Block<K extends>
        keyRange - the key range to retrieve.
        an iterable of NonSerializedPartitions.
        BlockFetchException - for any error occurred while trying to fetch a block.
      • commit

        public java.util.Optional<java.util.Map<K,​java.lang.Long>> commit()
        Commits this block to prevent further write.
        Specified by:
        commit in interface Block<K extends>
        the size of each partition.
        BlockWriteException - for any error occurred while trying to write a block.
      • commitPartitions

        public void commitPartitions()
        Commits all un-committed partitions.
        Specified by:
        commitPartitions in interface Block<K extends>
      • getId

        public java.lang.String getId()
        Specified by:
        getId in interface Block<K extends>
        the ID of this block.
      • isCommitted

        public boolean isCommitted()
        Specified by:
        isCommitted in interface Block<K extends>
        whether this block is committed or not.
      • release

        public void release()
        Releases the resource (i.e., off-heap memory) that the block holds.