Package org.apache.flink.api.common.operators

Examples of org.apache.flink.api.common.operators.SingleInputSemanticProperties


    {
      String[] constantFieldsExcept = { "1,2" };
 
      TypeInformation<?> type = new TupleTypeInfo<Tuple3<Integer, Integer, Integer>>(BasicTypeInfo.INT_TYPE_INFO,
          BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO);
      SingleInputSemanticProperties sp = SemanticPropUtil.getSemanticPropsSingleFromString(null, constantFieldsExcept, null, type, type);
 
      FieldSet fs = sp.getForwardedField(0);
      Assert.assertTrue(fs.size() == 1);
      Assert.assertTrue(fs.contains(0));
 
      Assert.assertNull(sp.getForwardedField(1));
      Assert.assertNull(sp.getForwardedField(2));
    }
   
    // with spaces
    {
      String[] constantFieldsExcept = { " 1  , 2" };
     
      TypeInformation<?> type = new TupleTypeInfo<Tuple3<Integer, Integer, Integer>>(BasicTypeInfo.INT_TYPE_INFO,
          BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO);
      SingleInputSemanticProperties sp = SemanticPropUtil.getSemanticPropsSingleFromString(null, constantFieldsExcept, null, type, type);
 
      FieldSet fs = sp.getForwardedField(0);
      Assert.assertTrue(fs.size() == 1);
      Assert.assertTrue(fs.contains(0));
 
      Assert.assertNull(sp.getForwardedField(1));
      Assert.assertNull(sp.getForwardedField(2));
    }
  }
View Full Code Here


    {
      String[] readFields = { "1", "2" };
 
      TypeInformation<?> type = new TupleTypeInfo<Tuple3<Integer, Integer, Integer>>(BasicTypeInfo.INT_TYPE_INFO,
          BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO);
      SingleInputSemanticProperties sp = SemanticPropUtil.getSemanticPropsSingleFromString(null, null, readFields, type, type);
 
      FieldSet fs = sp.getReadFields();
      Assert.assertTrue(fs.size() == 2);
      Assert.assertTrue(fs.contains(2));
      Assert.assertTrue(fs.contains(1));
    }
   
    // with spaces
    {
      String[] readFields = { "   1    ", " 2   " };
 
      TypeInformation<?> type = new TupleTypeInfo<Tuple3<Integer, Integer, Integer>>(BasicTypeInfo.INT_TYPE_INFO,
          BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO);
      SingleInputSemanticProperties sp = SemanticPropUtil.getSemanticPropsSingleFromString(null, null, readFields, type, type);
 
      FieldSet fs = sp.getReadFields();
      Assert.assertTrue(fs.size() == 2);
      Assert.assertTrue(fs.contains(2));
      Assert.assertTrue(fs.contains(1));
    }
  }
View Full Code Here

    {
      String[] readFields = { "1,2" };
 
      TypeInformation<?> type = new TupleTypeInfo<Tuple3<Integer, Integer, Integer>>(BasicTypeInfo.INT_TYPE_INFO,
          BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO);
      SingleInputSemanticProperties sp = SemanticPropUtil.getSemanticPropsSingleFromString(null, null, readFields, type, type);
 
      FieldSet fs = sp.getReadFields();
      Assert.assertTrue(fs.size() == 2);
      Assert.assertTrue(fs.contains(2));
      Assert.assertTrue(fs.contains(1));
    }
   
    // with spaces
    {
      String[] readFields = { "  1  , 2   " };
     
      TypeInformation<?> type = new TupleTypeInfo<Tuple3<Integer, Integer, Integer>>(BasicTypeInfo.INT_TYPE_INFO,
          BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO);
      SingleInputSemanticProperties sp = SemanticPropUtil.getSemanticPropsSingleFromString(null, null, readFields, type, type);
 
      FieldSet fs = sp.getReadFields();
      Assert.assertTrue(fs.size() == 2);
      Assert.assertTrue(fs.contains(2));
      Assert.assertTrue(fs.contains(1));
    }
  }
View Full Code Here

  public void testExtractSemantics() {
    try {
      {
        ReduceOperator reduceOp = ReduceOperator.builder(new TestReduceFunction()).build();
       
        SingleInputSemanticProperties props = reduceOp.getSemanticProperties();
        FieldSet fw2 = props.getForwardedField(2);
        FieldSet fw4 = props.getForwardedField(4);
       
        assertNotNull(fw2);
        assertNotNull(fw4);
        assertEquals(1, fw2.size());
        assertEquals(1, fw4.size());
        assertTrue(fw2.contains(2));
        assertTrue(fw4.contains(4));
      }
      {
        ReduceOperator reduceOp = ReduceOperator.builder(TestReduceFunction.class).build();
       
        SingleInputSemanticProperties props = reduceOp.getSemanticProperties();
        FieldSet fw2 = props.getForwardedField(2);
        FieldSet fw4 = props.getForwardedField(4);
       
        assertNotNull(fw2);
        assertNotNull(fw4);
        assertEquals(1, fw2.size());
        assertEquals(1, fw4.size());
View Full Code Here

      Plan plan = env.createProgramPlan();

      GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next();
      PlanProjectOperator<?, ?> projectOperator = ((PlanProjectOperator<?, ?>) sink.getInput());

      SingleInputSemanticProperties props = projectOperator.getSemanticProperties();

      assertTrue(props.getForwardedField(1).size() == 1);
      assertTrue(props.getForwardedField(3).size() == 1);
      assertTrue(props.getForwardedField(2).size() == 1);
      assertTrue(props.getForwardedField(1).contains(0));
      assertTrue(props.getForwardedField(3).contains(1));
      assertTrue(props.getForwardedField(2).contains(2));
    } catch (Exception e) {
      System.err.println(e.getMessage());
      e.printStackTrace();
      fail("Exception in test: " + e.getMessage());
    }
View Full Code Here

TOP

Related Classes of org.apache.flink.api.common.operators.SingleInputSemanticProperties

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.