Skip to content

Commit

Permalink
Don't calculate indexing stats if we're not indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
drewr committed Sep 16, 2015
1 parent f6f64b5 commit 50bf1cd
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/stream2es/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,21 @@
(let [bulk-bytes (reduce + (map #(get-in % [:meta :_bytes]) bulk))
errors (when (:indexing @state)
(es/error-capturing-bulk (:target @state) bulk
make-indexable-bulk))]
make-indexable-bulk)
(dosync
(alter state update-in [:total :indexed :docs]
+ (count bulk))
(alter state update-in [:total :indexed :bytes]
+ bulk-bytes)
(alter state update-in [:total :indexed :wire-bytes]
+ idxbulkbytes))
(log/trace "adding indexed total"
(get-in @state [:total :indexed :docs])
"+" (count bulk)))]
(dosync
(alter state update-in [:total :indexed :docs] + (count bulk))
(alter state update-in [:total :indexed :bytes] + bulk-bytes)
(alter state update-in [:total :indexed :wire-bytes]
+ idxbulkbytes)
(alter state update-in [:total :errors] (fnil + 0) (or errors 0)))
(alter state update-in [:total :errors]
(fnil + 0) (or errors 0)))
(index-status first-id (count bulk) idxbulkbytes state))
(log/trace "adding indexed total"
(get-in @state [:total :indexed :docs])
"+" (count bulk))
(when (:tee-bulk @state)
(spit-mkdirs
(:tee-bulk @state) (str first-id ".bulk") idxbulk))
Expand Down

0 comments on commit 50bf1cd

Please sign in to comment.