From 23c9b7fcaed816acda431ede9ae23c5027da4178 Mon Sep 17 00:00:00 2001 From: "J. Brisbin" Date: Tue, 23 Nov 2010 15:26:15 -0600 Subject: [PATCH] Tweaked Javadoc, spec for Map/Reduce --- .../datastore/riak/core/RiakTemplate.java | 27 +++++++++---------- .../riak/core/RiakTemplateSpec.groovy | 5 ++-- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/spring-datastore-riak/src/main/java/org/springframework/datastore/riak/core/RiakTemplate.java b/spring-datastore-riak/src/main/java/org/springframework/datastore/riak/core/RiakTemplate.java index e5ff6c24f..fdce5eec7 100644 --- a/spring-datastore-riak/src/main/java/org/springframework/datastore/riak/core/RiakTemplate.java +++ b/spring-datastore-riak/src/main/java/org/springframework/datastore/riak/core/RiakTemplate.java @@ -62,18 +62,17 @@ import java.util.regex.Pattern; /** * An implementation of {@link org.springframework.datastore.riak.core.KeyValueStoreOperations} - * and {@link org.springframework.datastore.riak.mapreduce.MapReduceOperations} - * for the Riak data store. + * and {@link org.springframework.datastore.riak.mapreduce.MapReduceOperations} for the Riak + * data store. *

- * To use the RiakTemplate, create a singleton in your Spring - * application-context.xml: + * To use the RiakTemplate, create a singleton in your Spring application-context.xml: *


  * <bean id="riak" class="org.springframework.datastore.riak.core.RiakTemplate"
  *     p:defaultUri="http://localhost:8098/riak/{bucket}/{key}"
  *     p:mapReduceUri="http://localhost:8098/mapred"/>
  * 
- * To store and retrieve objects in Riak, use the setXXX and getXXX methods - * (example in Groovy): + * To store and retrieve objects in Riak, use the setXXX and getXXX methods (example in + * Groovy): *

  * def obj = new TestObject(name: "My Name", age: 40)
  * riak.set([bucket: "mybucket", key: "mykey"], obj)
@@ -81,13 +80,13 @@ import java.util.regex.Pattern;
  * def name = riak.get([bucket: "mybucket", key: "mykey"]).name
  * println "Hello $name!"
  * 
- * You're key object should be one of: * * @author J. Brisbin */ @@ -141,7 +140,7 @@ public class RiakTemplate extends RestGatewaySupport implements KeyValueStoreOpe */ protected String mapReduceUri = "http://localhost:8098/mapred"; /** - * A list of resolvers to turn a single object into a {#link BucketKeyPair}. + * A list of resolvers to turn a single object into a {@link BucketKeyPair}. */ protected List bucketKeyResolvers; @@ -704,7 +703,7 @@ public class RiakTemplate extends RestGatewaySupport implements KeyValueStoreOpe BucketKeyPair bucketKeyPair; if (null != resolver) { bucketKeyPair = resolver.resolve(key); - if (null != val) { + if (null == bucketKeyPair.getBucket() && null != val) { Annotation meta = (val instanceof Class ? (Class) val : val.getClass()).getAnnotation( KeyValueStoreMetaData.class); if (null != meta) { diff --git a/spring-datastore-riak/src/test/groovy/org/springframework/datastore/riak/core/RiakTemplateSpec.groovy b/spring-datastore-riak/src/test/groovy/org/springframework/datastore/riak/core/RiakTemplateSpec.groovy index 76d74d083..764d1f4b4 100644 --- a/spring-datastore-riak/src/test/groovy/org/springframework/datastore/riak/core/RiakTemplateSpec.groovy +++ b/spring-datastore-riak/src/test/groovy/org/springframework/datastore/riak/core/RiakTemplateSpec.groovy @@ -160,10 +160,10 @@ class RiakTemplateSpec extends Specification { given: MapReduceJob job = riak.createMapReduceJob() - def mapJs = new JavascriptMapReduceOperation("function(v){ ejsLog('/tmp/mapred.log', 'map='+JSON.stringify(v)); var o=Riak.mapValuesJson(v); return [1]; }") + def mapJs = new JavascriptMapReduceOperation("function(v){ return [1]; }") def mapPhase = new RiakMapReducePhase("map", "javascript", mapJs) - def reduceJs = new JavascriptMapReduceOperation("function(v){ ejsLog('/tmp/mapred.log', 'reduce='+JSON.stringify(v)); return [v.length]; }") + def reduceJs = new JavascriptMapReduceOperation("function(v){ return [v.length]; }") def reducePhase = new RiakMapReducePhase("reduce", "javascript", reduceJs) job.addInputs(["test"]). @@ -171,7 +171,6 @@ class RiakTemplateSpec extends Specification { addPhase(reducePhase) when: - println "M/R: ${job.toJson()}" def result = riak.execute(job, List) then: