Package com.mongodb

Examples of com.mongodb.MapReduceOutput


    String r = "function(k, vals) {var result = {target: k, logIds: []}; vals.forEach(function(value) { result.logIds.push(value)}); return result;}";
    DBObject filter = new BasicDBObject();
    if(targetID != null) {
      filter.put("targetId", targetID);
    }
    MapReduceOutput mapReduce = collection.mapReduce(m, r, null, OutputType.INLINE, filter);
    Iterator<DBObject> iterator = mapReduce.results().iterator();
   
    List<LogDescriptor> descriptors = new ArrayList<LogDescriptor>();
    while(iterator.hasNext()) {
      DBObject row = iterator.next();
      DBObject value = (DBObject)row.get("value");
View Full Code Here


        String r = "function(k, vals) {var result = {target: k, logIds: []}; vals.forEach(function(value) { result.logIds.push(value)}); return result;}";
        DBObject filter = new BasicDBObject();
        if (targetID != null) {
            filter.put("targetId", targetID);
        }
        MapReduceOutput mapReduce = collection.mapReduce(m, r, null, OutputType.INLINE, filter);
        Iterator<DBObject> iterator = mapReduce.results().iterator();

        List<Descriptor> descriptors = new ArrayList<Descriptor>();
        while (iterator.hasNext()) {
            DBObject row = iterator.next();
            DBObject value = (DBObject) row.get("value");
View Full Code Here

 
      String outCollection = new StringBuilder(uuid).append("_AggregationUtils").toString();
 
      BasicDBObject mrQuery = new BasicDBObject(DocumentPojo.url_, uuid);
     
      @SuppressWarnings("unused")
      MapReduceOutput res =
        DbManager.getDocument().getMetadata().mapReduce(mapScript, reduceScript, outCollection, OutputType.REPLACE, mrQuery);

    }
    catch (Exception e) { // (These should never be runtime failures, all I/O is vs files embedded at compile-time)
View Full Code Here

                    return res;
                }

                res = col.getDB().command(cmdobj);
                res.throwOnError();
                output = new MapReduceOutput(col, cmdobj, res);
                return output;
            }

            @Override
            public void wrapUp(Object res) {
View Full Code Here

            cmd.setSort(q.getSortObject());

        if (log.isTraceEnabled())
            log.info("Executing " + cmd.toString());

        MapReduceOutput mpo = dbColl.mapReduce(baseCommand);
        MapreduceResults mrRes = (MapreduceResults) mapr.fromDBObject(MapreduceResults.class, mpo.getRaw(), createCache());

        QueryImpl baseQ = null;
        if (!MapreduceType.INLINE.equals(type))
            baseQ = new QueryImpl(outputType, db.getCollection(mrRes.getOutputCollectionName()), this);
        //TODO Handle inline case and create an iterator/able.
View Full Code Here

    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("MapReduce command result = [{}]", serializeToJsonSafely(commandObject));
    }

    MapReduceOutput mapReduceOutput = new MapReduceOutput(inputCollection, commandObject, commandResult);
    List<T> mappedResults = new ArrayList<T>();
    DbObjectCallback<T> callback = new ReadDbObjectCallback<T>(mongoConverter, entityClass);

    for (DBObject dbObject : mapReduceOutput.results()) {
      mappedResults.add(callback.doWith(dbObject));
    }

    return new MapReduceResults<T>(mappedResults, commandResult);
  }
View Full Code Here

        + "function(category){emit(category, {count:1});}" + ");"
        + "};";
    String reduce = "function(key, values){" + "var sum = 0;"
        + "for(var i=0;i<values.length;i++)"
        + "sum += values[i].count;" + "return {count: sum};" + "};";
    MapReduceOutput output = collection.mapReduce(map, reduce, null,
        MapReduceCommand.OutputType.INLINE, null);
    List<DBObject> result = Lists.newArrayList(output.results());
    Collections.sort(result, bookComparator);

    assertThat((String) result.get(0).get("_id"), equalTo("crime"));
    DBObject count1 = (DBObject) result.get(0).get("value");
    assertThat((Double) count1.get("count"), equalTo(1.0D));
View Full Code Here

            String reduce = "function (key, values) { return Array.sum( values ) }";

            MapReduceCommand cmd = new MapReduceCommand(mongoCollection, map, reduce, outputCollection,
                    MapReduceCommand.OutputType.REPLACE, null);

            MapReduceOutput out = mongoCollection.mapReduce(cmd);
            logger.debug("MapReduceOutput: {}", out);
            Thread.sleep(wait);
            refreshIndex();
            assertThat(executableType.name() + " outputCollection is indexed",
                    getNode().client().admin().indices().prepareTypesExists(getIndex()).setTypes(outputCollection).get().isExists(),
View Full Code Here

TOP

Related Classes of com.mongodb.MapReduceOutput

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.