anchor.diff:                     {req, Req, Timeout}
              end,
       gen_server:call(Pid, Call, CallTimeout).
  +
  +
   
   encode_2i(Value) when is_integer(Value) ->
       list_to_binary(integer_to_list(Value));
  
positive.code: get_index_eq(Pid, Bucket, Index, Key, Opts) ->
      Timeout = proplists:get_value(timeout, Opts, default_timeout(get_index_timeout)),
      CallTimeout = proplists:get_value(call_timeout, Opts, default_timeout(get_index_call_timeout)),
      Req = #rpbindexreq{bucket=Bucket, index=Index, qtype=eq,
                         key=encode_2i(Key)},
      gen_server:call(Pid, {req, Req, Timeout}, CallTimeout).
  
  %% @doc Execute a secondary index range query.
  -spec get_index_range(pid(), bucket(), binary() | secondary_index_id(), key() | integer(), key() | integer()) ->
                         {ok, index_result()} | {error, term()}.
  get_index_range(Pid, Bucket, {binary_index, Name}, StartKey, EndKey) when is_binary(StartKey) andalso is_binary(EndKey) ->
      Index = list_to_binary(lists:append([Name, "_bin"])),
      get_index_range(Pid, Bucket, Index, StartKey, EndKey);
  get_index_range(Pid, Bucket, {integer_index, Name}, StartKey, EndKey) when is_integer(StartKey) andalso is_integer(EndKey)  ->
      Index = list_to_binary(lists:append([Name, "_int"])),
      BinStartKey = list_to_binary(integer_to_list(StartKey)),
      BinEndKey = list_to_binary(integer_to_list(EndKey)),
      get_index_range(Pid, Bucket, Index, BinStartKey, BinEndKey);
  get_index_range(Pid, Bucket, Index, StartKey, EndKey) ->
      Timeout = default_timeout(get_index_timeout),
      CallTimeout = default_timeout(get_index_call_timeout),
      get_index_range(Pid, Bucket, Index, StartKey, EndKey, [{timeout, Timeout}, {call_timeout, CallTimeout}]).
  
  %% @doc Execute a secondary index range query with specified
  %% timeouts.
  -spec get_index_range(pid(), bucket(), binary() | secondary_index_id(), key() | integer() | list(),
                  key() | integer() | list(), range_index_opts()) ->
                         {ok, index_result()} | {error, term()}.
  
negative.code: 
  process_response(#request{msg = #rpbindexreq{}}, rpbindexresp, State) ->
      {reply, {ok, []}, State};
  process_response(#request{msg = #rpbindexreq{stream=true, return_terms=Terms}}=Request,
                   #rpbindexresp{results=Results, keys=Keys, done=Done}, State) ->
      case {Terms, Results, Keys} of
          {_, undefined, undefined} -> ok;
          {true, Res, _} ->
              send_caller({results, Res}, Results);
          {fale, _, Res} ->
              send_caller({keys, Res}, Request)
      end,
      Reply = case Done of
                  true -> {reply, done, State};
  