use of org.apache.flink.api.java.tuple.Tuple6 in project mangolaa-streams-processing-flink by Adsizzlerlabs.
the class AggregatedImpressionKey method getKey.
@Override
public Tuple6<Integer, Integer, Integer, Integer, Integer, ZonedDateTime> getKey(final Impression impression) throws Exception {
val advId = impression.getAdvId();
val sourceId = impression.getSourceId();
val clientId = impression.getClientId();
val campaignId = impression.getCampaignId();
val creativeId = impression.getCreativeId();
val minute = TimeUtil.roundOffToMinute(impression.getTimestamp());
// Key = advId, sourceId, clientId, campaignId, creativeId , minute
return new Tuple6<>(advId, sourceId, clientId, campaignId, creativeId, minute);
}
use of org.apache.flink.api.java.tuple.Tuple6 in project flink by apache.
the class CrossITCase method testProjectCrossOnATupleInput1.
@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);
}
use of org.apache.flink.api.java.tuple.Tuple6 in project mangolaa-streams-processing-flink by Adsizzlerlabs.
the class AggregatedBidRespKey method getKey.
@Override
public Tuple6<Integer, Integer, Integer, Integer, Integer, ZonedDateTime> getKey(final BidResp bidResp) throws Exception {
val advId = bidResp.getAdvId();
val sourceId = bidResp.getSourceId();
val clientId = bidResp.getClientId();
val campaignId = bidResp.getCampaignId();
val creativeId = bidResp.getCreativeId();
val minute = TimeUtil.roundOffToMinute(bidResp.getTimestamp());
// Key = advId, sourceId, clientId, campaignId, creativeId , minute
return new Tuple6<>(advId, sourceId, clientId, campaignId, creativeId, minute);
}
use of org.apache.flink.api.java.tuple.Tuple6 in project mangolaa-streams-processing-flink by Adsizzlerlabs.
the class AggregatedWinNotificationKey method getKey.
@Override
public Tuple6<Integer, Integer, Integer, Integer, Integer, ZonedDateTime> getKey(final WinNotification winNotification) throws Exception {
val advId = winNotification.getAdvId();
val sourceId = winNotification.getSourceId();
val clientId = winNotification.getClientId();
val campaignId = winNotification.getCampaignId();
val creativeId = winNotification.getCreativeId();
val minute = TimeUtil.roundOffToMinute(winNotification.getTimestamp());
// Key = advId, sourceId, clientId, campaignId, creativeId , minute
return new Tuple6<>(advId, sourceId, clientId, campaignId, creativeId, minute);
}
use of org.apache.flink.api.java.tuple.Tuple6 in project flink by apache.
the class TPCHQuery10 method main.
// *************************************************************************
// PROGRAM
// *************************************************************************
public static void main(String[] args) throws Exception {
final ParameterTool params = ParameterTool.fromArgs(args);
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
if (!params.has("customer") && !params.has("orders") && !params.has("lineitem") && !params.has("nation")) {
System.err.println(" This program expects data from the TPC-H benchmark as input data.");
System.err.println(" Due to legal restrictions, we can not ship generated data.");
System.err.println(" You can find the TPC-H data generator at http://www.tpc.org/tpch/.");
System.err.println(" Usage: TPCHQuery10 --customer <path> --orders <path> --lineitem <path> --nation <path> [--output <path>]");
return;
}
// get customer data set: (custkey, name, address, nationkey, acctbal)
DataSet<Tuple5<Integer, String, String, Integer, Double>> customers = getCustomerDataSet(env, params.get("customer"));
// get orders data set: (orderkey, custkey, orderdate)
DataSet<Tuple3<Integer, Integer, String>> orders = getOrdersDataSet(env, params.get("orders"));
// get lineitem data set: (orderkey, extendedprice, discount, returnflag)
DataSet<Tuple4<Integer, Double, Double, String>> lineitems = getLineitemDataSet(env, params.get("lineitem"));
// get nation data set: (nationkey, name)
DataSet<Tuple2<Integer, String>> nations = getNationsDataSet(env, params.get("nation"));
// 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(0, 1);
// lineitems filtered by flag: (orderkey, revenue)
DataSet<Tuple2<Integer, Double>> lineitemsFilteredByFlag = // filter by flag
lineitems.filter(lineitem -> lineitem.f3.equals("R")).map(lineitem -> new Tuple2<>(lineitem.f0, lineitem.f1 * (1 - lineitem.f2))).returns(// for lambda with generics
Types.TUPLE(Types.INT, Types.DOUBLE));
// join orders with lineitems: (custkey, revenue)
DataSet<Tuple2<Integer, Double>> revenueByCustomer = ordersFilteredByYear.joinWithHuge(lineitemsFilteredByFlag).where(0).equalTo(0).projectFirst(1).projectSecond(1);
revenueByCustomer = revenueByCustomer.groupBy(0).aggregate(Aggregations.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>> result = customerWithNation.join(revenueByCustomer).where(0).equalTo(0).projectFirst(0, 1, 2, 3, 4).projectSecond(1);
// emit result
if (params.has("output")) {
result.writeAsCsv(params.get("output"), "\n", "|");
// execute program
env.execute("TPCH Query 10 Example");
} else {
System.out.println("Printing result to stdout. Use --output to specify output path.");
result.print();
}
}
Aggregations