Skip to content

Commit

Permalink
Support RLE DictionaryBlock.dictionary in UnnestingPositionsAppender
Browse files Browse the repository at this point in the history
DictionaryBlock.dictionary will not be RLE in normal circumstances,
but since there is no precondition in the constructor, we cannot
rely on this to be always the case
  • Loading branch information
lukasz-stec authored and raunaqmorarka committed Jun 13, 2023
1 parent 858af73 commit 8f39e4c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void append(IntArrayList positions, Block source)
{
// RleAwarePositionsAppender should be used with UnnestingPositionsAppender that makes sure
// append is called only with flat block
checkArgument(!(source instanceof RunLengthEncodedBlock), "Append should be called with flat block but got %s", source);
checkArgument(!(source instanceof RunLengthEncodedBlock), "Append should be called with non-RLE block but got %s", source);
switchToFlat();
delegate.append(positions, source);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ public long getSizeInBytes()
private void appendDictionary(IntArrayList positions, DictionaryBlock source)
{
Block dictionary = source.getDictionary();
if (dictionary instanceof RunLengthEncodedBlock rleDictionary) {
appendRle(rleDictionary.getValue(), positions.size());
return;
}

IntArrayList dictionaryPositions = getDictionaryPositions(positions, source);
if (dictionaryBlockBuilder.canAppend(dictionary)) {
dictionaryBlockBuilder.append(dictionaryPositions, dictionary);
Expand Down

0 comments on commit 8f39e4c

Please sign in to comment.