Package eu.stratosphere.api.java.record.operators

Examples of eu.stratosphere.api.java.record.operators.ReduceOperator


    BulkIteration iteration = new BulkIteration("Loop");
    iteration.setInput(initialInput);
    iteration.setMaximumNumberOfIterations(5);
    Assert.assertTrue(iteration.getMaximumNumberOfIterations() > 1);

    ReduceOperator sumReduce = ReduceOperator.builder(new SumReducer())
        .input(iteration.getPartialSolution())
        .name("Compute sum (Reduce)")
        .build();
   
    iteration.setNextPartialSolution(sumReduce);
View Full Code Here


    String edgeInput = (args.length > 1 ? args[1] : "");
    String output    = (args.length > 2 ? args[2] : "");

    FileDataSource edges = new FileDataSource(new EdgeInFormat(), edgeInput, "BTC Edges");
   
    ReduceOperator buildTriads = ReduceOperator.builder(new BuildTriads(), StringValue.class, 0)
      .name("Build Triads")
      .build();

    JoinOperator closeTriads = JoinOperator.builder(new CloseTriads(), StringValue.class, 1, 0)
      .keyField(StringValue.class, 2, 1)
      .name("Close Triads")
      .build();
    closeTriads.setParameter("INPUT_LEFT_SHIP_STRATEGY", "SHIP_REPARTITION_HASH");
    closeTriads.setParameter("INPUT_RIGHT_SHIP_STRATEGY", "SHIP_REPARTITION_HASH");
    closeTriads.setParameter("LOCAL_STRATEGY", "LOCAL_STRATEGY_HASH_BUILD_SECOND");

    FileDataSink triangles = new FileDataSink(new CsvOutputFormat(), output, "Output");
    CsvOutputFormat.configureRecordFormat(triangles)
      .recordDelimiter('\n')
      .fieldDelimiter(' ')
      .field(StringValue.class, 0)
      .field(StringValue.class, 1)
      .field(StringValue.class, 2);

    triangles.setInput(closeTriads);
    closeTriads.setSecondInput(edges);
    closeTriads.setFirstInput(buildTriads);
    buildTriads.setInput(edges);

    Plan plan = new Plan(triangles, "Enumerate Triangles");
    plan.setDefaultParallelism(numSubTasks);
    return plan;
  }
View Full Code Here

    // create DataSourceContract for Orders input
    @SuppressWarnings("unchecked")
    CsvInputFormat format1 = new CsvInputFormat('|', IntValue.class, IntValue.class);
    FileDataSource input1 = new FileDataSource(format1, input1Path, "Input 1");
   
    ReduceOperator aggInput1 = ReduceOperator.builder(DummyReduce.class, IntValue.class, 0)
      .input(input1)
      .name("AggOrders")
      .build();

   
    // create DataSourceContract for Orders input
    @SuppressWarnings("unchecked")
    CsvInputFormat format2 = new CsvInputFormat('|', IntValue.class, IntValue.class);
    FileDataSource input2 = new FileDataSource(format2, input2Path, "Input 2");
    input2.setDegreeOfParallelism(numSubtasksInput2);

    ReduceOperator aggInput2 = ReduceOperator.builder(DummyReduce.class, IntValue.class, 0)
      .input(input2)
      .name("AggLines")
      .build();
    aggInput2.setDegreeOfParallelism(numSubtasksInput2);
   
    // create JoinOperator for joining Orders and LineItems
    JoinOperator joinLiO = JoinOperator.builder(JoinInputs.class, IntValue.class, 0, 0)
      .input1(aggInput1)
      .input2(aggInput2)
View Full Code Here

        BulkIteration iteration = new BulkIteration("Loop");
        iteration.setInput(initialInput);
        iteration.setMaximumNumberOfIterations(2);

        ReduceOperator dummyReduce = ReduceOperator.builder(new DummyReducer(), IntValue.class, 0)
                .input(iteration.getPartialSolution())
                .name("Reduce something")
                .build();

View Full Code Here

      .field(IntValue.class, 1)
      .field(DoubleValue.class, 2);
   
    // create ReduceOperator for aggregating the result
    // the reducer has a composite key, consisting of the fields 0 and 1
    @SuppressWarnings("unchecked")
    ReduceOperator aggLiO = ReduceOperator.builder(new AggLiO())
      .keyField(LongValue.class, 0)
      .keyField(StringValue.class, 1)
      .input(joinLiO, partJoin2, partJoin1)
      .name("AggLio")
View Full Code Here

    JoinOperator joinNCOL = JoinOperator.builder(JoinNCOL.class, IntValue.class, 4, 0)
      .name("JoinNCOL")
      .build();

    ReduceOperator reduce = ReduceOperator.builder(Sum.class)
      .keyField(IntValue.class, 0)
      .keyField(StringValue.class, 1)
      .keyField(StringValue.class, 3)
      .keyField(StringValue.class, 4)
      .keyField(StringValue.class, 5)
      .keyField(StringValue.class, 6)
      .keyField(StringValue.class, 7)
      .name("Reduce")
      .build();

    FileDataSink result = new FileDataSink(new TupleOutputFormat(), resultPath, "Output");

    result.setInput(reduce);
   
    reduce.setInput(joinNCOL);
   
    joinNCOL.setFirstInput(joinCOL);
    joinNCOL.setSecondInput(projectN);
   
    joinCOL.setFirstInput(projectC);
View Full Code Here

        .input2(edges)
        .name("Join Candidate Id With Neighbor")
        .build();

    // find for each neighbor the smallest of all candidates
    ReduceOperator minCandidateId = ReduceOperator.builder(new MinimumComponentIDReduce(), LongValue.class, 0)
        .input(joinWithNeighbors)
        .name("Find Minimum Candidate Id")
        .build();
   
    // join candidates with the solution set and update if the candidate component-id is smaller
View Full Code Here

    FileDataSource source = new FileDataSource(new TextInputFormat(), dataInput, "Input Lines");

    MapOperator mapper = MapOperator.builder(new TokenizeLine()).input(source).name("Tokenize Lines").build();
   
    ReduceOperator reducer = ReduceOperator.builder(CountWords.class, StringValue.class, 0).input(mapper)
        .name("Count Words").build();
   
    FileDataSink out = new FileDataSink(new CsvOutputFormat(), output, reducer, "Word Counts");
   
    CsvOutputFormat.configureRecordFormat(out).recordDelimiter('\n')
View Full Code Here

        new ContractITCaseInputFormat(), inPath);
    DelimitedInputFormat.configureDelimitedFormat(input)
      .recordDelimiter('\n');
    input.setDegreeOfParallelism(config.getInteger("ReduceTest#NoSubtasks", 1));

    ReduceOperator testReducer = ReduceOperator.builder(new TestReducer(), StringValue.class, 0)
      .build();
    testReducer.setDegreeOfParallelism(config.getInteger("ReduceTest#NoSubtasks", 1));
    testReducer.getParameters().setString(PactCompiler.HINT_LOCAL_STRATEGY,
        config.getString("ReduceTest#LocalStrategy", ""));
    testReducer.getParameters().setString(PactCompiler.HINT_SHIP_STRATEGY,
        config.getString("ReduceTest#ShipStrategy", ""));

    FileDataSink output = new FileDataSink(
        new ContractITCaseOutputFormat(), resultPath);
    output.setDegreeOfParallelism(1);

    output.setInput(testReducer);
    testReducer.setInput(input);

    Plan plan = new Plan(output);

    PactCompiler pc = new PactCompiler(new DataStatistics());
    OptimizedPlan op = pc.compile(plan);
View Full Code Here

      JoinOperator.builder(PartListJoin.class, IntValue.class , 0, 0)
      .name("partlistJoin")
      .build();

    /* Aggregate sum(amount) by (nation,year): */
    ReduceOperator sumAmountAggregate =
      ReduceOperator.builder(AmountAggregate.class, StringIntPair.class, 0)
      .name("groupyBy")
      .build();

    /* Connect input filters: */
    filterPart.setInput(partInput);
    mapPartsupp.setInput(partSuppInput);
    mapOrder.setInput(ordersInput);
    mapLineItem.setInput(lineItemInput);
    mapSupplier.setInput(supplierInput);

    /* Connect equijoins: */
    partsJoin.setFirstInput(filterPart);
    partsJoin.setSecondInput(mapPartsupp);
    orderedPartsJoin.setFirstInput(mapOrder);
    orderedPartsJoin.setSecondInput(mapLineItem);
    suppliersJoin.setFirstInput(mapSupplier);
    suppliersJoin.setSecondInput(nationInput);
    filteredPartsJoin.setFirstInput(partsJoin);
    filteredPartsJoin.setSecondInput(orderedPartsJoin);
    partListJoin.setFirstInput(filteredPartsJoin);
    partListJoin.setSecondInput(suppliersJoin);

    /* Connect aggregate: */
    sumAmountAggregate.setInput(partListJoin);

    /* Connect sink: */
    FileDataSink result = new FileDataSink(new StringIntPairStringDataOutFormat(), this.outputPath, "Results sink");
    result.setInput(sumAmountAggregate);

View Full Code Here

TOP

Related Classes of eu.stratosphere.api.java.record.operators.ReduceOperator

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.