Permalink
Browse files

Merge pull request #37 from a13x/master

Fixing the building of hanoidb for R18
  • Loading branch information...
2 parents 4e82d5f + 32b40f2 commit 68333fa51a6fdf27834fc84f42d4421f9627e3b7 @krestenkrab committed Mar 26, 2016
Showing with 39 additions and 7 deletions.
  1. +1 −0 .travis.yml
  2. +3 −2 rebar.config
  3. +8 −1 src/hanoidb.hrl
  4. +18 −1 src/hanoidb_bloom.erl
  5. +9 −3 test/hanoidb_tests.erl
View
@@ -3,5 +3,6 @@ otp_release:
- R16B03
- R15B03
- 17.0
+ - 18.0
View
@@ -21,19 +21,20 @@
warn_untyped_record,
% warn_missing_spec,
% strict_validation,
+ {platform_define, "^R|17", pre18},
debug_info]}.
{xref_checks, [undefined_function_calls]}.
-{deps, [ {sext, ".*", {git, "git://github.com/esl/sext", {branch, "master"}}}
+{deps, [ {sext, ".*", {git, "git://github.com/uwiger/sext", {branch, "master"}}}
, {lager, ".*", {git, "git://github.com/basho/lager", {branch, "master"}}}
, {snappy, "1.*", {git, "git://github.com/fdmanana/snappy-erlang-nif.git", {branch, "master"}}}
, {plain_fsm, "1.*", {git, "git://github.com/gburd/plain_fsm", {branch, "master"}}}
% , {basho_bench, ".*", {git, "git://github.com/basho/basho_bench", {branch, "master"}}}
, {ebloom, ".*", {git, "git://github.com/basho/ebloom", {branch, "master"}}}
, {triq, ".*", {git, "git://github.com/krestenkrab/triq", {branch, "master"}}}
, {lz4, ".*", {git, "git://github.com/krestenkrab/erlang-lz4.git", {branch, "master"}}}
-% , {edown, "0.3.*", {git, "git://github.com/esl/edown.git", {branch, "master"}}}
+% , {edown, "0.3.*", {git, "git://github.com/uwiger/edown.git", {branch, "master"}}}
% , {asciiedoc, "0.1.*", {git, "git://github.com/norton/asciiedoc.git", {branch, "master"}}}
% , {triq, ".*", {git, "git://github.com/krestenkrab/triq.git", {branch, "master"}}}
% , {proper, ".*", {git, "git://github.com/manopapad/proper.git", {branch, "master"}}}
View
@@ -48,12 +48,19 @@
-define(KEY_IN_RANGE(Key,Range),
(?KEY_IN_FROM_RANGE(Key,Range) andalso ?KEY_IN_TO_RANGE(Key,Range))).
+
+-ifdef(pre18).
+-define(TIMESTAMP, now()).
+-else.
+-define(TIMESTAMP, erlang:timestamp()).
+-endif.
+
-record(nursery, { log_file :: file:fd(),
dir :: string(),
cache :: gb_trees:tree(binary(), binary()),
total_size=0 :: integer(),
count=0 :: integer(),
- last_sync=now() :: erlang:timestamp(),
+ last_sync=?TIMESTAMP :: erlang:timestamp(),
min_level :: integer(),
max_level :: integer(),
config=[] :: [{atom(), term()}],
View
@@ -1,4 +1,4 @@
-%% The contents of this file are subject to the Erlang Public License, Version
+% The contents of this file are subject to the Erlang Public License, Version
%% 1.1, (the "License"); you may not use this file except in compliance with
%% the License. You should have received a copy of the Erlang Public License
%% along with this software. If not, it can be retrieved via the world wide web
@@ -41,7 +41,11 @@
-define(W, 27).
+-ifdef(pre18).
-type bitmask() :: array() | any().
+-else.
+-type bitmask() :: arrays:array() | any().
+-endif.
-record(bloom, {
e :: float(), % error probability
@@ -216,7 +220,11 @@ bitmask_get(I, BM) ->
dense_bitmap -> hanoidb_dense_bitmap:member(I, BM)
end.
+-ifdef(pre18).
-spec as_array(bitmask()) -> array().
+-else.
+-spec as_array(bitmask()) -> arrays:array().
+-endif.
as_array(BM) ->
case array:is_array(BM) of
true -> BM
@@ -225,7 +233,12 @@ as_array(BM) ->
%%%========== Bitarray representation - suitable for sparse arrays ==========
bitarray_new(N) -> array:new((N-1) div ?W + 1, {default, 0}).
+-ifdef(pre18).
-spec bitarray_set( non_neg_integer(), array() ) -> array().
+-else.
+-spec bitarray_set( non_neg_integer(), arrays:array() ) -> arrays:array().
+-endif.
+
bitarray_set(I, A1) ->
A = as_array(A1),
AI = I div ?W,
@@ -235,7 +248,11 @@ bitarray_set(I, A1) ->
true -> array:set(AI, V1, A)
end.
+-ifdef(pre18).
-spec bitarray_get( non_neg_integer(), array() ) -> boolean().
+-else.
+-spec bitarray_get( non_neg_integer(), arrays:array() ) -> boolean().
+-endif.
bitarray_get(I, A) ->
AI = I div ?W,
V = array:get(AI, A),
@@ -47,9 +47,15 @@
next_state/3, postcondition/3,
precondition/2]).
--record(tree, { elements = dict:new() :: dict() }).
--record(state, { open = dict:new() :: dict(),
- closed = dict:new() :: dict()}).
+-ifdef(pre18).
+-define(OTP_DICT, dict()).
+-else.
+-define(OTP_DICT, dict:dict()).
+-endif.
+
+-record(tree, { elements = dict:new() :: ?OTP_DICT }).
+-record(state, { open = dict:new() :: ?OTP_DICT,
+ closed = dict:new() :: ?OTP_DICT}).
-define(SERVER, hanoidb_drv).
full_test_() ->

0 comments on commit 68333fa

Please sign in to comment.