Fix append_chunk op in b_b driver

This commit is contained in:
Scott Lystig Fritchie 2016-03-28 17:51:53 +09:00
parent 767f5d9e60
commit a739b5265c
2 changed files with 9 additions and 4 deletions

View file

@ -1,6 +1,6 @@
%% -------------------------------------------------------------------
%%
%% Copyright (c) 2007-2015 Basho Technologies, Inc. All Rights Reserved.
%% Copyright (c) 2007-2016 Basho Technologies, Inc. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
@ -95,7 +95,9 @@ new(Id) ->
run(append, KeyGen, ValueGen, #m{conn=Conn}=S) ->
Prefix = KeyGen(),
Value = ValueGen(),
case machi_cr_client:append_chunk(Conn, Prefix, Value, ?THE_TIMEOUT) of
CSum = machi_util:make_client_csum(Value),
AppendOpts = {append_opts,0,undefined,false},
case machi_cr_client:append_chunk(Conn, undefined, Prefix, Value, CSum, AppendOpts, ?THE_TIMEOUT) of
{ok, Pos} ->
EtsKey = ets:update_counter(?ETS_TAB, max_key, 1),
true = ets:insert(?ETS_TAB, {EtsKey, Pos}),
@ -137,9 +139,8 @@ load_ets_table(Conn, ETS) ->
[begin
{ok, InfoBin} = machi_cr_client:checksum_list(Conn, File),
PosList = machi_csum_table:split_checksum_list_blob_decode(InfoBin),
?INFO("File ~s len PosList ~p\n", [File, length(PosList)]),
StartKey = ets:update_counter(ETS, max_key, 0),
%% _EndKey = lists:foldl(fun({Off,Sz,CSum}, K) ->
%% V = {File, Off, Sz, CSum},
{_, Bytes} = lists:foldl(fun({Off,Sz,_CSum}, {K, Bs}) ->
V = {File, Off, Sz},
ets:insert(ETS, {K, V}),

View file

@ -25,6 +25,7 @@
-export([
checksum_chunk/1,
make_tagged_csum/1, make_tagged_csum/2,
make_client_csum/1,
unmake_tagged_csum/1,
hexstr_to_bin/1, bin_to_hexstr/1,
hexstr_to_int/1, int_to_hexstr/2, int_to_hexbin/2,
@ -327,6 +328,9 @@ make_tagged_csum(?CSUM_TAG_SERVER_SHA_ATOM, SHA) ->
make_tagged_csum(?CSUM_TAG_SERVER_REGEN_SHA_ATOM, SHA) ->
<<?CSUM_TAG_SERVER_REGEN_SHA:8, SHA/binary>>.
make_client_csum(BinOrList) ->
make_tagged_csum(?CSUM_TAG_CLIENT_SHA_ATOM, checksum_chunk(BinOrList)).
unmake_tagged_csum(<<Tag:8, Rest/binary>>) ->
{Tag, Rest}.