Skip to content

Commit

Permalink
Improve DictionaryBlock#getLogicalSizeInBytes
Browse files Browse the repository at this point in the history
When fixedSizeInBytesPerPosition is known, it can be used to compute
logical size of DictionaryBlock cheaply.
Logical size for page is computed frequently by orc/parquet writers.
  • Loading branch information
raunaqmorarka committed Jul 18, 2022
1 parent b3d38c3 commit c7d3c75
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ public long getLogicalSizeInBytes()
return logicalSizeInBytes;
}

OptionalInt dictionarySizePerPosition = dictionary.fixedSizeInBytesPerPosition();
if (dictionarySizePerPosition.isPresent()) {
logicalSizeInBytes = dictionarySizePerPosition.getAsInt() * (long) getPositionCount();
return logicalSizeInBytes;
}

// Calculation of logical size can be performed as part of calculateCompactSize() with minor modifications.
// Keeping this calculation separate as this is a little more expensive and may not be called as often.
long sizeInBytes = 0;
Expand Down

0 comments on commit c7d3c75

Please sign in to comment.