Package org.springframework.data.mongodb.core.mapreduce

Examples of org.springframework.data.mongodb.core.mapreduce.MapReduceOptions


  public void testIssue260() {
    createContentAndVersionData();
    String map = "function () { emit(this.document_id, this.version); }";
    String reduce = "function (key, values) { return Math.max.apply(Math, values); }";
    MapReduceResults<ContentAndVersion> results = mongoTemplate.mapReduce("jmr2", map, reduce,
        new MapReduceOptions().outputCollection("jmr2_out"), ContentAndVersion.class);

    int size = 0;
    for (ContentAndVersion cv : results) {
      if (cv.getId().equals("Resume")) {
        assertEquals(6, cv.getValue().longValue());
View Full Code Here


  public void testIssue260Part2() {
    createNumberAndVersionData();
    String map = "function () { emit(this.number, this.version); }";
    String reduce = "function (key, values) { return Math.max.apply(Math, values); }";
    MapReduceResults<NumberAndVersion> results = mongoTemplate.mapReduce("jmr2", map, reduce,
        new MapReduceOptions().outputCollection("jmr2_out"), NumberAndVersion.class);
    int size = 0;
    for (NumberAndVersion nv : results) {
      if (nv.getId().equals("1")) {
        assertEquals(2, nv.getValue().longValue());
      }
View Full Code Here

    scopeVariables.put("exclude", "a");

    String mapWithExcludeFunction = "function(){ for ( var i=0; i<this.x.length; i++ ){ if(this.x[i] != exclude) emit( this.x[i] , 1 ); } }";

    MapReduceResults<ValueObject> results = mongoTemplate.mapReduce("jmr1", mapWithExcludeFunction, reduceFunction,
        new MapReduceOptions().scopeVariables(scopeVariables).outputTypeInline(), ValueObject.class);
    Map<String, Float> m = copyToMap(results);
    assertEquals(3, m.size());
    assertEquals(2, m.get("b").intValue());
    assertEquals(2, m.get("c").intValue());
    assertEquals(1, m.get("d").intValue());
View Full Code Here

      if (withQuery) {
        results = mongoTemplate.mapReduce(new Query(), "jmr1", mapFunction, reduceFunction,
            options().outputCollection("jmr1_out"), ValueObject.class);
      } else {
        results = mongoTemplate.mapReduce("jmr1", mapFunction, reduceFunction,
            new MapReduceOptions().outputCollection("jmr1_out"), ValueObject.class);
      }
    }
    Map<String, Float> m = copyToMap(results);
    assertMapReduceResults(m);
  }
View Full Code Here

        entityClass), collectionName);
  }

  public <T> MapReduceResults<T> mapReduce(String inputCollectionName, String mapFunction, String reduceFunction,
      Class<T> entityClass) {
    return mapReduce(null, inputCollectionName, mapFunction, reduceFunction, new MapReduceOptions().outputTypeInline(),
        entityClass);
  }
View Full Code Here

  }

  public <T> MapReduceResults<T> mapReduce(Query query, String inputCollectionName, String mapFunction,
      String reduceFunction, Class<T> entityClass) {
    return mapReduce(query, inputCollectionName, mapFunction, reduceFunction,
        new MapReduceOptions().outputTypeInline(), entityClass);
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.mongodb.core.mapreduce.MapReduceOptions

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.