Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 17th, 2012  |  syntax: None  |  size: 0.44 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. (defn m-seq
  2.   "a lazy seq of rows from a table. rows are fetched in batches of batch-size, which defaults to 1000"
  3.   ([table] (m-seq 1000 table))
  4.   ([batch-size table]
  5.      (flatten
  6.       (take-while #(> (count %) 0)
  7.                   (map (fn [offset] @(-> table
  8.                                          (cql/drop offset)
  9.                                          (cql/take batch-size)))
  10.                        (iterate (partial + batch-size) 0))))))