feat(): add count/1

This commit is contained in:
Ryan Schmukler 2017-01-24 16:50:37 -05:00
parent 07bfefc49a
commit 7ee6cd3a53
2 changed files with 20 additions and 0 deletions

View File

@ -276,4 +276,16 @@ defmodule Rox do
Keyword.merge(rest, converted)
end
@doc """
Return the approximate number of keys in the default column family.
Implemented by calling GetIntProperty with `rocksdb.estimate-num-keys`
"""
@spec count(db_handle) :: non_neg_integer | {:error, any}
def count(db) do
:erocksdb.count(db)
end
end

View File

@ -46,4 +46,12 @@ defmodule RoxTest do
Rox.stream_keys(db) |> Enum.take(1)
end
test "count", %{db: db} do
count =
Rox.count(db)
assert is_number(count)
assert count >= 0
end
end