예제 #1
0
 @Before
 public void init() {
   schema
       .addInputField(0, "field1", Integer.class)
       .addInputField(0, "field2", Integer.class)
       .addOutputField(0, "field1", Integer.class)
       .addOutputField(0, "field2", Integer.class);
 }
예제 #2
0
  @Test
  public void
      shouldNotMergePartitionedStatefulAndStatelessRegionsWhenPartitionFieldNamesAreNotPresentInStatelessRegion() {
    final OperatorDef partitionedStateful =
        OperatorDefBuilder.newInstance("partitionedStateful", PartitionedStatefulOperator.class)
            .setExtendingSchema(schema)
            .setPartitionFieldNames(partitionFieldNames)
            .build();

    final OperatorRuntimeSchemaBuilder statelessSchema = new OperatorRuntimeSchemaBuilder(1, 1);

    final RuntimeSchemaField inputField =
        schema.getInputPortSchemaBuilder(0).getFields().iterator().next();
    final RuntimeSchemaField outputField =
        schema.getOutputPortSchemaBuilder(0).getFields().iterator().next();

    statelessSchema.addInputField(0, inputField.getName(), inputField.getType());
    statelessSchema.addOutputField(0, outputField.getName(), outputField.getType());

    final OperatorDef stateless =
        OperatorDefBuilder.newInstance("stateless", StatelessOperator.class)
            .setExtendingSchema(statelessSchema)
            .build();

    final FlowDef flow =
        new FlowDefBuilder()
            .add(partitionedStateful)
            .add(stateless)
            .connect("partitionedStateful", "stateless")
            .build();

    final List<RegionDef> regions = new ArrayList<>();
    regions.add(
        new RegionDef(
            0,
            PARTITIONED_STATEFUL,
            partitionedStateful.partitionFieldNames(),
            singletonList(partitionedStateful)));
    regions.add(new RegionDef(1, STATELESS, emptyList(), singletonList(stateless)));

    flowOptimizer.mergeRegions(flow.getOperatorsMap(), flow.getConnections(), regions);

    assertEquals(2, regions.size());
  }