@Override public Block[] getSequenceBlocks(int start, int length) { return new Block[] {createDoubleSequenceBlock(start, start + length), createDoubleSequenceBlock(start + 5, start + 5 + length)}; }
@Override public Block[] getSequenceBlocks(int start, int length) { return new Block[] {createDoubleSequenceBlock(start, start + length), createDoubleSequenceBlock(start + 2, start + 2 + length)}; }
@Override public Block[] getSequenceBlocks(int start, int length) { return new Block[] {createDoubleSequenceBlock(start, start + length), createDoubleSequenceBlock(start + 2, start + 2 + length)}; }
@Override public Block[] getSequenceBlocks(int start, int length) { return new Block[] {createDoubleSequenceBlock(start, start + length), createDoubleSequenceBlock(start + 2, start + 2 + length)}; }
@Override public Block[] getSequenceBlocks(int start, int length) { return new Block[] {createDoubleSequenceBlock(start, start + length), createDoubleSequenceBlock(start + 5, start + 5 + length)}; }
@Override public Block[] getSequenceBlocks(int start, int length) { return new Block[] {createDoubleSequenceBlock(start, start + length), createLongRepeatBlock(2, length)}; }
private static List<Page> createPages(int pageCount, int channelCount, Type type) { int positionCount = PageBuilderStatus.DEFAULT_MAX_PAGE_SIZE_IN_BYTES / (channelCount * 8); List<Page> pages = new ArrayList<>(pageCount); for (int numPage = 0; numPage < pageCount; numPage++) { Block[] blocks = new Block[channelCount]; for (int numChannel = 0; numChannel < channelCount; numChannel++) { if (type.equals(BIGINT)) { blocks[numChannel] = BlockAssertions.createLongSequenceBlock(0, positionCount); } else if (type.equals(VARCHAR)) { blocks[numChannel] = BlockAssertions.createStringSequenceBlock(0, positionCount); } else if (type.equals(DOUBLE)) { blocks[numChannel] = BlockAssertions.createDoubleSequenceBlock(0, positionCount); } else if (type.equals(BOOLEAN)) { blocks[numChannel] = BlockAssertions.createBooleanSequenceBlock(0, positionCount); } else { throw new IllegalArgumentException("Unsupported type: " + type); } } pages.add(new Page(blocks)); } return pages; }
@Test public void testContains() { Block valuesBlock = BlockAssertions.createDoubleSequenceBlock(0, 10); Block hashBlock = TypeUtils.getHashBlock(ImmutableList.of(DOUBLE), valuesBlock); GroupByHash groupByHash = createGroupByHash(TEST_SESSION, ImmutableList.of(DOUBLE), new int[] {0}, Optional.of(1), 100, JOIN_COMPILER); groupByHash.getGroupIds(new Page(valuesBlock, hashBlock)).process(); Block testBlock = BlockAssertions.createDoublesBlock((double) 3); Block testHashBlock = TypeUtils.getHashBlock(ImmutableList.of(DOUBLE), testBlock); assertTrue(groupByHash.contains(0, new Page(testBlock, testHashBlock), CONTAINS_CHANNELS)); testBlock = BlockAssertions.createDoublesBlock(11.0); testHashBlock = TypeUtils.getHashBlock(ImmutableList.of(DOUBLE), testBlock); assertFalse(groupByHash.contains(0, new Page(testBlock, testHashBlock), CONTAINS_CHANNELS)); }
@Test public void testContainsMultipleColumns() { Block valuesBlock = BlockAssertions.createDoubleSequenceBlock(0, 10); Block stringValuesBlock = BlockAssertions.createStringSequenceBlock(0, 10); Block hashBlock = TypeUtils.getHashBlock(ImmutableList.of(DOUBLE, VARCHAR), valuesBlock, stringValuesBlock); int[] hashChannels = {0, 1}; GroupByHash groupByHash = createGroupByHash(TEST_SESSION, ImmutableList.of(DOUBLE, VARCHAR), hashChannels, Optional.of(2), 100, JOIN_COMPILER); groupByHash.getGroupIds(new Page(valuesBlock, stringValuesBlock, hashBlock)).process(); Block testValuesBlock = BlockAssertions.createDoublesBlock((double) 3); Block testStringValuesBlock = BlockAssertions.createStringsBlock("3"); Block testHashBlock = TypeUtils.getHashBlock(ImmutableList.of(DOUBLE, VARCHAR), testValuesBlock, testStringValuesBlock); assertTrue(groupByHash.contains(0, new Page(testValuesBlock, testStringValuesBlock, testHashBlock), hashChannels)); }
blocks[i] = BlockAssertions.createDoubleSequenceBlock(initialValue, initialValue + length);
BlockAssertions.createLongSequenceBlock(15, 25)); List<Block> doubleChannel = ImmutableList.of( BlockAssertions.createDoubleSequenceBlock(10, 20), BlockAssertions.createDoubleSequenceBlock(20, 30), BlockAssertions.createDoubleSequenceBlock(15, 25)); List<Block> booleanChannel = ImmutableList.of( BlockAssertions.createBooleanSequenceBlock(10, 20),
DOUBLE_APPROXIMATE_PERCENTILE_WEIGHTED_AGGREGATION_WITH_ACCURACY, 9900.0, createDoubleSequenceBlock(0, 10000), createLongRepeatBlock(1, 10000), createRLEBlock(0.99, 10000),
0.01, 1.0); testAggregationDouble( createDoubleSequenceBlock(-1000, 1000), createRLEBlock(1, 2000), 0.01,
@Override public Block[] getSequenceBlocks(int start, int length) { return new Block[]{createDoubleSequenceBlock(start, start + length), createDoubleSequenceBlock(start + 5, start + 5 + length)}; }
@Override public Block[] getSequenceBlocks(int start, int length) { return new Block[] {createDoubleSequenceBlock(start, start + length), createDoubleSequenceBlock(start + 2, start + 2 + length)}; }
@Override public Block[] getSequenceBlocks(int start, int length) { return new Block[] {createDoubleSequenceBlock(start, start + length), createDoubleSequenceBlock(start + 2, start + 2 + length)}; }
@Override public Block[] getSequenceBlocks(int start, int length) { return new Block[] {createDoubleSequenceBlock(start, start + length), createDoubleSequenceBlock(start + 2, start + 2 + length)}; }
@Override public Block[] getSequenceBlocks(int start, int length) { return new Block[]{createDoubleSequenceBlock(start, start + length), createDoubleSequenceBlock(start + 5, start + 5 + length)}; }
@Override public Block[] getSequenceBlocks(int start, int length) { return new Block[] {createDoubleSequenceBlock(start, start + length), createLongRepeatBlock(2, length)}; }
@Test public void testContainsMultipleColumns() throws Exception { Block valuesBlock = BlockAssertions.createDoubleSequenceBlock(0, 10); Block stringValuesBlock = BlockAssertions.createStringSequenceBlock(0, 10); Block hashBlock = TypeUtils.getHashBlock(ImmutableList.of(DOUBLE, VARCHAR), valuesBlock, stringValuesBlock); int[] hashChannels = { 0, 1 }; GroupByHash groupByHash = createGroupByHash(TEST_SESSION, ImmutableList.of(DOUBLE, VARCHAR), hashChannels, Optional.<Integer>empty(), Optional.of(2), 100); groupByHash.getGroupIds(new Page(valuesBlock, stringValuesBlock, hashBlock)); Block testValuesBlock = BlockAssertions.createDoublesBlock((double) 3); Block testStringValuesBlock = BlockAssertions.createStringsBlock("3"); Block testHashBlock = TypeUtils.getHashBlock(ImmutableList.of(DOUBLE, VARCHAR), testValuesBlock, testStringValuesBlock); assertTrue(groupByHash.contains(0, new Page(testValuesBlock, testStringValuesBlock, testHashBlock), hashChannels)); }