From 143c474d1a2801151dddcc2beed7ea5b822dc662 Mon Sep 17 00:00:00 2001 From: Christopher Date: Sun, 8 Mar 2020 15:43:37 -0500 Subject: [PATCH] simplify batch for now --- lib/cluster_kv/db.ex | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/cluster_kv/db.ex b/lib/cluster_kv/db.ex index c9a966b..ffcafe3 100644 --- a/lib/cluster_kv/db.ex +++ b/lib/cluster_kv/db.ex @@ -80,21 +80,26 @@ defmodule ClusterKV.DB do {:noreply, %DB{state | batch: batch, last_batch: lb}} end - defp handle_next_batch_chunk(db, batch, chunk, last_batch, fun) do - batch - |> Enum.slice(last_batch, chunk) - |> Enum.each(fn {k, v} -> + defp handle_next_batch_chunk(db, batch, _chunk, _last_batch, fun) do + Enum.each(batch, 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 + {[], 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 end defp do_upsert(db, key, value, fun) do -- 2.45.3