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());
}
}
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);
}
}
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);
}
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);
}
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);
}
}
Aggregations