本文整理汇总了Java中org.apache.flink.api.java.tuple.Tuple6类的典型用法代码示例。如果您正苦于以下问题:Java Tuple6类的具体用法?Java Tuple6怎么用?Java Tuple6使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tuple6类属于org.apache.flink.api.java.tuple包,在下文中一共展示了Tuple6类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNumericAutocastInComparison
import org.apache.flink.api.java.tuple.Tuple6; //导入依赖的package包/类
@Test
public void testNumericAutocastInComparison() throws Exception {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, config());
DataSource<Tuple6<Byte, Short, Integer, Long, Float, Double>> input =
env.fromElements(
new Tuple6<>((byte) 1, (short) 1, 1, 1L, 1.0f, 1.0d),
new Tuple6<>((byte) 2, (short) 2, 2, 2L, 2.0f, 2.0d));
Table table =
tableEnv.fromDataSet(input, "a,b,c,d,e,f");
Table result = table
.filter("a > 1 && b > 1 && c > 1L && d > 1.0f && e > 1.0d && f > 1");
DataSet<Row> ds = tableEnv.toDataSet(result, Row.class);
List<Row> results = ds.collect();
String expected = "2,2,2,2,2.0,2.0";
compareResultAsText(results, expected);
}
示例2: main
import org.apache.flink.api.java.tuple.Tuple6; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// parse parameters
ParameterTool params = ParameterTool.fromArgs(args);
String input = params.getRequired("input");
String output = params.getRequired("output");
// obtain execution environment
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
// read the raw mail data, each mail is a String
DataSet<String> rawMails =
env.readFile(new MBoxMailFormat(MAIL_DAEMON_PREFIX), input);
// parse mail String into record with six fields
DataSet<Tuple6<String, String, String, String, String, String>> mails = rawMails
// parse mails
.flatMap(new MBoxMailParser(MAIL_DAEMON_PREFIX))
// filter out mails with duplicate messageIds
.distinct(0);
// write mail records as delimited files
mails.writeAsCsv(output, MAIL_RECORD_DELIM, MAIL_FIELD_DELIM);
env.execute();
}
示例3: testProjectOnATuple1Input
import org.apache.flink.api.java.tuple.Tuple6; //导入依赖的package包/类
@Test
public void testProjectOnATuple1Input() throws Exception {
/*
* Project join on a tuple input 1
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple3<Integer, Long, String>> ds1 = CollectionDataSets.getSmall3TupleDataSet(env);
DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = CollectionDataSets.get5TupleDataSet(env);
DataSet<Tuple6<String, Long, String, Integer, Long, Long>> joinDs =
ds1.join(ds2)
.where(1)
.equalTo(1)
.projectFirst(2, 1)
.projectSecond(3)
.projectFirst(0)
.projectSecond(4, 1);
List<Tuple6<String, Long, String, Integer, Long, Long>> result = joinDs.collect();
String expected = "Hi,1,Hallo,1,1,1\n" +
"Hello,2,Hallo Welt,2,2,2\n" +
"Hello world,2,Hallo Welt,3,2,2\n";
compareResultAsTuples(result, expected);
}
示例4: testProjectJoinOnATuple2Input
import org.apache.flink.api.java.tuple.Tuple6; //导入依赖的package包/类
@Test
public void testProjectJoinOnATuple2Input() throws Exception {
/*
* Project join on a tuple input 2
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple3<Integer, Long, String>> ds1 = CollectionDataSets.getSmall3TupleDataSet(env);
DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = CollectionDataSets.get5TupleDataSet(env);
DataSet<Tuple6<String, String, Long, Long, Long, Integer>> joinDs =
ds1.join(ds2)
.where(1)
.equalTo(1)
.projectSecond(3)
.projectFirst(2, 1)
.projectSecond(4, 1)
.projectFirst(0);
List<Tuple6<String, String, Long, Long, Long, Integer>> result = joinDs.collect();
String expected = "Hallo,Hi,1,1,1,1\n" +
"Hallo Welt,Hello,2,2,2,2\n" +
"Hallo Welt,Hello world,2,2,2,3\n";
compareResultAsTuples(result, expected);
}
示例5: testProjectCrossOnATupleInput1
import org.apache.flink.api.java.tuple.Tuple6; //导入依赖的package包/类
@Test
public void testProjectCrossOnATupleInput1() throws Exception{
/*
* project cross on a tuple input 1
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple3<Integer, Long, String>> ds = CollectionDataSets.getSmall3TupleDataSet(env);
DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = CollectionDataSets.getSmall5TupleDataSet(env);
DataSet<Tuple6<String, Long, String, Integer, Long, Long>> crossDs = ds.cross(ds2)
.projectFirst(2, 1)
.projectSecond(3)
.projectFirst(0)
.projectSecond(4,1);
List<Tuple6<String, Long, String, Integer, Long, Long>> result = crossDs.collect();
String expected = "Hi,1,Hallo,1,1,1\n" +
"Hi,1,Hallo Welt,1,2,2\n" +
"Hi,1,Hallo Welt wie,1,1,3\n" +
"Hello,2,Hallo,2,1,1\n" +
"Hello,2,Hallo Welt,2,2,2\n" +
"Hello,2,Hallo Welt wie,2,1,3\n" +
"Hello world,2,Hallo,3,1,1\n" +
"Hello world,2,Hallo Welt,3,2,2\n" +
"Hello world,2,Hallo Welt wie,3,1,3\n";
compareResultAsTuples(result, expected);
}
示例6: testProjectCrossOnATupleInput2
import org.apache.flink.api.java.tuple.Tuple6; //导入依赖的package包/类
@Test
public void testProjectCrossOnATupleInput2() throws Exception {
/*
* project cross on a tuple input 2
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple3<Integer, Long, String>> ds = CollectionDataSets.getSmall3TupleDataSet(env);
DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = CollectionDataSets.getSmall5TupleDataSet(env);
DataSet<Tuple6<String, String, Long, Long, Long,Integer>> crossDs = ds.cross(ds2)
.projectSecond(3)
.projectFirst(2, 1)
.projectSecond(4,1)
.projectFirst(0);
List<Tuple6<String, String, Long, Long, Long, Integer>> result = crossDs.collect();
String expected = "Hallo,Hi,1,1,1,1\n" +
"Hallo Welt,Hi,1,2,2,1\n" +
"Hallo Welt wie,Hi,1,1,3,1\n" +
"Hallo,Hello,2,1,1,2\n" +
"Hallo Welt,Hello,2,2,2,2\n" +
"Hallo Welt wie,Hello,2,1,3,2\n" +
"Hallo,Hello world,2,1,1,3\n" +
"Hallo Welt,Hello world,2,2,2,3\n" +
"Hallo Welt wie,Hello world,2,1,3,3\n";
compareResultAsTuples(result, expected);
}
示例7: testProjectCrossOnATupleInput1
import org.apache.flink.api.java.tuple.Tuple6; //导入依赖的package包/类
@Test
public void testProjectCrossOnATupleInput1() throws Exception{
/*
* project cross on a tuple input 1
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple3<Integer, Long, String>> ds = CollectionDataSets.getSmall3TupleDataSet(env);
DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = CollectionDataSets.getSmall5TupleDataSet(env);
DataSet<Tuple6<String, Long, String, Integer, Long, Long>> crossDs = ds.cross(ds2)
.projectFirst(2, 1)
.projectSecond(3)
.projectFirst(0)
.projectSecond(4, 1);
List<Tuple6<String, Long, String, Integer, Long, Long>> result = crossDs.collect();
String expected = "Hi,1,Hallo,1,1,1\n" +
"Hi,1,Hallo Welt,1,2,2\n" +
"Hi,1,Hallo Welt wie,1,1,3\n" +
"Hello,2,Hallo,2,1,1\n" +
"Hello,2,Hallo Welt,2,2,2\n" +
"Hello,2,Hallo Welt wie,2,1,3\n" +
"Hello world,2,Hallo,3,1,1\n" +
"Hello world,2,Hallo Welt,3,2,2\n" +
"Hello world,2,Hallo Welt wie,3,1,3\n";
compareResultAsTuples(result, expected);
}
示例8: testProjectCrossOnATupleInput2
import org.apache.flink.api.java.tuple.Tuple6; //导入依赖的package包/类
@Test
public void testProjectCrossOnATupleInput2() throws Exception {
/*
* project cross on a tuple input 2
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple3<Integer, Long, String>> ds = CollectionDataSets.getSmall3TupleDataSet(env);
DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = CollectionDataSets.getSmall5TupleDataSet(env);
DataSet<Tuple6<String, String, Long, Long, Long, Integer>> crossDs = ds.cross(ds2)
.projectSecond(3)
.projectFirst(2, 1)
.projectSecond(4, 1)
.projectFirst(0);
List<Tuple6<String, String, Long, Long, Long, Integer>> result = crossDs.collect();
String expected = "Hallo,Hi,1,1,1,1\n" +
"Hallo Welt,Hi,1,2,2,1\n" +
"Hallo Welt wie,Hi,1,1,3,1\n" +
"Hallo,Hello,2,1,1,2\n" +
"Hallo Welt,Hello,2,2,2,2\n" +
"Hallo Welt wie,Hello,2,1,3,2\n" +
"Hallo,Hello world,2,1,1,3\n" +
"Hallo Welt,Hello world,2,2,2,3\n" +
"Hallo Welt wie,Hello world,2,1,3,3\n";
compareResultAsTuples(result, expected);
}
示例9: extractTimestamp
import org.apache.flink.api.java.tuple.Tuple6; //导入依赖的package包/类
@Override
public long extractTimestamp(Tuple6<String, String, Long, String, Long, Double> element, long previousElementTimestamp) {
long timestamp = element.f2; // get processing timestamp from current event
currentMaxTimestamp = Math.max(timestamp, currentMaxTimestamp);
return timestamp;
}
示例10: newTuple
import org.apache.flink.api.java.tuple.Tuple6; //导入依赖的package包/类
/**
* Convert object array to type of Tuple{N} where N is between 0 to 25.
*
* @throws IllegalArgumentException if rows's length > 25
*/
public static <T extends Tuple> T newTuple(Object[] row) {
Preconditions.checkNotNull(row, "Tuple row is null");
switch (row.length) {
case 0:
return setTupleValue(new Tuple0(), row);
case 1:
return setTupleValue(new Tuple1(), row);
case 2:
return setTupleValue(new Tuple2(), row);
case 3:
return setTupleValue(new Tuple3(), row);
case 4:
return setTupleValue(new Tuple4(), row);
case 5:
return setTupleValue(new Tuple5(), row);
case 6:
return setTupleValue(new Tuple6(), row);
case 7:
return setTupleValue(new Tuple7(), row);
case 8:
return setTupleValue(new Tuple8(), row);
case 9:
return setTupleValue(new Tuple9(), row);
case 10:
return setTupleValue(new Tuple10(), row);
case 11:
return setTupleValue(new Tuple11(), row);
case 12:
return setTupleValue(new Tuple12(), row);
case 13:
return setTupleValue(new Tuple13(), row);
case 14:
return setTupleValue(new Tuple14(), row);
case 15:
return setTupleValue(new Tuple15(), row);
case 16:
return setTupleValue(new Tuple16(), row);
case 17:
return setTupleValue(new Tuple17(), row);
case 18:
return setTupleValue(new Tuple18(), row);
case 19:
return setTupleValue(new Tuple19(), row);
case 20:
return setTupleValue(new Tuple20(), row);
case 21:
return setTupleValue(new Tuple21(), row);
case 22:
return setTupleValue(new Tuple22(), row);
case 23:
return setTupleValue(new Tuple23(), row);
case 24:
return setTupleValue(new Tuple24(), row);
case 25:
return setTupleValue(new Tuple25(), row);
default:
throw new IllegalArgumentException("Too long row: " + row.length + ", unable to convert to Tuple");
}
}
示例11: newTuple
import org.apache.flink.api.java.tuple.Tuple6; //导入依赖的package包/类
/**
* Convert object array to type of Tuple{N} where N is between 0 to 25.
*
* @throws IllegalArgumentException if rows's length > 25
*/
public static <T extends Tuple> T newTuple(Object[] row) {
Preconditions.checkNotNull(row, "Tuple row is null");
switch (row.length) {
case 0:
return setTupleValue(new Tuple0(), row);
case 1:
return setTupleValue(new Tuple1(), row);
case 2:
return setTupleValue(new Tuple2(), row);
case 3:
return setTupleValue(new Tuple3(), row);
case 4:
return setTupleValue(new Tuple4(), row);
case 5:
return setTupleValue(new Tuple5(), row);
case 6:
return setTupleValue(new Tuple6(), row);
case 7:
return setTupleValue(new Tuple7(), row);
case 8:
return setTupleValue(new Tuple8(), row);
case 9:
return setTupleValue(new Tuple9(), row);
case 10:
return setTupleValue(new Tuple10(), row);
case 11:
return setTupleValue(new Tuple11(), row);
case 12:
return setTupleValue(new Tuple12(), row);
case 13:
return setTupleValue(new Tuple13(), row);
case 14:
return setTupleValue(new Tuple14(), row);
case 15:
return setTupleValue(new Tuple15(), row);
case 16:
return setTupleValue(new Tuple16(), row);
case 17:
return setTupleValue(new Tuple17(), row);
case 18:
return setTupleValue(new Tuple18(), row);
case 19:
return setTupleValue(new Tuple19(), row);
case 20:
return setTupleValue(new Tuple20(), row);
case 21:
return setTupleValue(new Tuple21(), row);
case 22:
return setTupleValue(new Tuple22(), row);
case 23:
return setTupleValue(new Tuple23(), row);
case 24:
return setTupleValue(new Tuple24(), row);
case 25:
return setTupleValue(new Tuple25(), row);
default:
throw new IllegalArgumentException("Too long row: " + row.length + ", unable to convert to Tuple");
}
}
示例12: main
import org.apache.flink.api.java.tuple.Tuple6; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
if (!parseParameters(args)) {
return;
}
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
// get customer data set: (custkey, name, address, nationkey, acctbal)
DataSet<Tuple5<Integer, String, String, Integer, Double>> customers = getCustomerDataSet(env);
// get orders data set: (orderkey, custkey, orderdate)
DataSet<Tuple3<Integer, Integer, String>> orders = getOrdersDataSet(env);
// get lineitem data set: (orderkey, extendedprice, discount, returnflag)
DataSet<Tuple4<Integer, Double, Double, String>> lineitems = getLineitemDataSet(env);
// get nation data set: (nationkey, name)
DataSet<Tuple2<Integer, String>> nations = getNationsDataSet(env);
// orders filtered by year: (orderkey, custkey)
DataSet<Tuple2<Integer, Integer>> ordersFilteredByYear =
// filter by year
orders.filter(order -> Integer.parseInt(order.f2.substring(0, 4)) > 1990)
// project fields out that are no longer required
.project(0, 1);
// lineitems filtered by flag: (orderkey, extendedprice, discount)
DataSet<Tuple3<Integer, Double, Double>> lineitemsFilteredByFlag =
// filter by flag
lineitems.filter(lineitem -> lineitem.f3.equals("R"))
// project fields out that are no longer required
.project(0, 1, 2);
// join orders with lineitems: (custkey, extendedprice, discount)
DataSet<Tuple3<Integer, Double, Double>> lineitemsOfCustomerKey =
ordersFilteredByYear.joinWithHuge(lineitemsFilteredByFlag)
.where(0).equalTo(0)
.projectFirst(1).projectSecond(1, 2);
// aggregate for revenue: (custkey, revenue)
DataSet<Tuple2<Integer, Double>> revenueOfCustomerKey = lineitemsOfCustomerKey
// calculate the revenue for each item
// revenue per item = l_extendedprice * (1 - l_discount)
.map(i -> new Tuple2<>(i.f0, i.f1 * (1 - i.f2)))
// aggregate the revenues per item to revenue per customer
.groupBy(0).sum(1);
// join customer with nation (custkey, name, address, nationname, acctbal)
DataSet<Tuple5<Integer, String, String, String, Double>> customerWithNation = customers
.joinWithTiny(nations)
.where(3).equalTo(0)
.projectFirst(0, 1, 2).projectSecond(1).projectFirst(4);
// join customer (with nation) with revenue (custkey, name, address, nationname, acctbal, revenue)
DataSet<Tuple6<Integer, String, String, String, Double, Double>> customerWithRevenue =
customerWithNation.join(revenueOfCustomerKey)
.where(0).equalTo(0)
.projectFirst(0, 1, 2, 3, 4).projectSecond(1);
// emit result
customerWithRevenue.writeAsCsv(outputPath);
// execute program
env.execute("TPCH Query 10 Example");
}
示例13: add
import org.apache.flink.api.java.tuple.Tuple6; //导入依赖的package包/类
public Tuple6Builder<T0, T1, T2, T3, T4, T5> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5){
tuples.add(new Tuple6<>(value0, value1, value2, value3, value4, value5));
return this;
}
示例14: build
import org.apache.flink.api.java.tuple.Tuple6; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Tuple6<T0, T1, T2, T3, T4, T5>[] build(){
return tuples.toArray(new Tuple6[tuples.size()]);
}
示例15: main
import org.apache.flink.api.java.tuple.Tuple6; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
if(!parseParameters(args)) {
return;
}
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
// get customer data set: (custkey, name, address, nationkey, acctbal)
DataSet<Tuple5<Integer, String, String, Integer, Double>> customers = getCustomerDataSet(env);
// get orders data set: (orderkey, custkey, orderdate)
DataSet<Tuple3<Integer, Integer, String>> orders = getOrdersDataSet(env);
// get lineitem data set: (orderkey, extendedprice, discount, returnflag)
DataSet<Tuple4<Integer, Double, Double, String>> lineitems = getLineitemDataSet(env);
// get nation data set: (nationkey, name)
DataSet<Tuple2<Integer, String>> nations = getNationsDataSet(env);
// orders filtered by year: (orderkey, custkey)
DataSet<Tuple2<Integer, Integer>> ordersFilteredByYear =
// filter by year
orders.filter(order -> Integer.parseInt(order.f2.substring(0, 4)) > 1990)
// project fields out that are no longer required
.project(0,1).types(Integer.class, Integer.class);
// lineitems filtered by flag: (orderkey, extendedprice, discount)
DataSet<Tuple3<Integer, Double, Double>> lineitemsFilteredByFlag =
// filter by flag
lineitems.filter(lineitem -> lineitem.f3.equals("R"))
// project fields out that are no longer required
.project(0,1,2).types(Integer.class, Double.class, Double.class);
// join orders with lineitems: (custkey, extendedprice, discount)
DataSet<Tuple3<Integer, Double, Double>> lineitemsOfCustomerKey =
ordersFilteredByYear.joinWithHuge(lineitemsFilteredByFlag)
.where(0).equalTo(0)
.projectFirst(1).projectSecond(1,2)
.types(Integer.class, Double.class, Double.class);
// aggregate for revenue: (custkey, revenue)
DataSet<Tuple2<Integer, Double>> revenueOfCustomerKey = lineitemsOfCustomerKey
// calculate the revenue for each item
// revenue per item = l_extendedprice * (1 - l_discount)
.map(i -> new Tuple2<>(i.f0, i.f1 * (1 - i.f2)))
// aggregate the revenues per item to revenue per customer
.groupBy(0).sum(1);
// join customer with nation (custkey, name, address, nationname, acctbal)
DataSet<Tuple5<Integer, String, String, String, Double>> customerWithNation = customers
.joinWithTiny(nations)
.where(3).equalTo(0)
.projectFirst(0,1,2).projectSecond(1).projectFirst(4)
.types(Integer.class, String.class, String.class, String.class, Double.class);
// join customer (with nation) with revenue (custkey, name, address, nationname, acctbal, revenue)
DataSet<Tuple6<Integer, String, String, String, Double, Double>> customerWithRevenue =
customerWithNation.join(revenueOfCustomerKey)
.where(0).equalTo(0)
.projectFirst(0,1,2,3,4).projectSecond(1)
.types(Integer.class, String.class, String.class, String.class, Double.class, Double.class);
// emit result
customerWithRevenue.writeAsCsv(outputPath);
// execute program
env.execute("TPCH Query 10 Example");
}