From: Christopher Date: Sun, 8 Mar 2020 20:55:54 +0000 (-0500) Subject: add batch logic back, not the issue X-Git-Url: http://git.entropealabs.com/?a=commitdiff_plain;h=cd13b55a06fdc8be2fa05d7ebac886febb72e264;p=cluster_kv.git add batch logic back, not the issue --- diff --git a/lib/cluster_kv/db.ex b/lib/cluster_kv/db.ex index ffcafe3..a512987 100644 --- a/lib/cluster_kv/db.ex +++ b/lib/cluster_kv/db.ex @@ -81,25 +81,20 @@ defmodule ClusterKV.DB do end defp handle_next_batch_chunk(db, batch, _chunk, _last_batch, fun) do - Enum.each(batch, fn {k, v} -> + batch + |> Enum.slice(last_batch, chunk) + |> Enum.each(fn {k, v} -> do_upsert(db, k, v, fun) end) - {[], 0} - # batch - # |> Enum.slice(last_batch, chunk) - # |> Enum.each(fn {k, v} -> - # do_upsert(db, k, v, fun) - # end) - - # case last_batch + chunk do - # lb when lb > length(batch) -> - # {[], 0} - # - # lb -> - # Process.send_after(self(), :process_batch, 0) - # {batch, lb} - # end + case last_batch + chunk do + lb when lb > length(batch) -> + {[], 0} + + lb -> + Process.send_after(self(), :process_batch, 0) + {batch, lb} + end end defp do_upsert(db, key, value, fun) do