Package eu.stratosphere.api.java.tuple

Examples of eu.stratosphere.api.java.tuple.Tuple5


        .setDrivername("org.apache.derby.jdbc.EmbeddedDriver")
        .setDBUrl("jdbc:derby:memory:ebookshop")
        .setQuery("select * from books")
        .finish();
    jdbcInputFormat.open(null);
    Tuple5 tuple = new Tuple5();
    int recordCount = 0;
    while (!jdbcInputFormat.reachedEnd()) {
      jdbcInputFormat.nextRecord(tuple);
      Assert.assertEquals("Field 0 should be int", Integer.class, tuple.getField(0).getClass());
      Assert.assertEquals("Field 1 should be String", String.class, tuple.getField(1).getClass());
      Assert.assertEquals("Field 2 should be String", String.class, tuple.getField(2).getClass());
      Assert.assertEquals("Field 3 should be float", Double.class, tuple.getField(3).getClass());
      Assert.assertEquals("Field 4 should be int", Integer.class, tuple.getField(4).getClass());

      for (int x = 0; x < 5; x++) {
        Assert.assertEquals(dbData[recordCount][x], tuple.getField(x));
      }
      recordCount++;
    }
    Assert.assertEquals(5, recordCount);
  }
View Full Code Here


        .setDBUrl("jdbc:derby:memory:ebookshop")
        .setQuery("insert into books (id, title, author, price, qty) values (?,?,?,?,?)")
        .finish();
    jdbcOutputFormat.open(0, 1);

    Tuple5 tuple5 = new Tuple5();
    tuple5.setField(4, 0);
    tuple5.setField("hello", 1);
    tuple5.setField("world", 2);
    tuple5.setField(0.99, 3);
    tuple5.setField("imthewrongtype", 4);

    jdbcOutputFormat.writeRecord(tuple5);
    jdbcOutputFormat.close();
  }
View Full Code Here

        .setDBUrl(dbUrl)
        .setQuery("select * from " + sourceTable)
        .finish();
    jdbcInputFormat.open(null);

    Tuple5 tuple = new Tuple5();
    while (!jdbcInputFormat.reachedEnd()) {
      jdbcInputFormat.nextRecord(tuple);
      jdbcOutputFormat.writeRecord(tuple);
    }

    jdbcOutputFormat.close();
    jdbcInputFormat.close();

    jdbcInputFormat = JDBCInputFormat.buildJDBCInputFormat()
        .setDrivername(driverPath)
        .setDBUrl(dbUrl)
        .setQuery("select * from " + targetTable)
        .finish();
    jdbcInputFormat.open(null);

    int recordCount = 0;
    while (!jdbcInputFormat.reachedEnd()) {
      jdbcInputFormat.nextRecord(tuple);
      Assert.assertEquals("Field 0 should be int", Integer.class, tuple.getField(0).getClass());
      Assert.assertEquals("Field 1 should be String", String.class, tuple.getField(1).getClass());
      Assert.assertEquals("Field 2 should be String", String.class, tuple.getField(2).getClass());
      Assert.assertEquals("Field 3 should be float", Double.class, tuple.getField(3).getClass());
      Assert.assertEquals("Field 4 should be int", Integer.class, tuple.getField(4).getClass());

      for (int x = 0; x < 5; x++) {
        Assert.assertEquals(dbData[recordCount][x], tuple.getField(x));
      }

      recordCount++;
    }
    Assert.assertEquals(5, recordCount);
View Full Code Here

TOP

Related Classes of eu.stratosphere.api.java.tuple.Tuple5

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.