Skip to content

Commit

Permalink
Added comments to explain offset field better
Browse files Browse the repository at this point in the history
  • Loading branch information
malhotrashivam committed Nov 20, 2023
1 parent 8fefcc1 commit e489ee3
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,19 @@ public class ColumnPageReaderImpl implements ColumnPageReader {
private final Path filePath;
private final List<Type> fieldTypes;

/**
* Stores the offset from where the next byte should be read. Can be the offset of page header if
* {@link #pageHeader} is {@code null}, else will be the offset of data.
*/
private long offset;
private PageHeader pageHeader;
private int numValues;
private int rowCount = -1;

/**
* @param offset The offset for page header if supplied {@code pageHeader} is {@code null}. Else, the offset of data
* in the page.
*/
ColumnPageReaderImpl(SeekableChannelsProvider channelsProvider,
CompressorAdapter compressorAdapter,
Supplier<Dictionary> dictionarySupplier,
Expand Down Expand Up @@ -108,6 +116,10 @@ public IntBuffer readKeyValues(IntBuffer keyDest, int nullPlaceholder) throws IO
}
}

/**
* If {@link #pageHeader} is {@code null}, read it from the {@link #offset} and increment the {@link #offset} by the
* length of page header. Also, read the number of values in the page from the header.
*/
private synchronized void ensurePageHeader(SeekableByteChannel file) throws IOException {
if (pageHeader == null) {
offset = file.position();
Expand Down

0 comments on commit e489ee3

Please sign in to comment.