use of io.crate.planner.projection.TopNProjection in project crate by crate.
the class NestedLoopPhaseTest method testSerialization.
@Test
public void testSerialization() throws Exception {
TopNProjection topNProjection = new TopNProjection(10, 0, Collections.emptyList());
UUID jobId = UUID.randomUUID();
MergePhase mp1 = new MergePhase(jobId, 2, "merge", 1, Collections.emptyList(), ImmutableList.<DataType>of(DataTypes.STRING), ImmutableList.of(), DistributionInfo.DEFAULT_BROADCAST, null);
MergePhase mp2 = new MergePhase(jobId, 3, "merge", 1, Collections.emptyList(), ImmutableList.<DataType>of(DataTypes.STRING), ImmutableList.of(), DistributionInfo.DEFAULT_BROADCAST, null);
SqlExpressions sqlExpressions = new SqlExpressions(T3.SOURCES, T3.TR_1);
Symbol joinCondition = sqlExpressions.normalize(sqlExpressions.asSymbol("t1.x = t1.i"));
NestedLoopPhase node = new NestedLoopPhase(jobId, 1, "nestedLoop", ImmutableList.of(topNProjection), mp1, mp2, Sets.newHashSet("node1", "node2"), JoinType.INNER, joinCondition, 1, 1);
BytesStreamOutput output = new BytesStreamOutput();
node.writeTo(output);
StreamInput input = StreamInput.wrap(output.bytes());
NestedLoopPhase node2 = new NestedLoopPhase();
node2.readFrom(input);
assertThat(node.nodeIds(), Is.is(node2.nodeIds()));
assertThat(node.jobId(), Is.is(node2.jobId()));
assertThat(node.name(), is(node2.name()));
assertThat(node.outputTypes(), is(node2.outputTypes()));
assertThat(node.joinType(), is(node2.joinType()));
assertThat(node.numLeftOutputs(), is(node2.numLeftOutputs()));
assertThat(node.numRightOutputs(), is(node2.numRightOutputs()));
}
use of io.crate.planner.projection.TopNProjection 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()));
}
Aggregations