anchor.diff:              Partition - 1
       end.
   
  -%% @doc Returns the preflist with the primary vnodes. No matter they are up or down.
  +%% @doc get_primaries_preflist returns the preflist with the primary vnodes. No matter they are up or down.
  +%%      Input:  A hashed key
  +%%      Return: The primaries preflist
  +-spec get_primaries_preflist(term()) -> preflist().
   get_primaries_preflist(HashedKey)->
       {ok, CHBin} = riak_core_ring_manager:get_chash_bin(),
       Itr = chashbin:iterator(HashedKey, CHBin),
  
positive.code: -include_lib("eunit/include/eunit.hrl").
  -endif.
  
  -export([get_logid_from_partition/1,
           get_logid_from_key/1,
           get_preflist_from_logid/1,
           get_apl_from_logid/2,
           remove_node_from_preflist/1]).
  
  get_logid_from_partition(Partition) ->
      HashedKey = get_hashedkey_from_partition(Partition),
      Preflist = get_primaries_preflist(HashedKey),
      remove_node_from_preflist(Preflist).
  
  get_logid_from_key(Key) ->
      HashedKey = riak_core_util:chash_key({?BUCKET,
                                         term_to_binary(Key)}),
      Preflist = get_primaries_preflist(HashedKey),
      remove_node_from_preflist(Preflist).
  
  get_preflist_from_logid(LogId) ->
      Partition = hd(LogId),
      HashedKey = get_hashedkey_from_partition(Partition),
      get_primaries_preflist(HashedKey).
  
  get_apl_from_logid(LogId, Service) ->
      Partition = hd(LogId),
      HashedKey = get_hashedkey_from_partition(Partition),
      PreflistAnn = riak_core_apl:get_primary_apl(HashedKey, ?N, Service),
      [IndexNode || {IndexNode, _} <- PreflistAnn].
   
  get_hashedkey_from_partition(Partition) ->
      case Partition of
          0 ->
  
negative.code: 
  -ifdef(TEST).
  
  %% @doc Testing that get_hashedkey_from_partition works when the index is 0
  %%      and when the index is different to 0
  get_hashedkey_from_partition_test()->
      Partition0 = 0,
      ?assertEqual(?MAXRING, get_hashedkey_from_partition(Partition0)),
      Partition = 100,
      ?assertEqual(99, get_hashedkey_from_partition(Partition)).
  
  %% @doc Testing remove_node_from_preflist
  remove_node_from_preflist_test()->
      Preflist = [{partition1, node},{partition2, node},{partition3, node}],
  