use of com.facebook.presto.operator.aggregation.state.MapUnionSumState in project presto by prestodb.
the class TestMapUnionSumResult method testAddToKeySet.
@Test
public void testAddToKeySet() {
MapType mapType = createMapType(BIGINT, BIGINT);
Map<Long, Long> map = new HashMap<>();
map.put(1L, 1L);
MapBlock mapBlock = (MapBlock) createMapBlock(mapType, map);
Block singleMapBlock = mapBlock.getBlock(0);
MapUnionSumState mapUnionSumState = new MapUnionSumStateFactory(BIGINT, BIGINT).createSingleState();
MapUnionSumResult mapUnionSumResult = MapUnionSumResult.create(BIGINT, BIGINT, mapUnionSumState.getAdder(), singleMapBlock);
TypedSet typedSet = new TypedSet(BIGINT, 1, "TEST");
Block block = createLongsBlock(-1);
typedSet.add(block, 0);
assertEquals(typedSet.size(), 1);
assertEquals(mapUnionSumResult.size(), 1);
mapUnionSumResult.unionSum(mapUnionSumResult).addKeyToSet(typedSet, 0);
assertEquals(typedSet.size(), 2);
assertEquals(mapUnionSumResult.size(), 1);
}
Aggregations