Class FileMetadata<K extends java.io.Serializable>

  • Type Parameters:
    K - the key type of its partitions.
    Direct Known Subclasses:
    LocalFileMetadata, RemoteFileMetadata

    public abstract class FileMetadata<K extends java.io.Serializable>
    extends java.lang.Object
    This class represents a metadata for a Block. The writer and reader determine the status of a file block (such as accessibility, how many bytes are written, etc.) by using this metadata.
    • Constructor Detail

      • FileMetadata

        public FileMetadata()
        Construct a new file metadata.
      • FileMetadata

        public FileMetadata​(java.util.List<PartitionMetadata<K>> partitionMetadataList)
        Construct a file metadata with existing partition metadata.
        Parameters:
        partitionMetadataList - the partition metadata list.
    • Method Detail

      • writePartitionMetadata

        public final void writePartitionMetadata​(K key,
                                                 int partitionSize)
                                          throws java.io.IOException
        Writes the metadata for a partition.
        Parameters:
        key - the key of the partition.
        partitionSize - the size of the partition.
        Throws:
        java.io.IOException - if fail to append the partition metadata.
      • getPartitionMetadataList

        public final java.util.List<PartitionMetadata<K>> getPartitionMetadataList()
        Gets a list containing the partition metadata of corresponding block.
        Returns:
        the list containing the partition metadata.
      • deleteMetadata

        public abstract void deleteMetadata()
                                     throws java.io.IOException
        Deletes the metadata.
        Throws:
        java.io.IOException - if fail to delete.
      • commitBlock

        public abstract void commitBlock()
                                  throws java.io.IOException
        Notifies that all writes are finished for the block corresponding to this metadata.
        Throws:
        java.io.IOException - if fail to commit.
      • setCommitted

        protected final void setCommitted​(boolean committed)
        Set the commit value.
        Parameters:
        committed - whether this block is committed or not.
      • isCommitted

        public final boolean isCommitted()
        Returns:
        whether this file is committed or not.