]> Entropealabs - cluster_kv.git/commitdiff
add batch logic back, not the issue
authorChristopher <chris@entropealabs.com>
Sun, 8 Mar 2020 20:55:54 +0000 (15:55 -0500)
committerChristopher <chris@entropealabs.com>
Sun, 8 Mar 2020 20:55:54 +0000 (15:55 -0500)
lib/cluster_kv/db.ex

index ffcafe3fa6118ff9984e99181d48b16428deaf5e..a512987723ce5ab8efede5637cd097b6c594dec3 100644 (file)
@@ -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