Commits

justin  committed 6affdb4

update fstats even if writing in same file, resolving bz://757

  • Participants
  • Parent commits 2789745

Comments (0)

Files changed (2)

File c_src/bitcask_nifs.c

                 update_fstats(env, keydir, entry.file_id, 1, 1,
                               entry.total_sz, entry.total_sz);
             }
+            else // file_id is same, change live/total in one entry
+            {
+                update_fstats(env, keydir, entry.file_id, 0, 1,
+                        entry.total_sz - old_entry->total_sz, entry.total_sz);
+
+            }
 
             // Update the entry info. Note that if you do multiple updates in a
             // second, the last one in wins!

File src/bitcask.erl

     bitcask:close(KDB),
     ok.
 
+frag_status_test() ->
+    B1 = bitcask:open("/tmp/bc.test.fragtest", [read_write]),
+    ok = bitcask:put(B1,<<"k">>,<<"v">>),
+    ok = bitcask:put(B1,<<"k">>,<<"z">>),
+    ok = bitcask:close(B1),
+    % close and reopen so that status can reflect a closed file
+    B2 = bitcask:open("/tmp/bc.test.fragtest", [read_write]),
+    {1,[{_,50,16,32}]} = bitcask:status(B2),
+    %% 1 key, 50% frag, 16 dead bytes, 32 total bytes
+    ok.
+
 -endif.