public final class BlockData
extends java.lang.Object
| Constructor | Description |
|---|---|
BlockData(long fileSize,
int blockSize) |
Constructs an instance of
BlockData. |
| Modifier and Type | Method | Description |
|---|---|---|
int |
getBlockNumber(long offset) |
Gets the id of the block that contains the given absolute offset.
|
int |
getBlockSize() |
Gets the size of each block.
|
long |
getFileSize() |
Gets the size of the associated file.
|
int |
getNumBlocks() |
Gets the number of blocks in the associated file.
|
int |
getRelativeOffset(int blockNumber,
long offset) |
Gets the relative offset corresponding to the given block and the absolute offset.
|
int |
getSize(int blockNumber) |
Gets the size of the given block.
|
long |
getStartOffset(int blockNumber) |
Gets the start offset of the given block.
|
org.apache.hadoop.fs.impl.prefetch.BlockData.State |
getState(int blockNumber) |
Gets the state of the given block.
|
java.lang.String |
getStateString() |
|
boolean |
isLastBlock(int blockNumber) |
Indicates whether the given block is the last block in the associated file.
|
boolean |
isValidOffset(long offset) |
Indicates whether the given absolute offset is valid.
|
void |
setState(int blockNumber,
org.apache.hadoop.fs.impl.prefetch.BlockData.State blockState) |
Sets the state of the given block to the given value.
|
public BlockData(long fileSize,
int blockSize)
BlockData.fileSize - the size of a file.blockSize - the file is divided into blocks of this size.java.lang.IllegalArgumentException - if fileSize is negative.java.lang.IllegalArgumentException - if blockSize is negative.java.lang.IllegalArgumentException - if blockSize is zero or negative.public int getBlockSize()
public long getFileSize()
public int getNumBlocks()
public boolean isLastBlock(int blockNumber)
blockNumber - the id of the desired block.java.lang.IllegalArgumentException - if blockNumber is invalid.public int getBlockNumber(long offset)
offset - the absolute offset to check.java.lang.IllegalArgumentException - if offset is invalid.public int getSize(int blockNumber)
blockNumber - the id of the desired block.public boolean isValidOffset(long offset)
offset - absolute offset in the file..public long getStartOffset(int blockNumber)
blockNumber - the id of the given block.java.lang.IllegalArgumentException - if blockNumber is invalid.public int getRelativeOffset(int blockNumber,
long offset)
blockNumber - the id of the given block.offset - absolute offset in the file.java.lang.IllegalArgumentException - if either blockNumber or offset is invalid.public org.apache.hadoop.fs.impl.prefetch.BlockData.State getState(int blockNumber)
blockNumber - the id of the given block.java.lang.IllegalArgumentException - if blockNumber is invalid.public void setState(int blockNumber,
org.apache.hadoop.fs.impl.prefetch.BlockData.State blockState)
blockNumber - the id of the given block.blockState - the target state.java.lang.IllegalArgumentException - if blockNumber is invalid.public java.lang.String getStateString()
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.