Search in sources :

Example 11 with StateSet

use of io.prestosql.spi.statestore.StateSet in project hetu-core by openlookeng.

the class TestDynamicFilterSourceOperator method testCollectEmptyBuildSide.

@Test
public void testCollectEmptyBuildSide() {
    String filterId = "empty_build_side";
    OperatorFactory operatorFactory = createOperatorFactory(LOCAL, HASHSET, 1, channel(0, BIGINT, filterId));
    verifyPassthrough(createOperator((DynamicFilterSourceOperatorFactory) operatorFactory), ImmutableList.of(BIGINT));
    operatorFactory.noMoreOperators();
    String key = DynamicFilterUtils.createKey(PARTIALPREFIX, filterId, TEST_SESSION.getQueryId().toString());
    StateSet states = ((StateSet) stateStoreProvider.getStateStore().getStateCollection(key));
    for (Object bfSerialized : states.getAll()) {
        // should be empty
        assertEquals((Set) bfSerialized, new HashSet());
    }
}
Also used : DynamicFilterSourceOperatorFactory(io.prestosql.operator.DynamicFilterSourceOperator.DynamicFilterSourceOperatorFactory) DynamicFilterSourceOperatorFactory(io.prestosql.operator.DynamicFilterSourceOperator.DynamicFilterSourceOperatorFactory) StateSet(io.prestosql.spi.statestore.StateSet) HashSet(java.util.HashSet) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest) BeforeTest(org.testng.annotations.BeforeTest)

Example 12 with StateSet

use of io.prestosql.spi.statestore.StateSet in project hetu-core by openlookeng.

the class TestDynamicFilterSourceOperator method testCollectWithNulls.

@Test
public void testCollectWithNulls() {
    Block blockWithNulls = INTEGER.createFixedSizeBlockBuilder(0).writeInt(3).appendNull().writeInt(4).build();
    String filterId = "with_nulls";
    OperatorFactory operatorFactory = createOperatorFactory(LOCAL, HASHSET, 1, channel(0, INTEGER, filterId));
    verifyPassthrough(createOperator((DynamicFilterSourceOperatorFactory) operatorFactory), ImmutableList.of(INTEGER), new Page(createLongsBlock(1, 2, 3)), new Page(blockWithNulls), new Page(createLongsBlock(4, 5)));
    operatorFactory.noMoreOperators();
    String key = DynamicFilterUtils.createKey(PARTIALPREFIX, filterId, TEST_SESSION.getQueryId().toString());
    Set<Long> set = new HashSet<>(Arrays.asList(1L, 2L, 3L, 4L, 5L));
    StateSet states = ((StateSet) stateStoreProvider.getStateStore().getStateCollection(key));
    for (Object bfSerialized : states.getAll()) {
        assertEquals((Set) bfSerialized, set);
    }
}
Also used : DynamicFilterSourceOperatorFactory(io.prestosql.operator.DynamicFilterSourceOperator.DynamicFilterSourceOperatorFactory) BlockAssertions.createSlicesBlock(io.prestosql.block.BlockAssertions.createSlicesBlock) BlockAssertions.createStringsBlock(io.prestosql.block.BlockAssertions.createStringsBlock) BlockAssertions.createLongRepeatBlock(io.prestosql.block.BlockAssertions.createLongRepeatBlock) Block(io.prestosql.spi.block.Block) BlockAssertions.createBooleansBlock(io.prestosql.block.BlockAssertions.createBooleansBlock) BlockAssertions.createDoublesBlock(io.prestosql.block.BlockAssertions.createDoublesBlock) BlockAssertions.createLongsBlock(io.prestosql.block.BlockAssertions.createLongsBlock) DynamicFilterSourceOperatorFactory(io.prestosql.operator.DynamicFilterSourceOperator.DynamicFilterSourceOperatorFactory) SequencePageBuilder.createSequencePage(io.prestosql.SequencePageBuilder.createSequencePage) Page(io.prestosql.spi.Page) StateSet(io.prestosql.spi.statestore.StateSet) HashSet(java.util.HashSet) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest) BeforeTest(org.testng.annotations.BeforeTest)

Example 13 with StateSet

use of io.prestosql.spi.statestore.StateSet in project hetu-core by openlookeng.

the class TestDynamicFilterSourceOperator method testGlobalDynamicFilterSourceOperatorBloomFilterSlice.

@Test
public void testGlobalDynamicFilterSourceOperatorBloomFilterSlice() {
    String filterId = "909";
    DynamicFilterSourceOperatorFactory operatorFactory = createOperatorFactory(GLOBAL, BLOOM_FILTER, 1, channel(0, VARCHAR, filterId));
    // will finish before noMoreOperators()
    DynamicFilterSourceOperator op1 = createOperator(operatorFactory);
    verifyPassthrough(op1, ImmutableList.of(VARCHAR), new Page(createSlicesBlock(utf8Slice("test1"))), new Page(createSlicesBlock(utf8Slice("test2"))), new Page(createSlicesBlock(utf8Slice("test3"))));
    String key = DynamicFilterUtils.createKey(PARTIALPREFIX, filterId, TEST_SESSION.getQueryId().toString());
    StateSet states = ((StateSet) stateStoreProvider.getStateStore().getStateCollection(key));
    for (Object bfSerialized : states.getAll()) {
        BloomFilterDynamicFilter bfdf = new BloomFilterDynamicFilter(filterId, null, (byte[]) bfSerialized, GLOBAL);
        Slice slice = Slices.utf8Slice("test1");
        assertEquals(bfdf.getSize(), 3);
        assertTrue(bfdf.contains(slice));
    }
    assertEquals(stateStoreProvider.getStateStore().getStateCollection(DynamicFilterUtils.createKey(TASKSPREFIX, filterId, TEST_SESSION.getQueryId().toString())).size(), 1);
}
Also used : Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) Slice(io.airlift.slice.Slice) DynamicFilterSourceOperatorFactory(io.prestosql.operator.DynamicFilterSourceOperator.DynamicFilterSourceOperatorFactory) SequencePageBuilder.createSequencePage(io.prestosql.SequencePageBuilder.createSequencePage) Page(io.prestosql.spi.Page) BloomFilterDynamicFilter(io.prestosql.spi.dynamicfilter.BloomFilterDynamicFilter) StateSet(io.prestosql.spi.statestore.StateSet) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest) BeforeTest(org.testng.annotations.BeforeTest)

Example 14 with StateSet

use of io.prestosql.spi.statestore.StateSet in project hetu-core by openlookeng.

the class TestDynamicFilterSourceOperator method testGlobalDynamicFilterSourceOperatorHashSet.

@Test
public void testGlobalDynamicFilterSourceOperatorHashSet() {
    String filterId = "22";
    DynamicFilterSourceOperatorFactory operatorFactory = createOperatorFactory(GLOBAL, HASHSET, 1, channel(0, BIGINT, filterId));
    // will finish before noMoreOperators()
    DynamicFilterSourceOperator op1 = createOperator(operatorFactory);
    verifyPassthrough(op1, ImmutableList.of(BIGINT), new Page(createLongsBlock(1, 2)), new Page(createLongsBlock(12, 21)), new Page(createLongsBlock(13, 22)), new Page(createLongsBlock(3, 5)));
    String key = DynamicFilterUtils.createKey(PARTIALPREFIX, filterId, TEST_SESSION.getQueryId().toString());
    StateSet states = ((StateSet) stateStoreProvider.getStateStore().getStateCollection(key));
    for (Object bfSerialized : states.getAll()) {
        HashSetDynamicFilter bfdf = new HashSetDynamicFilter(filterId, null, (Set) bfSerialized, GLOBAL);
        assertTrue(bfdf.contains(22L));
        assertEquals(bfdf.getSize(), 8);
    }
    assertEquals(stateStoreProvider.getStateStore().getStateCollection(DynamicFilterUtils.createKey(TASKSPREFIX, filterId, TEST_SESSION.getQueryId().toString())).size(), 1);
}
Also used : DynamicFilterSourceOperatorFactory(io.prestosql.operator.DynamicFilterSourceOperator.DynamicFilterSourceOperatorFactory) SequencePageBuilder.createSequencePage(io.prestosql.SequencePageBuilder.createSequencePage) Page(io.prestosql.spi.Page) StateSet(io.prestosql.spi.statestore.StateSet) HashSetDynamicFilter(io.prestosql.spi.dynamicfilter.HashSetDynamicFilter) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest) BeforeTest(org.testng.annotations.BeforeTest)

Example 15 with StateSet

use of io.prestosql.spi.statestore.StateSet in project hetu-core by openlookeng.

the class TestDynamicFilterSourceOperator method testCollectOnlyLastColumn.

@Test
public void testCollectOnlyLastColumn() {
    String filterId = "last_column";
    OperatorFactory operatorFactory = createOperatorFactory(LOCAL, HASHSET, 1, channel(1, DOUBLE, filterId));
    verifyPassthrough(createOperator((DynamicFilterSourceOperatorFactory) operatorFactory), ImmutableList.of(BOOLEAN, DOUBLE), new Page(createBooleansBlock(true, 2), createDoublesBlock(1.5, 3.0)), new Page(createBooleansBlock(false, 1), createDoublesBlock(4.5)));
    operatorFactory.noMoreOperators();
    String key = DynamicFilterUtils.createKey(PARTIALPREFIX, filterId, TEST_SESSION.getQueryId().toString());
    Set<Double> set = new HashSet<>(Arrays.asList(1.5, 3.0, 4.5));
    StateSet states = ((StateSet) stateStoreProvider.getStateStore().getStateCollection(key));
    for (Object bfSerialized : states.getAll()) {
        assertEquals((Set) bfSerialized, set);
    }
}
Also used : DynamicFilterSourceOperatorFactory(io.prestosql.operator.DynamicFilterSourceOperator.DynamicFilterSourceOperatorFactory) DynamicFilterSourceOperatorFactory(io.prestosql.operator.DynamicFilterSourceOperator.DynamicFilterSourceOperatorFactory) SequencePageBuilder.createSequencePage(io.prestosql.SequencePageBuilder.createSequencePage) Page(io.prestosql.spi.Page) StateSet(io.prestosql.spi.statestore.StateSet) HashSet(java.util.HashSet) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

StateSet (io.prestosql.spi.statestore.StateSet)15 DynamicFilterSourceOperatorFactory (io.prestosql.operator.DynamicFilterSourceOperator.DynamicFilterSourceOperatorFactory)10 HashSet (java.util.HashSet)10 AfterTest (org.testng.annotations.AfterTest)10 BeforeTest (org.testng.annotations.BeforeTest)10 Test (org.testng.annotations.Test)10 SequencePageBuilder.createSequencePage (io.prestosql.SequencePageBuilder.createSequencePage)9 Page (io.prestosql.spi.Page)9 BloomFilterDynamicFilter (io.prestosql.spi.dynamicfilter.BloomFilterDynamicFilter)4 StateStore (io.prestosql.spi.statestore.StateStore)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 DynamicFilter (io.prestosql.spi.dynamicfilter.DynamicFilter)2 StateMap (io.prestosql.spi.statestore.StateMap)2 BloomFilter (io.prestosql.spi.util.BloomFilter)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Set (java.util.Set)2 ImmutableSet (com.google.common.collect.ImmutableSet)1