From 32b40f25f9920f09f1dc2f9db2ecc6192a2f2c0d Mon Sep 17 00:00:00 2001 From: Aleksandar Radulovic Date: Mon, 21 Mar 2016 13:21:18 +0100 Subject: [PATCH] Fix building of the lib Fix sext and edown dependency Fix array() type defs Change-Id: Ibc2986b690fb81ef9d757fa7b8ba20a994bc8fa2 --- .travis.yml | 1 + rebar.config | 5 +++-- src/hanoidb.hrl | 9 ++++++++- src/hanoidb_bloom.erl | 19 ++++++++++++++++++- test/hanoidb_tests.erl | 12 +++++++++--- 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index a92f632..8c4a58b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,5 +3,6 @@ otp_release: - R16B03 - R15B03 - 17.0 + - 18.0 diff --git a/rebar.config b/rebar.config index 1997063..17b3522 100644 --- a/rebar.config +++ b/rebar.config @@ -21,11 +21,12 @@ 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"}}} @@ -33,7 +34,7 @@ , {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"}}} diff --git a/src/hanoidb.hrl b/src/hanoidb.hrl index f6df372..28d32a8 100644 --- a/src/hanoidb.hrl +++ b/src/hanoidb.hrl @@ -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()}], diff --git a/src/hanoidb_bloom.erl b/src/hanoidb_bloom.erl index 8c1daad..c36edad 100644 --- a/src/hanoidb_bloom.erl +++ b/src/hanoidb_bloom.erl @@ -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), diff --git a/test/hanoidb_tests.erl b/test/hanoidb_tests.erl index ef7e4af..00a4bd9 100644 --- a/test/hanoidb_tests.erl +++ b/test/hanoidb_tests.erl @@ -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_() ->