K - the key type of its partitions.public final class FileBlock<K extends Serializable> extends Object implements Block<K>
| Constructor and Description |
|---|
FileBlock(Coder coder,
String filePath,
FileMetadata<K> metadata)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
List<FileArea> |
asFileAreas(KeyRange keyRange)
|
void |
commit()
Commits this block to prevent further write.
|
void |
deleteFile()
Deletes the file that contains this block data.
|
Iterable<NonSerializedPartition<K>> |
getPartitions(KeyRange keyRange)
Retrieves the partitions of this block from the file in a specific key range and deserializes it.
|
Iterable<SerializedPartition<K>> |
getSerializedPartitions(KeyRange keyRange)
Retrieves the
SerializedPartitions in a specific key range. |
Optional<List<Long>> |
putPartitions(Iterable<NonSerializedPartition<K>> partitions)
Writes
NonSerializedPartitions to this block. |
List<Long> |
putSerializedPartitions(Iterable<SerializedPartition<K>> partitions)
Writes
SerializedPartitions to this block. |
public FileBlock(Coder coder, String filePath, FileMetadata<K> metadata)
coder - the Coder.filePath - the path of the file that this block will be stored.metadata - the metadata for this block.public Optional<List<Long>> putPartitions(Iterable<NonSerializedPartition<K>> partitions) throws IOException
NonSerializedPartitions to this block.putPartitions in interface Block<K extends Serializable>partitions - the NonSerializedPartitions to write.IOException - if fail to write.public List<Long> putSerializedPartitions(Iterable<SerializedPartition<K>> partitions) throws IOException
SerializedPartitions to this block.putSerializedPartitions in interface Block<K extends Serializable>partitions - the SerializedPartitions to store.IOException - if fail to store.public Iterable<NonSerializedPartition<K>> getPartitions(KeyRange keyRange) throws IOException
getPartitions in interface Block<K extends Serializable>keyRange - the key range.NonSerializedPartitions.IOException - if failed to retrieve.public Iterable<SerializedPartition<K>> getSerializedPartitions(KeyRange keyRange) throws IOException
SerializedPartitions in a specific key range.
Invariant: This should not be invoked before this block is committed.getSerializedPartitions in interface Block<K extends Serializable>keyRange - the key range to retrieve.SerializedPartitions.IOException - if failed to retrieve.public List<FileArea> asFileAreas(KeyRange keyRange) throws IOException
keyRange - the key rangeIOException - if failed to open a file channelpublic void deleteFile()
throws IOException
IOException - if failed to delete.public void commit()
throws IOException
commit in interface Block<K extends Serializable>IOException - if failed to commit.Copyright © 2018. All rights reserved.