Package org.apache.flink.api.java.record.operators

Examples of org.apache.flink.api.java.record.operators.CollectionDataSource


      tmpInner.add(Integer.parseInt(s.split(" ")[1]));
      tmp.add(tmpInner);
    }

    // test serializable iterator input, the input record is {id, word}
    CollectionDataSource source = new CollectionDataSource(new SerializableIteratorTest(), "test_iterator");
    // test collection input, the input record is {id, count}
    CollectionDataSource source2 = new CollectionDataSource(tmp, "test_collection");

    JoinOperator join = JoinOperator.builder(Join.class, IntValue.class, 0, 0)
      .input1(source).input2(source2).build();

    FileDataSink out = new FileDataSink(new CsvOutputFormat(), output, join, "Collection Join");
View Full Code Here


    /*
     * valid array input
     */
    try {
      new CollectionDataSource("test_1d_valid_array", "a", "b", "c");
    } catch (Exception e) {
      e.printStackTrace();
      Assert.fail(e.getMessage());
    }

    try {
      new CollectionDataSource("test_2d_valid_array", new Object[][] { { 1, "a" },
        { 2, "b" }, { 3, "c" } });
    } catch (Exception e) {
      e.printStackTrace();
      Assert.fail(e.getMessage());
    }

    /*
     * invalid array input
     */
    try {
      new CollectionDataSource("test_1d_invalid_array", 1, "b", "c");
      Assert.fail("input type is different");
    } catch (Exception e) {
    }

    try {
      new CollectionDataSource("test_2d_invalid_array", new Object[][] {
        { 1, "a" }, { 2, "b" }, { 3, 4 } });
      Assert.fail("input type is different");
    } catch (Exception e) {
    }
  }
View Full Code Here

    try {
      List<Object> tmp = new ArrayList<Object>();
      for (int i = 0; i < 100; i++) {
        tmp.add(i);
      }
      new CollectionDataSource(tmp, "test_valid_collection");
    } catch (Exception e) {
      e.printStackTrace();
      Assert.fail(e.getMessage());
    }

    try {
      List<Object> tmp = new ArrayList<Object>();
      for (int i = 0; i < 100; i++) {
        List<Object> inner = new ArrayList<Object>();
        inner.add(i);
        inner.add('a' + i);
        tmp.add(inner);
      }
      new CollectionDataSource(tmp, "test_valid_double_collection");
    } catch (Exception e) {
      e.printStackTrace();
      Assert.fail(e.getMessage());
    }

    /*
     * invalid collection input
     */
    try {
      List<Object> tmp = new ArrayList<Object>();
      for (int i = 0; i < 100; i++) {
        tmp.add(i);
      }
      tmp.add("a");
      new CollectionDataSource(tmp, "test_invalid_collection");
      Assert.fail("input type is different");
    } catch (Exception e) {
    }

    try {
      List<Object> tmp = new ArrayList<Object>();
      for (int i = 0; i < 100; i++) {
        List<Object> inner = new ArrayList<Object>();
        inner.add(i);
        inner.add('a' + i);
        tmp.add(inner);
      }
      List<Object> inner = new ArrayList<Object>();
      inner.add('a');
      inner.add('a');
      tmp.add(inner);
      new CollectionDataSource(tmp, "test_invalid_double_collection");
      Assert.fail("input type is different");
    } catch (Exception e) {
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.flink.api.java.record.operators.CollectionDataSource

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.