Class FileMetadata<K extends Serializable>

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

    public abstract class FileMetadata<K extends Serializable>
    extends 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​(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 IOException
        Writes the metadata for a partition.
        Parameters:
        key - the key of the partition.
        partitionSize - the size of the partition.
        Throws:
        IOException - if fail to append the partition metadata.
      • getPartitionMetadataList

        public final 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 IOException
        Deletes the metadata.
        Throws:
        IOException - if fail to delete.
      • commitBlock

        public abstract void commitBlock()
                                  throws IOException
        Notifies that all writes are finished for the block corresponding to this metadata.
        Throws:
        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.