summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJoe <joe@ubuntu.localdomain>2010-02-22 12:19:15 -0800
committerJoe <joe@ubuntu.localdomain>2010-02-22 12:19:15 -0800
commit6fce297e9ff9f495b10281f2c5c78e6e0c2d48ad (patch)
tree42f34b519a411ce8f594a375d5be5c885ee37ed6 /include
merge attempt #1
Diffstat (limited to 'include')
-rw-r--r--include/chunk_size.hrl1
-rw-r--r--include/common.hrl41
-rw-r--r--include/config.hrl24
-rw-r--r--include/dmerkle.hrl14
-rw-r--r--include/profile.hrl9
-rw-r--r--include/test.hrl13
6 files changed, 102 insertions, 0 deletions
diff --git a/include/chunk_size.hrl b/include/chunk_size.hrl
new file mode 100644
index 00000000..f9906b5f
--- /dev/null
+++ b/include/chunk_size.hrl
@@ -0,0 +1 @@
+-define(CHUNK_SIZE, 5120).
diff --git a/include/common.hrl b/include/common.hrl
new file mode 100644
index 00000000..2299950d
--- /dev/null
+++ b/include/common.hrl
@@ -0,0 +1,41 @@
+
+-include_lib("eunit/include/eunit.hrl").
+
+-define(fmt(Msg, Args), lists:flatten(io_lib:format(Msg, Args))).
+-define(infoFmt(Msg, Args), error_logger:info_msg(Msg, Args)).
+-define(infoMsg(Msg), error_logger:info_msg(Msg)).
+
+
+%% from couch_db.hrl
+-ifndef(LOG_DEBUG).
+-define(LOG_DEBUG(Format, Args),
+ showroom_log:message(debug, Format, Args)).
+-endif.
+
+-ifndef(LOG_INFO).
+-define(LOG_INFO(Format, Args),
+ showroom_log:message(info, Format, Args)).
+-endif.
+
+-ifndef(LOG_ERROR).
+-define(LOG_ERROR(Format, Args),
+ showroom_log:message(error, Format, Args)).
+-endif.
+
+%% -define(PMAP(F,L), lists:map(F,L)).
+-define(PMAP(F,L), showroom_utils:pmap(F,L)).
+
+
+%%
+%% membership2 (in here for separate testing module)
+%%
+
+-define(VERSION,2).
+
+-record(membership, {header=?VERSION,
+ node,
+ nodes,
+ partitions,
+ version,
+ fullmap
+ }).
diff --git a/include/config.hrl b/include/config.hrl
new file mode 100644
index 00000000..20983d26
--- /dev/null
+++ b/include/config.hrl
@@ -0,0 +1,24 @@
+
+-ifndef(CONFIG_HRL).
+-define(CONFIG_HRL, true).
+%we don't want to turn protocol buffers on by default, since the library is not included
+%it should be very easy for new users to start up an instance
+-record(config, {n=3,
+ r=1,
+ w=1,
+ q=6,
+ directory,
+ web_port,
+ text_port=11222,
+ storage_mod=dets_storage,
+ blocksize=4096,
+ thrift_port=9200,
+ pb_port=undefined,
+ buffered_writes=undefined,
+ cache=undefined,
+ cache_size=1048576,
+ hash_module=partitions,
+ meta=[]
+ }).
+
+-endif.
diff --git a/include/dmerkle.hrl b/include/dmerkle.hrl
new file mode 100644
index 00000000..b4fe2a08
--- /dev/null
+++ b/include/dmerkle.hrl
@@ -0,0 +1,14 @@
+-define(DMERKLE_VERSION, 2).
+-define(STATIC_HEADER, 93).
+
+-define(d_from_blocksize(BlockSize), trunc((BlockSize - 17)/16)).
+-define(pointers_from_blocksize(BlockSize), (lib_misc:ceiling(math:log(BlockSize)/math:log(2)) - 3)).
+-define(pointer_for_size(Size, BlockSize), (if Size =< 16 -> 1; Size =< BlockSize -> ?pointers_from_blocksize(Size); true -> last end)).
+-define(size_for_pointer(N), (2 bsl (N+2))).
+-define(headersize_from_blocksize(BlockSize), (?STATIC_HEADER + ?pointers_from_blocksize(BlockSize) * 8)).
+-define(aligned(Ptr, HeaderSize, BlockSize), (((Ptr - (HeaderSize)) rem BlockSize) == 0)).
+-define(block(Ptr, HeaderSize, BlockSize), ((Ptr - (HeaderSize)) div BlockSize)).
+
+-record(node, {m=0, keys=[], children=[], offset=eof}).
+-record(leaf, {m=0, values=[], offset=eof}).
+-record(free, {offset,size=0,pointer=0}).
diff --git a/include/profile.hrl b/include/profile.hrl
new file mode 100644
index 00000000..2ffd8009
--- /dev/null
+++ b/include/profile.hrl
@@ -0,0 +1,9 @@
+-ifdef(PROF).
+-define(balance_prof, dynomite_prof:balance_prof()).
+-define(prof(Label), dynomite_prof:start_prof(Label)).
+-define(forp(Label), dynomite_prof:stop_prof(Label)).
+-else.
+-define(prof(Label), true).
+-define(forp(Label), true).
+-define(balance_prof, true).
+-endif.
diff --git a/include/test.hrl b/include/test.hrl
new file mode 100644
index 00000000..38fb850f
--- /dev/null
+++ b/include/test.hrl
@@ -0,0 +1,13 @@
+-define(TMP_DIR, "../../../tmp/lib").
+
+-define(TMP_FILE, fun(File) ->
+ filename:join(?TMP_DIR, File)
+ end).
+
+%% priv_dir() ->
+%% Dir = filename:join([t:config(priv_dir), "data", atom_to_list(?MODULE), pid_to_list(self())]),
+%% filelib:ensure_dir(filename:join([Dir, atom_to_list(?MODULE)])),
+%% Dir.
+
+%% priv_file(File) ->
+%% filename:join(priv_dir(), File).