Enable lz4 compression
This commit is contained in:
parent
923dbe3852
commit
35de7a3300
3 changed files with 13 additions and 13 deletions
|
@ -30,7 +30,7 @@
|
||||||
, {plain_fsm, "1.1.*", {git, "git://github.com/gburd/plain_fsm", {branch, "master"}}}
|
, {plain_fsm, "1.1.*", {git, "git://github.com/gburd/plain_fsm", {branch, "master"}}}
|
||||||
, {basho_bench, ".*", {git, "git://github.com/basho/basho_bench", {branch, "master"}}}
|
, {basho_bench, ".*", {git, "git://github.com/basho/basho_bench", {branch, "master"}}}
|
||||||
, {triq, ".*", {git, "git://github.com/krestenkrab/triq", {branch, "master"}}}
|
, {triq, ".*", {git, "git://github.com/krestenkrab/triq", {branch, "master"}}}
|
||||||
% , {lz4, ".*", {git, "git://github.com/gburd/erlang-lz4.git", {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/esl/edown.git", {branch, "master"}}}
|
||||||
% , {asciiedoc, "0.1.*", {git, "git://github.com/norton/asciiedoc.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"}}}
|
% , {triq, ".*", {git, "git://github.com/krestenkrab/triq.git", {branch, "master"}}}
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
|
|
||||||
-type hanoidb() :: pid().
|
-type hanoidb() :: pid().
|
||||||
-type key_range() :: #key_range{}.
|
-type key_range() :: #key_range{}.
|
||||||
-type config_option() :: {compress, none | gzip | snappy} %lz4
|
-type config_option() :: {compress, none | gzip | snappy | lz4}
|
||||||
| {page_size, pos_integer()}
|
| {page_size, pos_integer()}
|
||||||
| {read_buffer_size, pos_integer()}
|
| {read_buffer_size, pos_integer()}
|
||||||
| {write_buffer_size, pos_integer()}
|
| {write_buffer_size, pos_integer()}
|
||||||
|
|
|
@ -89,7 +89,7 @@ estimate_node_size_increment(_KVList, Key, Value)
|
||||||
-define(NO_COMPRESSION, 0).
|
-define(NO_COMPRESSION, 0).
|
||||||
-define(SNAPPY_COMPRESSION, 1).
|
-define(SNAPPY_COMPRESSION, 1).
|
||||||
-define(GZIP_COMPRESSION, 2).
|
-define(GZIP_COMPRESSION, 2).
|
||||||
%%-define(LZ4_COMPRESSION, 3).
|
-define(LZ4_COMPRESSION, 3).
|
||||||
|
|
||||||
use_compressed(UncompressedSize, CompressedSize) when CompressedSize < UncompressedSize ->
|
use_compressed(UncompressedSize, CompressedSize) when CompressedSize < UncompressedSize ->
|
||||||
true;
|
true;
|
||||||
|
@ -104,14 +104,14 @@ compress(snappy, Bin) ->
|
||||||
false ->
|
false ->
|
||||||
{?NO_COMPRESSION, Bin}
|
{?NO_COMPRESSION, Bin}
|
||||||
end;
|
end;
|
||||||
%% compress(lz4, Bin) ->
|
compress(lz4, Bin) ->
|
||||||
%% {ok, CompressedBin} = lz4:compress(Bin),
|
{ok, CompressedBin} = lz4:compress(erlang:iolist_to_binary(Bin)),
|
||||||
%% case use_compressed(erlang:iolist_size(Bin), erlang:iolist_size(CompressedBin)) of
|
case use_compressed(erlang:iolist_size(Bin), erlang:iolist_size(CompressedBin)) of
|
||||||
%% true ->
|
true ->
|
||||||
%% {?LZ4_COMPRESSION, CompressedBin};
|
{?LZ4_COMPRESSION, CompressedBin};
|
||||||
%% false ->
|
false ->
|
||||||
%% {?NO_COMPRESSION, Bin}
|
{?NO_COMPRESSION, Bin}
|
||||||
%% end;
|
end;
|
||||||
compress(gzip, Bin) ->
|
compress(gzip, Bin) ->
|
||||||
CompressedBin = zlib:gzip(Bin),
|
CompressedBin = zlib:gzip(Bin),
|
||||||
case use_compressed(erlang:iolist_size(Bin), erlang:iolist_size(CompressedBin)) of
|
case use_compressed(erlang:iolist_size(Bin), erlang:iolist_size(CompressedBin)) of
|
||||||
|
@ -128,8 +128,8 @@ uncompress(<<?NO_COMPRESSION, Data/binary>>) ->
|
||||||
uncompress(<<?SNAPPY_COMPRESSION, Data/binary>>) ->
|
uncompress(<<?SNAPPY_COMPRESSION, Data/binary>>) ->
|
||||||
{ok, UncompressedData} = snappy:decompress(Data),
|
{ok, UncompressedData} = snappy:decompress(Data),
|
||||||
UncompressedData;
|
UncompressedData;
|
||||||
%%uncompress(<<?LZ4_COMPRESSION, Data/binary>>) ->
|
uncompress(<<?LZ4_COMPRESSION, Data/binary>>) ->
|
||||||
%% lz4:uncompress(Data);
|
lz4:uncompress(Data);
|
||||||
uncompress(<<?GZIP_COMPRESSION, Data/binary>>) ->
|
uncompress(<<?GZIP_COMPRESSION, Data/binary>>) ->
|
||||||
zlib:gunzip(Data).
|
zlib:gunzip(Data).
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue