Search in sources :

Example 11 with Tuple6

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);
}
Also used : lombok.val(lombok.val) Tuple6(org.apache.flink.api.java.tuple.Tuple6)

Example 12 with Tuple6

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);
}
Also used : Tuple5(org.apache.flink.api.java.tuple.Tuple5) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Tuple6(org.apache.flink.api.java.tuple.Tuple6) Tuple3(org.apache.flink.api.java.tuple.Tuple3) Test(org.junit.Test)

Example 13 with Tuple6

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);
}
Also used : lombok.val(lombok.val) Tuple6(org.apache.flink.api.java.tuple.Tuple6)

Example 14 with Tuple6

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);
}
Also used : lombok.val(lombok.val) Tuple6(org.apache.flink.api.java.tuple.Tuple6)

Example 15 with Tuple6

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();
    }
}
Also used : ParameterTool(org.apache.flink.api.java.utils.ParameterTool) Types(org.apache.flink.api.common.typeinfo.Types) ParameterTool(org.apache.flink.api.java.utils.ParameterTool) DataSet(org.apache.flink.api.java.DataSet) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Tuple3(org.apache.flink.api.java.tuple.Tuple3) Tuple2(org.apache.flink.api.java.tuple.Tuple2) Tuple5(org.apache.flink.api.java.tuple.Tuple5) Tuple4(org.apache.flink.api.java.tuple.Tuple4) Aggregations(org.apache.flink.api.java.aggregation.Aggregations) Tuple6(org.apache.flink.api.java.tuple.Tuple6) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Tuple4(org.apache.flink.api.java.tuple.Tuple4) Tuple5(org.apache.flink.api.java.tuple.Tuple5) Tuple6(org.apache.flink.api.java.tuple.Tuple6) Tuple2(org.apache.flink.api.java.tuple.Tuple2) Tuple3(org.apache.flink.api.java.tuple.Tuple3)

Aggregations

Tuple6 (org.apache.flink.api.java.tuple.Tuple6)25 Test (org.junit.Test)20 CompletableFuture (java.util.concurrent.CompletableFuture)11 JobID (org.apache.flink.api.common.JobID)11 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)11 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)11 ResourceProfile (org.apache.flink.runtime.clusterframework.types.ResourceProfile)11 SlotID (org.apache.flink.runtime.clusterframework.types.SlotID)11 Acknowledge (org.apache.flink.runtime.messages.Acknowledge)11 ResourceManagerId (org.apache.flink.runtime.resourcemanager.ResourceManagerId)11 TaskExecutorConnection (org.apache.flink.runtime.resourcemanager.registration.TaskExecutorConnection)11 ResourceRequirement (org.apache.flink.runtime.slots.ResourceRequirement)11 SlotReport (org.apache.flink.runtime.taskexecutor.SlotReport)11 TestingTaskExecutorGatewayBuilder (org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGatewayBuilder)11 Matchers.empty (org.hamcrest.Matchers.empty)11 Assert.assertFalse (org.junit.Assert.assertFalse)11 Assert.assertThat (org.junit.Assert.assertThat)11 ArrayList (java.util.ArrayList)10 List (java.util.List)10 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)10