Skip to content
Browse files

added links to sumo.client/get, built link-to-map/map-to-link, moved …

…link building to map-to-riak-object
  • Loading branch information...
1 parent 46925cb commit 6f239d51147afb0478c54df08446dd940efc30ce @jmshoffs0812 jmshoffs0812 committed Feb 15, 2012
Showing with 13 additions and 7 deletions.
  1. +1 −1 src/sumo/client.clj
  2. +12 −6 src/sumo/internal.clj
2 src/sumo/client.clj
@@ -87,7 +87,7 @@
"Store an object into Riak.
Usage looks like:
(sumo.client/put client \"bucket\" \"key\" {:content-type \"text/plain\" :value \"hello!\"})"
- (let [new-obj (assoc obj :value (serialize obj) :links (i/build-links obj))
+ (let [new-obj (assoc obj :value (serialize obj))
results (put-raw client bucket key new-obj (or (first options) {}))]
(for [r results]
(assoc r :value (deserialize r)))))
18 src/sumo/internal.clj
@@ -63,12 +63,17 @@
(reduce step {} indexes)))
-(defn build-links
- "Convert a map's collection of link-shaped maps into RiakLinks"
- [obj]
- (map #(let [{:keys [bucket key tag]} %] (RiakLink. bucket key tag)) (:links obj)))
+(defn map-to-link
+ "Converts a link-shaped map into a RiakLink"
+ [link-map]
+ (let [{:keys [bucket key tag]} link-map] (RiakLink. bucket key tag)))
+(defn link-to-map
+ "Converts a RiakLink into a generic map"
+ [^RiakLink link]
+ {:bucket (.getBucket link)
+ :key (.getKey link)
+ :tag (.getTag link)})
(defn riak-object-to-map
"Turn an IRiakObject implementation into
@@ -79,6 +84,7 @@
:vtag (.getVtag riak-object)
:last-modified (.getLastModified riak-object)
:metadata (into {} (.getMeta riak-object))
+ :links (map link-to-map (.getLinks riak-object))
:value (.getValue riak-object)
:indexes (riak-indexes-to-map
(concat (seq (.allBinIndexes riak-object))
@@ -90,7 +96,7 @@
[bucket key {:keys [value content-type links metadata indexes vector-clock]}]
(let [^RiakObjectBuilder riak-object (-> ^RiakObjectBuilder (RiakObjectBuilder/newBuilder bucket key)
(.withValue value)
- (.withLinks links)
+ (.withLinks (map map-to-link links))
(.withContentType (or content-type "application/json"))
(.withUsermeta (or metadata {})))]
(doseq [[index-name index-seq] indexes

0 comments on commit 6f239d5

Please sign in to comment.
Something went wrong with that request. Please try again.