Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/trino-spi/src/main/java/io/trino/spi/Page.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ private static List<DictionaryBlock> compactRelatedBlocks(List<DictionaryBlock>

try {
Block compactDictionary = dictionaryBlock.getDictionary().copyPositions(dictionaryPositionsToCopy, 0, numberOfIndexes);
outputDictionaryBlocks.add(new DictionaryBlock(positionCount, compactDictionary, newIds, true, newDictionaryId));
outputDictionaryBlocks.add(new DictionaryBlock(positionCount, compactDictionary, newIds, !(compactDictionary instanceof DictionaryBlock), newDictionaryId));
}
catch (UnsupportedOperationException e) {
// ignore if copy positions is not supported for the dictionary
Expand Down Expand Up @@ -301,7 +301,7 @@ public Page getLoadedPage()

public Page getLoadedPage(int column)
{
return wrapBlocksWithoutCopy(positionCount, new Block[]{this.blocks[column].getLoadedBlock()});
return wrapBlocksWithoutCopy(positionCount, new Block[] {this.blocks[column].getLoadedBlock()});
}

public Page getLoadedPage(int... columns)
Expand Down
15 changes: 15 additions & 0 deletions core/trino-spi/src/test/java/io/trino/spi/TestPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import static io.trino.spi.type.VarbinaryType.VARBINARY;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertTrue;

Expand Down Expand Up @@ -115,6 +116,20 @@ public void testCompactDictionaryBlocks()
assertEquals(((DictionaryBlock) page.getBlock(0)).getDictionarySourceId(), ((DictionaryBlock) page.getBlock(2)).getDictionarySourceId());
}

@Test
public void testCompactNestedDictionary()
{
Slice[] expectedValues = createExpectedValues(10);
Block valuesBlock = createSlicesBlock(expectedValues);
DictionaryBlock nestedDictionary = new DictionaryBlock(valuesBlock, new int[] {0, 1, 2, 2, 4, 5});
DictionaryBlock dictionary = new DictionaryBlock(nestedDictionary, new int[] {2, 3, 2, 0});

Page page = new Page(dictionary);
page.compact();
// Page#compact does not unnest nested dictionaries
assertFalse(((DictionaryBlock) page.getBlock(0)).isCompact());
}

@Test
public void testGetPositions()
{
Expand Down