use of io.trino.spi.block.IntArrayBlock in project trino by trinodb.
the class TestSimplePagesHashStrategy method testHashRowWithMapType.
@Test
public void testHashRowWithMapType() {
MapType mapType = new MapType(INTEGER, INTEGER, new TypeOperators());
Block block = mapType.createBlockFromKeyValue(Optional.empty(), new int[] { 0, 1 }, new IntArrayBlock(1, Optional.empty(), new int[] { 1234 }), new IntArrayBlock(1, Optional.empty(), new int[] { 5678 }));
SimplePagesHashStrategy strategy = createSimplePagesHashStrategy(mapType, ImmutableList.of(block));
Page page = new Page(block);
// This works because MapType is comparable.
assertEquals(strategy.hashRow(0, page), 451258269207618863L);
}
use of io.trino.spi.block.IntArrayBlock in project trino by trinodb.
the class TestDictionaryBlock method testNestedDictionarySizes.
@Test
public void testNestedDictionarySizes() {
// fixed width block
Block fixedWidthBlock = new IntArrayBlock(100, Optional.empty(), IntStream.range(0, 100).toArray());
assertDictionarySizeMethods(fixedWidthBlock);
assertDictionarySizeMethods(new DictionaryBlock(fixedWidthBlock, IntStream.range(0, 50).toArray()));
assertDictionarySizeMethods(new DictionaryBlock(new DictionaryBlock(fixedWidthBlock, IntStream.range(0, 50).toArray()), IntStream.range(0, 10).toArray()));
// variable width block
Block variableWidthBlock = createSlicesBlock(createExpectedValues(100));
assertDictionarySizeMethods(variableWidthBlock);
assertDictionarySizeMethods(new DictionaryBlock(variableWidthBlock, IntStream.range(0, 50).toArray()));
assertDictionarySizeMethods(new DictionaryBlock(new DictionaryBlock(variableWidthBlock, IntStream.range(0, 50).toArray()), IntStream.range(0, 10).toArray()));
}
use of io.trino.spi.block.IntArrayBlock in project trino by trinodb.
the class TestSimplePagesHashStrategy method testCompareSortChannelPositionsWithMapType.
@Test
public void testCompareSortChannelPositionsWithMapType() {
MapType mapType = new MapType(INTEGER, INTEGER, new TypeOperators());
Block block = mapType.createBlockFromKeyValue(Optional.empty(), new int[] { 0, 1 }, new IntArrayBlock(1, Optional.empty(), new int[] { 1234 }), new IntArrayBlock(1, Optional.empty(), new int[] { 5678 }));
SimplePagesHashStrategy strategy = createSimplePagesHashStrategy(mapType, ImmutableList.of(block));
// This fails because MapType is not orderable.
assertThatThrownBy(() -> strategy.compareSortChannelPositions(0, 0, 0, 0)).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("type is not orderable");
}
use of io.trino.spi.block.IntArrayBlock in project trino by trinodb.
the class TestSimplePagesHashStrategy method testRowEqualsRowWithIntegerType.
@Test
public void testRowEqualsRowWithIntegerType() {
SimplePagesHashStrategy strategy = createSimplePagesHashStrategy(INTEGER, ImmutableList.of());
Page leftPage = new Page(new IntArrayBlock(1, Optional.empty(), new int[] { 1234 }));
Page rightPage1 = new Page(new IntArrayBlock(1, Optional.empty(), new int[] { 1234 }));
Page rightPage2 = new Page(new IntArrayBlock(1, Optional.empty(), new int[] { 5678 }));
// This works because IntegerType is comparable.
assertTrue(strategy.rowEqualsRow(0, leftPage, 0, rightPage1));
assertFalse(strategy.rowEqualsRow(0, leftPage, 0, rightPage2));
}
use of io.trino.spi.block.IntArrayBlock in project trino by trinodb.
the class TestSimplePagesHashStrategy method testRowEqualsRowWithMapType.
@Test
public void testRowEqualsRowWithMapType() {
MapType mapType = new MapType(INTEGER, INTEGER, new TypeOperators());
SimplePagesHashStrategy strategy = createSimplePagesHashStrategy(mapType, ImmutableList.of());
Page leftPage = new Page(mapType.createBlockFromKeyValue(Optional.empty(), new int[] { 0, 1 }, new IntArrayBlock(1, Optional.empty(), new int[] { 1234 }), new IntArrayBlock(1, Optional.empty(), new int[] { 5678 })));
Page rightPage1 = new Page(mapType.createBlockFromKeyValue(Optional.empty(), new int[] { 0, 1 }, new IntArrayBlock(1, Optional.empty(), new int[] { 1234 }), new IntArrayBlock(1, Optional.empty(), new int[] { 5678 })));
Page rightPage2 = new Page(mapType.createBlockFromKeyValue(Optional.empty(), new int[] { 0, 1 }, new IntArrayBlock(1, Optional.empty(), new int[] { 1234 }), new IntArrayBlock(1, Optional.empty(), new int[] { 1234 })));
// This works because MapType is comparable.
assertTrue(strategy.rowEqualsRow(0, leftPage, 0, rightPage1));
assertFalse(strategy.rowEqualsRow(0, leftPage, 0, rightPage2));
}
Aggregations