Skip to content

Commit

Permalink
Rename getPosition() to getPos()
Browse files Browse the repository at this point in the history
  • Loading branch information
yihua committed Jan 30, 2024
1 parent 9697ada commit 806bd78
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public HoodieLogFile getLogFile() {
// for max of Integer size
private HoodieLogBlock readBlock() throws IOException {
int blockSize;
long blockStartPos = inputStream.getPosition();
long blockStartPos = inputStream.getPos();
try {
// 1 Read the total size of the block
blockSize = (int) inputStream.readLong();
Expand Down Expand Up @@ -179,7 +179,7 @@ private HoodieLogBlock readBlock() throws IOException {
nextBlockVersion.getVersion() != HoodieLogFormatVersion.DEFAULT_VERSION ? (int) inputStream.readLong() : blockSize;

// 6. Read the content or skip content based on IO vs Memory trade-off by client
long contentPosition = inputStream.getPosition();
long contentPosition = inputStream.getPos();
boolean shouldReadLazily = readBlockLazily && nextBlockVersion.getVersion() != HoodieLogFormatVersion.DEFAULT_VERSION;
Option<byte[]> content = HoodieLogBlock.tryReadContent(inputStream, contentLength, shouldReadLazily);

Expand All @@ -194,7 +194,7 @@ private HoodieLogBlock readBlock() throws IOException {
}

// 9. Read the log block end position in the log file
long blockEndPos = inputStream.getPosition();
long blockEndPos = inputStream.getPos();

HoodieLogBlock.HoodieLogBlockContentLocation logBlockContentLoc =
new HoodieLogBlock.HoodieLogBlockContentLocation(hadoopConf, logFile, contentPosition, contentLength, blockEndPos);
Expand Down Expand Up @@ -268,7 +268,7 @@ private HoodieLogBlock createCorruptBlock(long blockStartPos) throws IOException
inputStream.seek(blockStartPos);
LOG.info("Next available block in " + logFile + " starts at " + nextBlockOffset);
int corruptedBlockSize = (int) (nextBlockOffset - blockStartPos);
long contentPosition = inputStream.getPosition();
long contentPosition = inputStream.getPos();
Option<byte[]> corruptedBytes = HoodieLogBlock.tryReadContent(inputStream, corruptedBlockSize, readBlockLazily);
HoodieLogBlock.HoodieLogBlockContentLocation logBlockContentLoc =
new HoodieLogBlock.HoodieLogBlockContentLocation(hadoopConf, logFile, contentPosition, corruptedBlockSize, nextBlockOffset);
Expand All @@ -280,7 +280,7 @@ private boolean isBlockCorrupted(int blocksize) throws IOException {
// skip block corrupt check if writes are transactional. see https://issues.apache.org/jira/browse/HUDI-2118
return false;
}
long currentPos = inputStream.getPosition();
long currentPos = inputStream.getPos();
long blockSizeFromFooter;

try {
Expand Down Expand Up @@ -327,7 +327,7 @@ private long scanForNextAvailableBlockOffset() throws IOException {
byte[] dataBuf = new byte[BLOCK_SCAN_READ_BUFFER_SIZE];
boolean eof = false;
while (true) {
long currentPos = inputStream.getPosition();
long currentPos = inputStream.getPos();
try {
Arrays.fill(dataBuf, (byte) 0);
inputStream.readFully(dataBuf, 0, dataBuf.length);
Expand All @@ -339,7 +339,7 @@ private long scanForNextAvailableBlockOffset() throws IOException {
return currentPos + pos;
}
if (eof) {
return inputStream.getPosition();
return inputStream.getPos();
}
inputStream.seek(currentPos + dataBuf.length - HoodieLogFormat.MAGIC.length);
}
Expand Down Expand Up @@ -436,7 +436,7 @@ public HoodieLogBlock prev() throws IOException {
throw new HoodieNotSupportedException("Reverse log reader has not been enabled");
}
long blockSize = inputStream.readLong();
long blockEndPos = inputStream.getPosition();
long blockEndPos = inputStream.getPos();
// blocksize should read everything about a block including the length as well
try {
inputStream.seek(reverseLogFilePosition - blockSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public static Option<byte[]> tryReadContent(SeekableDataInputStream inputStream,
throws IOException {
if (readLazily) {
// Seek to the end of the content block
inputStream.seek(inputStream.getPosition() + contentLength);
inputStream.seek(inputStream.getPos() + contentLength);
return Option.empty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public HadoopSeekableDataInputStream(FSDataInputStream stream) {
}

@Override
public long getPosition() throws IOException {
public long getPos() throws IOException {
return stream.getPos();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public SeekableDataInputStream(InputStream in) {
/**
* @return current position of the stream. The next read() will be from that location.
*/
public abstract long getPosition() throws IOException;
public abstract long getPos() throws IOException;

/**
* Seeks to a position within the stream.
Expand Down

0 comments on commit 806bd78

Please sign in to comment.