Skip to content

Commit

Permalink
switch lazyseq to iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
ereteog committed Sep 18, 2024
1 parent 3fbc4ef commit 92fdde6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/ctia/task/migration/migrate_es_stores.clj
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,14 @@
:documents data
:search_after next-search-after)))))

(s/defn read-source ;; WARNING: defining schema output breaks lazyness
(s/defn read-source
"returns a lazy-seq of batch from source store"
[read-params :- (s/maybe BatchParams)]
(lazy-seq
(when-let [batch (read-source-batch read-params)]
(cons batch (read-source (dissoc batch :documents))))))
(iteration read-source-batch
:vf identity
:initk read-params
:kf #(dissoc % :documents)
:somef seq))

(s/defn write-target :- s/Int
"This function writes a batch of documents which are (1) modified with `migrations` functions,
Expand Down
3 changes: 2 additions & 1 deletion src/ctia/task/migration/store.clj
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ Rollover requires refresh so we cannot just call ES with condition since refresh
{"id" sort-order})
params
(merge
{:offset (or offset 0)
{:track_total_hits true
:offset (or offset 0)
:limit batch-size}
(when sort-order
{:sort sort-by})
Expand Down

0 comments on commit 92fdde6

Please sign in to comment.