@Test public void testRowHistograms() { RowType innerRowType = RowType.from(ImmutableList.of( RowType.field("f1", BIGINT), RowType.field("f2", DOUBLE))); MapType mapType = mapType(innerRowType, BIGINT); InternalAggregationFunction aggregationFunction = getAggregation(mapType.getTypeSignature(), innerRowType.getTypeSignature()); BlockBuilder builder = innerRowType.createBlockBuilder(null, 3); innerRowType.writeObject(builder, toRow(ImmutableList.of(BIGINT, DOUBLE), 1L, 1.0)); innerRowType.writeObject(builder, toRow(ImmutableList.of(BIGINT, DOUBLE), 2L, 2.0)); innerRowType.writeObject(builder, toRow(ImmutableList.of(BIGINT, DOUBLE), 3L, 3.0)); assertAggregation( aggregationFunction, ImmutableMap.of(ImmutableList.of(1L, 1.0), 1L, ImmutableList.of(2L, 2.0), 1L, ImmutableList.of(3L, 3.0), 1L), builder.build()); }
@Test public void testDoubleRowMap() { RowType innerRowType = RowType.from(ImmutableList.of( RowType.field("f1", INTEGER), RowType.field("f2", DOUBLE))); MapType mapType = mapType(DOUBLE, innerRowType); InternalAggregationFunction aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), parseTypeSignature(StandardTypes.DOUBLE), innerRowType.getTypeSignature())); BlockBuilder builder = innerRowType.createBlockBuilder(null, 3); innerRowType.writeObject(builder, toRow(ImmutableList.of(INTEGER, DOUBLE), 1L, 1.0)); innerRowType.writeObject(builder, toRow(ImmutableList.of(INTEGER, DOUBLE), 2L, 2.0)); innerRowType.writeObject(builder, toRow(ImmutableList.of(INTEGER, DOUBLE), 3L, 3.0)); assertAggregation( aggFunc, ImmutableMap.of(1.0, ImmutableList.of(1, 1.0), 2.0, ImmutableList.of(2, 2.0), 3.0, ImmutableList.of(3, 3.0)), createDoublesBlock(1.0, 2.0, 3.0), builder.build()); }
@Override public void writeToBlock(BlockBuilder blockBuilder) { _rowType.writeObject(blockBuilder, getUnderlyingData()); } }
@Override public void writeToBlock(BlockBuilder blockBuilder) { _rowType.writeObject(blockBuilder, getUnderlyingData()); } }