<commit_before>-module(pooled_memcached_client).

-include("ns_common.hrl").
-include("mc_constants.hrl").
-include("mc_entry.hrl").
-include("couch_db.hrl").
-include("xdcr_upr_streamer.hrl").

-export([find_missing_revs/3, bulk_set_metas/3]).

-spec find_missing_revs(any(), vbucket_id(), [{binary(), rev()}]) ->
                               {ok,
                                [{binary(), rev()}],
                                [{atom(), {binary(), rev()}}]}.
find_missing_revs(DestRef, Vb, IdRevs) ->
    execute(DestRef, fun find_missing_revs_inner/3, [Vb, IdRevs]).

send_batch({batch_socket, Socket}, Data) ->
    BatchBytes = iolist_size(Data),
    BatchReqs = length(Data),
    system_stats_collector:add_histo(xdcr_batch_bytes, BatchBytes),
    system_stats_collector:add_histo(xdcr_batch_reqs, BatchReqs),
    Data1 = [<<BatchBytes:32/big, BatchReqs:32/big>> | Data],
    ok = prim_inet:send(Socket, Data1);
send_batch(Socket, Data) ->
    ok = prim_inet:send(Socket, Data).

extract_recv_socket({batch_socket, S}) ->
    S;
extract_recv_socket(S) ->
    S.


find_missing_revs_inner(S, Vb, IdRevs) ->
    SenderPid = spawn_link(
                  fun () ->
                          Data = [begin
                                      H = #mc_header{vbucket = Vb,
                                                     opcode = ?CMD_GET_META},
                                      E = #mc_entry{key = Key},
                                      mc_binary:encode(req, H, E)
                                  end || {Key, _Rev} <- IdRevs],
                          send_batch(S, Data)
                  end),
    RV = fetch_missing_revs_loop(extract_recv_socket(S), IdRevs, [], []),<commit_msg>export pooled_memcached_client:send_batch and extract_recv_socket<commit_after>-module(pooled_memcached_client).

-include("ns_common.hrl").
-include("mc_constants.hrl").
-include("mc_entry.hrl").
-include("couch_db.hrl").
-include("xdcr_upr_streamer.hrl").

-export([find_missing_revs/3, bulk_set_metas/3]).

-export([send_batch/2, extract_recv_socket/1]).

-spec find_missing_revs(any(), vbucket_id(), [{binary(), rev()}]) ->
                               {ok,
                                [{binary(), rev()}],
                                [{atom(), {binary(), rev()}}]}.
find_missing_revs(DestRef, Vb, IdRevs) ->
    execute(DestRef, fun find_missing_revs_inner/3, [Vb, IdRevs]).

send_batch({batch_socket, Socket}, Requests) ->
    BatchBytes = iolist_size(Requests),
    BatchReqs = length(Requests),
    system_stats_collector:add_histo(xdcr_batch_bytes, BatchBytes),
    system_stats_collector:add_histo(xdcr_batch_reqs, BatchReqs),
    Data1 = [<<BatchBytes:32/big, BatchReqs:32/big>> | Requests],
    ok = prim_inet:send(Socket, Data1);
send_batch(Socket, Requests) ->
    ok = prim_inet:send(Socket, Requests).

extract_recv_socket({batch_socket, S}) ->
    S;
extract_recv_socket(S) ->
    S.


find_missing_revs_inner(S, Vb, IdRevs) ->
    SenderPid = spawn_link(
                  fun () ->
                          Data = [begin
                                      H = #mc_header{vbucket = Vb,
                                                     opcode = ?CMD_GET_META},
                                      E = #mc_entry{key = Key},
                                      mc_binary:encode(req, H, E)
                                  end || {Key, _Rev} <- IdRevs],
                          send_batch(S, Data)
                  end),
    RV = fetch_missing_revs_loop(extract_recv_socket(S), IdRevs, [], []),
{'fraction_non_alphanumeric': 0.14112334180073385, 'fraction_numerical': 0.005644933672029354, 'mean_word_length': 1.990717299578059, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5372957', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1149, 'n_words': 173}