Search in sources :

Example 1 with GroupProjection

use of io.crate.planner.projection.GroupProjection in project crate by crate.

the class MergeNodeTest method testSerialization.

@Test
public void testSerialization() throws Exception {
    Reference nameRef = TestingHelpers.createReference("name", DataTypes.STRING);
    List<Symbol> keys = Collections.singletonList(nameRef);
    List<Aggregation> aggregations = Collections.singletonList(Aggregation.finalAggregation(new FunctionInfo(new FunctionIdent(CountAggregation.NAME, ImmutableList.of()), DataTypes.LONG), ImmutableList.of(), Aggregation.Step.PARTIAL));
    GroupProjection groupProjection = new GroupProjection(keys, aggregations, RowGranularity.CLUSTER);
    TopNProjection topNProjection = new TopNProjection(10, 0, InputColumn.numInputs(keys.size() + aggregations.size()));
    List<Projection> projections = Arrays.asList(groupProjection, topNProjection);
    MergePhase node = new MergePhase(UUID.randomUUID(), 0, "merge", 2, Collections.emptyList(), Arrays.<DataType>asList(DataTypes.UNDEFINED, DataTypes.STRING), projections, DistributionInfo.DEFAULT_BROADCAST, null);
    node.executionNodes(Sets.newHashSet("node1", "node2"));
    BytesStreamOutput output = new BytesStreamOutput();
    node.writeTo(output);
    StreamInput input = StreamInput.wrap(output.bytes());
    MergePhase node2 = MergePhase.FACTORY.create();
    node2.readFrom(input);
    assertThat(node.numUpstreams(), is(node2.numUpstreams()));
    assertThat(node.nodeIds(), is(node2.nodeIds()));
    assertThat(node.jobId(), is(node2.jobId()));
    assertEquals(node.inputTypes(), node2.inputTypes());
    assertThat(node.phaseId(), is(node2.phaseId()));
    assertThat(node.distributionInfo(), is(node2.distributionInfo()));
}
Also used : Reference(io.crate.metadata.Reference) Symbol(io.crate.analyze.symbol.Symbol) FunctionInfo(io.crate.metadata.FunctionInfo) TopNProjection(io.crate.planner.projection.TopNProjection) GroupProjection(io.crate.planner.projection.GroupProjection) Projection(io.crate.planner.projection.Projection) TopNProjection(io.crate.planner.projection.TopNProjection) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) CountAggregation(io.crate.operation.aggregation.impl.CountAggregation) Aggregation(io.crate.analyze.symbol.Aggregation) FunctionIdent(io.crate.metadata.FunctionIdent) MergePhase(io.crate.planner.node.dql.MergePhase) StreamInput(org.elasticsearch.common.io.stream.StreamInput) GroupProjection(io.crate.planner.projection.GroupProjection) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

Aggregation (io.crate.analyze.symbol.Aggregation)1 Symbol (io.crate.analyze.symbol.Symbol)1 FunctionIdent (io.crate.metadata.FunctionIdent)1 FunctionInfo (io.crate.metadata.FunctionInfo)1 Reference (io.crate.metadata.Reference)1 CountAggregation (io.crate.operation.aggregation.impl.CountAggregation)1 MergePhase (io.crate.planner.node.dql.MergePhase)1 GroupProjection (io.crate.planner.projection.GroupProjection)1 Projection (io.crate.planner.projection.Projection)1 TopNProjection (io.crate.planner.projection.TopNProjection)1 CrateUnitTest (io.crate.test.integration.CrateUnitTest)1 BytesStreamOutput (org.elasticsearch.common.io.stream.BytesStreamOutput)1 StreamInput (org.elasticsearch.common.io.stream.StreamInput)1 Test (org.junit.Test)1