Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eleveldb version #1

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6f1036e
first version of antidote_db with eleveldb as backend
santialvarezcolombo Jan 22, 2016
2e3fd26
added options to fold methods
santialvarezcolombo Jan 22, 2016
deac50b
fix esport parameters for fold methods
santialvarezcolombo Jan 22, 2016
e37bad9
antidote db sup first version
santialvarezcolombo Jan 22, 2016
1f4c0e2
fix bug while passing keys to binary
santialvarezcolombo Jan 22, 2016
1336486
Added antidote_db_wrapper, originally on the main Antidote repo. Firs…
santialvarezcolombo Aug 22, 2016
f8d7ba3
Changed dependency for antidote utils branch
santialvarezcolombo Aug 23, 2016
eaf5db9
Fixed branch in rebar config for antidote utils dependency
santialvarezcolombo Aug 24, 2016
ca2eb9f
Added the licence to missing files
santialvarezcolombo Aug 26, 2016
af40b72
Switched branch order in get_ops to make code more readable
santialvarezcolombo Aug 29, 2016
7b87efd
Fixed accumulation in the resulting list of the get_ops method
santialvarezcolombo Aug 29, 2016
03fbcdc
Updated the wrapper with to use the log_record provided in antidote_u…
santialvarezcolombo Sep 7, 2016
20148ab
Updated spec return type in get_ops
santialvarezcolombo Sep 7, 2016
e3bff37
Renamed and refactored the antidote_db and the leveldb_wrapper
santialvarezcolombo Sep 20, 2016
17377dc
Added a test for to check the reutnr type in all methods
santialvarezcolombo Sep 20, 2016
0cba2b8
Changes to use the materealized_snapshot in antidote_uti.s
santialvarezcolombo Sep 21, 2016
ffb1b10
Fixed upper bound in get_ops method
santialvarezcolombo Sep 26, 2016
992109e
Added the get_ops_applicable_to_snapshot method and it's tests.
santialvarezcolombo Sep 26, 2016
eeb1968
Refactored tests and added comments
santialvarezcolombo Sep 26, 2016
17fbcfc
Added the get_ops_applicable_to_snapshot method to the antidote_db in…
santialvarezcolombo Sep 26, 2016
28b0d8b
Fixed lower bound in get_ops range
santialvarezcolombo Sep 28, 2016
26f66a8
Fixed bug with concurrent ops
santialvarezcolombo Sep 28, 2016
f965f2b
Fixed begening key to start looking in fold
santialvarezcolombo Sep 30, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{deps, [

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hint: We moved to rebar3 for Antidote. Might be worth considering for you, too?

{eleveldb, ".*", {git, "git://github.com/SyncFree/eleveldb", {branch, "antidote_comparator"}}},
{antidote_utils, ".*", {git, "git://github.com/SyncFree/antidote_utils", {branch, "additions_for_antidote_db"}}}
]}.
13 changes: 13 additions & 0 deletions src/antidote_db.app.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{application, antidote_db,
[
{description, "Antidote DataBase application"},
{vsn, "1"},
{registered, []},
{applications, [
kernel,
stdlib,
eleveldb
]},
{mod, { antidote_db, []}},
{env, []}
]}.
99 changes: 99 additions & 0 deletions src/antidote_db.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
%% -------------------------------------------------------------------
%%
%% Copyright (c) 2014 SyncFree Consortium. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% software distributed under the License is distributed on an
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%% KIND, either express or implied. See the License for the
%% specific language governing permissions and limitations
%% under the License.
%%
%% -------------------------------------------------------------------

-module(antidote_db).

-export([
new/1,
get/2,
put/3,
close_and_destroy/2,
close/1,
fold/4,
fold_keys/4,
is_empty/1,
delete/2,
repair/1]).

-type antidote_db() :: eleveldb:db_ref().

-export_type([antidote_db/0]).

%% Given a name, returns a new AntidoteDB (ElevelDB)
%% OpenOptions are set to use Antidote special comparator
-spec new(atom()) -> {ok, antidote_db()} | {error, any()}.
new(Name) ->
eleveldb:open(Name, [{create_if_missing, true}, {antidote, true}]).

%% Closes and destroys the given base
-spec close_and_destroy(antidote_db(), atom()) -> ok | {error, any()}.
close_and_destroy(AntidoteDB, Name) ->
eleveldb:close(AntidoteDB),
eleveldb:destroy(Name, []).

-spec close(antidote_db()) -> ok | {error, any()}.
close(AntidoteDB) ->
eleveldb:close(AntidoteDB).

%% @doc returns the value of Key, in the antidote_db
-spec get(antidote_db(), any()) -> term() | not_found.
get(AntidoteDB, Key) ->
AKey = case is_binary(Key) of
true -> Key;
false -> term_to_binary(Key)
end,
case eleveldb:get(AntidoteDB, AKey, []) of
{ok, Res} ->
binary_to_term(Res);
not_found ->
not_found
end.

%% @doc puts the Value associated to Key in eleveldb AntidoteDB
-spec put(antidote_db(), any(), any()) -> ok | {error, any()}.
put(AntidoteDB, Key, Value) ->
AKey = case is_binary(Key) of
true -> Key;
false -> term_to_binary(Key)
end,
ATerm = case is_binary(Value) of
true -> Value;
false -> term_to_binary(Value)
end,
eleveldb:put(AntidoteDB, AKey, ATerm, []).

-spec fold(antidote_db(), eleveldb:fold_fun(), any(), eleveldb:read_options()) -> any().
fold(AntidoteDB, Fun, Acc0, Opts) ->
eleveldb:fold(AntidoteDB, Fun, Acc0, Opts).

-spec fold_keys(antidote_db(), eleveldb:fold_keys_fun(), any(), eleveldb:read_options()) -> any().
fold_keys(AntidoteDB, Fun, Acc0, Opts) ->
eleveldb:fold_keys(AntidoteDB, Fun, Acc0, Opts).

-spec is_empty(antidote_db()) -> boolean().
is_empty(AntidoteDB) ->
eleveldb:is_empty(AntidoteDB).

repair(Name) ->
eleveldb:repair(Name, []).

-spec delete(antidote_db(), binary()) -> ok | {error, any()}.
delete(AntidoteDB, Key) ->
eleveldb:delete(AntidoteDB, Key, []).
45 changes: 45 additions & 0 deletions src/antidote_db_sup.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
%% -------------------------------------------------------------------
%%
%% Copyright (c) 2014 SyncFree Consortium. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% software distributed under the License is distributed on an
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%% KIND, either express or implied. See the License for the
%% specific language governing permissions and limitations
%% under the License.
%%
%% -------------------------------------------------------------------
-module(antidote_db_sup).

-behaviour(supervisor).

%% API
-export([start_link/0]).

%% Supervisor callbacks
-export([init/1]).

%% Helper macro for declaring children of supervisor
-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).

%% ===================================================================
%% API functions
%% ===================================================================

start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).

%% ===================================================================
%% Supervisor callbacks
%% ===================================================================

init([]) ->
{ok, { {one_for_one, 5, 10}, []} }.
Loading