 
   Ref. http://goo.gl/XfGKW for query+scan best practices."
   [creds table
-   & [{:keys [attr-conds last-prim-kvs max-reqs return limit total-segments
+   & [{:keys [attr-conds last-prim-kvs span-reqs return limit total-segments
               segment return-cc?] :as opts
-       :or   {max-reqs 5}}]]
+       :or   {span-reqs {:max 5}}}]]
   (letfn [(run1 [last-prim-kvs]
             (as-map
              (.scan (db-client creds)

(defn- merge-more
  "Enables auto paging for batch batch-get/write and query/scan requests.
  Particularly useful for throughput limitations."
  ;; TODO Add rate-limiting opt merge-more rate-limiting http://goo.gl/i9YxM
  ;; Perhaps change :max-reqs opt to -> :multi-reqs {:max _ :throttle-ms _}?
  [more-f max-idx last-result]
  (loop [{:keys [unprocessed last-prim-kvs] :as last-result} last-result idx 1]
    (let [more (or unprocessed last-prim-kvs)]
      (if (or (empty? more) (>= idx max-idx))
        (if-let [items (:items last-result)]
          (with-meta items (dissoc last-result :items))
          last-result)
        (let [merge-results (fn [l r] (cond (number? l) (+    l r)
                                           (vector? l) (into l r)
                                           :else               r))]
          (recur (merge-with merge-results last-result (more-f more))
                 (inc idx)))))))


     :friends {:prim-kvs [{:catagory \"favorites\" :id [1 2 3]}
                          {:catagory \"recent\"    :id [7 8 9]}]}})

  :span-reqs - {:max _ :throttle-ms _} allows a number of requests to
  automatically be stitched together (to exceed throughput limits, for example)."
  [creds requests & [{:keys [return-cc? span-reqs] :as opts
                      :or   {span-reqs {:max 5}}}]]
  (letfn [(run1 [raw-req]
            (as-map
             (.batchGetItem (db-client creds)
               (doto-maybe (BatchGetItemRequest.) g ; {table-str KeysAndAttributes}
                 :always    (.setRequestItems raw-req)
                 return-cc? (.setReturnConsumedCapacity (utils/enum :total))))))]
    (merge-more run1 span-reqs (run1 (batch-request-items requests)))))

(comment
  (def bigval (.getBytes (apply str (range 14000))))
