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
SerializedPartition s in a specific key range. |
Optional<List<Long>> |
putPartitions(Iterable<NonSerializedPartition<K>> partitions)
Writes
NonSerializedPartition s to this block. |
List<Long> |
putSerializedPartitions(Iterable<SerializedPartition<K>> partitions)
Writes
SerializedPartition s 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
NonSerializedPartition
s to this block.putPartitions
in interface Block<K extends Serializable>
partitions
- the NonSerializedPartition
s to write.IOException
- if fail to write.public List<Long> putSerializedPartitions(Iterable<SerializedPartition<K>> partitions) throws IOException
SerializedPartition
s to this block.putSerializedPartitions
in interface Block<K extends Serializable>
partitions
- the SerializedPartition
s 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.NonSerializedPartition
s.IOException
- if failed to retrieve.public Iterable<SerializedPartition<K>> getSerializedPartitions(KeyRange keyRange) throws IOException
SerializedPartition
s 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.SerializedPartition
s.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.