Examples of MapReduce


Examples of co.cask.cdap.api.mapreduce.MapReduce

                                ? Long.parseLong(arguments
                                                   .getOption(ProgramOptionConstants.LOGICAL_START_TIME))
                                : System.currentTimeMillis();

    String workflowBatch = arguments.getOption(ProgramOptionConstants.WORKFLOW_BATCH);
    MapReduce mapReduce;
    try {
      mapReduce = new InstantiatorFactory(false).get(TypeToken.of(program.<MapReduce>getMainClass())).create();
    } catch (Exception e) {
      LOG.error("Failed to instantiate MapReduce class for {}", spec.getClassName(), e);
      throw Throwables.propagate(e);
    }

    final BasicMapReduceContext context =
      new BasicMapReduceContext(program, null, runId, options.getUserArguments(),
                                program.getSpecification().getDatasets().keySet(), spec,
                                logicalStartTime,
                                workflowBatch, discoveryServiceClient, metricsCollectionService,
                                datasetFramework, cConf);


    Reflections.visit(mapReduce, TypeToken.of(mapReduce.getClass()),
                      new PropertyFieldSetter(context.getSpecification().getProperties()),
                      new DataSetFieldSetter(context));

    // note: this sets logging context on the thread level
    LoggingContextAccessor.setLoggingContext(context.getLoggingContext());
View Full Code Here

Examples of com.basho.riak.client.api.commands.mapreduce.MapReduce

  private void JsBucketKeyMR(String bucketType) throws InterruptedException, ExecutionException, IOException
  {
    initValues(bucketType);
       
        Namespace ns = new Namespace(bucketType, mrBucket);
    MapReduce mr = new BucketKeyMapReduce.Builder()
        .withLocation(new Location(ns, "p1"))
        .withLocation(new Location(ns, "p2"))
        .withLocation(new Location(ns, "p3"))
        .withMapPhase(Function.newAnonymousJsFunction(
            "function(v, key_data) {" +
View Full Code Here

Examples of com.basho.riak.client.api.commands.mapreduce.MapReduce

    private void erlangBucketKeyMR(String bucketType) throws ExecutionException, InterruptedException
    {
        initValues(bucketType);
        Namespace ns = new Namespace(bucketType, mrBucket);
       
        MapReduce mr = new BucketKeyMapReduce.Builder()
        .withLocation(new Location(ns, "p1"))
        .withLocation(new Location(ns, "p2"))
        .withLocation(new Location(ns, "p3"))
                .withMapPhase(Function.newErlangFunction("riak_kv_mapreduce", "map_object_value"), false)
                .withReducePhase(Function.newErlangFunction("riak_kv_mapreduce","reduce_sort"), true)
View Full Code Here

Examples of com.basho.riak.client.query.MapReduce

     * @see
     * com.basho.riak.client.raw.RawClient#fetchIndex(com.basho.riak.client.
     * raw.query.IndexQuery)
     */
    public List<String> fetchIndex(IndexQuery indexQuery) throws IOException {
        final MapReduce mr = new IndexMapReduce(this, indexQuery);

        mr.addReducePhase(NamedErlangFunction.REDUCE_IDENTITY, new Object() {
            @Override public String toString() {
                return "{reduce_phase_only_1, true}";
            }

        });
        // only return the key, to match the http rest api
        mr.addReducePhase(new JSSourceFunction("function(v) { return v.map(function(e) { return e[1]; }); }"));

        try {
            MapReduceResult result = mr.execute();
            return new ArrayList<String>(result.getResult(String.class));
        } catch (RiakException e) {
            throw new IOException(e);
        }
    }
View Full Code Here

Examples of com.basho.riak.client.query.MapReduce

     * @see
     * com.basho.riak.client.raw.RawClient#fetchIndex(com.basho.riak.client.
     * raw.query.IndexQuery)
     */
    public List<String> fetchIndex(IndexQuery indexQuery) throws IOException {
        final MapReduce mr = new IndexMapReduce(this, indexQuery);

        mr.addReducePhase(NamedErlangFunction.REDUCE_IDENTITY, Args.REDUCE_PHASE_ONLY_1);
        // only return the key, to match the http rest api
        mr.addReducePhase(new JSSourceFunction("function(v) { return v.map(function(e) { return e[1]; }); }"), Args.REDUCE_PHASE_ONLY_1);

        try {
            MapReduceResult result = mr.execute();
            return new ArrayList<String>(result.getResult(String.class));
        } catch (RiakException e) {
            throw new IOException(e);
        }
    }
View Full Code Here

Examples of com.basho.riak.client.query.MapReduce

     * @see
     * com.basho.riak.client.raw.RawClient#fetchIndex(com.basho.riak.client.
     * raw.query.IndexQuery)
     */
    public List<String> fetchIndex(IndexQuery indexQuery) throws IOException {
        final MapReduce mr = new IndexMapReduce(this, indexQuery);

        mr.addReducePhase(NamedErlangFunction.REDUCE_IDENTITY, new Object() {
            @Override public String toString() {
                return "{reduce_phase_only_1, true}";
            }

        });
        // only return the key, to match the http rest api
        mr.addReducePhase(new JSSourceFunction("function(v) { return v.map(function(e) { return e[1]; }); }"));

        try {
            MapReduceResult result = mr.execute();
            return new ArrayList<String>(result.getResult(String.class));
        } catch (RiakException e) {
            throw new IOException(e);
        }
    }
View Full Code Here

Examples of com.basho.riak.client.query.MapReduce

     * @see
     * com.basho.riak.client.raw.RawClient#fetchIndex(com.basho.riak.client.
     * raw.query.IndexQuery)
     */
    public List<String> fetchIndex(IndexQuery indexQuery) throws IOException {
        final MapReduce mr = new IndexMapReduce(this, indexQuery);

        mr.addReducePhase(NamedErlangFunction.REDUCE_IDENTITY, Args.REDUCE_PHASE_ONLY_1);
        // only return the key, to match the http rest api
        mr.addReducePhase(new JSSourceFunction("function(v) { return v.map(function(e) { return e[1]; }); }"), Args.REDUCE_PHASE_ONLY_1);

        try {
            MapReduceResult result = mr.execute();
            return new ArrayList<String>(result.getResult(String.class));
        } catch (RiakException e) {
            throw new IOException(e);
        }
    }
View Full Code Here

Examples of com.impetus.client.couchdb.CouchDBDesignDocument.MapReduce

     */
    static void createView(Map<String, MapReduce> views, String columnName, List<String> columns)
    {
        Iterator<String> iterator = columns.iterator();

        MapReduce mapr = new MapReduce();
        StringBuilder mapBuilder = new StringBuilder();
        StringBuilder ifBuilder = new StringBuilder("function(doc){if(");
        StringBuilder emitFunction = new StringBuilder("{emit(");
        if (columns != null && columns.size() > 1)
        {
            emitFunction.append("[");
        }
        while (iterator.hasNext())
        {
            String nextToken = iterator.next();
            ifBuilder.append("doc." + nextToken);
            ifBuilder.append(" && ");
            emitFunction.append("doc." + nextToken);
            emitFunction.append(",");
        }
        ifBuilder.delete(ifBuilder.toString().lastIndexOf(" && "), ifBuilder.toString().lastIndexOf(" && ") + 3);
        emitFunction.deleteCharAt(emitFunction.toString().lastIndexOf(","));

        ifBuilder.append(")");
        if (columns != null && columns.size() > 1)
        {
            emitFunction.append("]");
        }
        emitFunction.append(", doc)}}");

        mapBuilder.append(ifBuilder.toString()).append(emitFunction.toString());

        mapr.setMap(mapBuilder.toString());
        views.put(columnName, mapr);
    }
View Full Code Here

Examples of com.impetus.client.couchdb.CouchDBDesignDocument.MapReduce

     * @param views
     * @param columnName
     */
    private void createView(Map<String, MapReduce> views, String columnName)
    {
        MapReduce mapr = new MapReduce();
        mapr.setMap("function(doc){if(doc." + columnName + "){emit(doc." + columnName + ", doc);}}");
        views.put(columnName, mapr);
    }
View Full Code Here

Examples of com.impetus.client.couchdb.CouchDBDesignDocument.MapReduce

     * @param tableInfo
     * @param views
     */
    private void createViewForSelectAll(TableInfo tableInfo, Map<String, MapReduce> views)
    {
        MapReduce mapr = new MapReduce();
        mapr.setMap("function(doc){if(doc." + tableInfo.getIdColumnName() + "){emit(null, doc);}}");
        views.put("all", mapr);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.