@Test
public void testDistributedMergeTask() throws Exception {
ClusterService clusterService = cluster().getInstance(ClusterService.class);
Functions functions = cluster().getInstance(Functions.class);
AggregationFunction countAggregation =
(AggregationFunction)functions.get(new FunctionIdent(CountAggregation.NAME, ImmutableList.<DataType>of()));
TransportMergeNodeAction transportMergeNodeAction = cluster().getInstance(TransportMergeNodeAction.class);
Set<String> nodes = new HashSet<>();
for (DiscoveryNode discoveryNode : clusterService.state().nodes()) {
nodes.add(discoveryNode.getId());
}
// select count(*), user ... group by user
MergeNode mergeNode = new MergeNode("merge1", 2);
mergeNode.contextId(UUID.randomUUID());
mergeNode.executionNodes(nodes);
mergeNode.inputTypes(Arrays.<DataType>asList(DataTypes.UNDEFINED, DataTypes.STRING));
GroupProjection groupProjection = new GroupProjection();
groupProjection.keys(Arrays.<DataTypeSymbol>asList(new InputColumn(1, DataTypes.STRING)));
groupProjection.values(Arrays.asList(
new Aggregation(
countAggregation.info(),
ImmutableList.<Symbol>of(new InputColumn(0)),
Aggregation.Step.PARTIAL,
Aggregation.Step.FINAL
)
));