anchor.diff:  -define(CAPABILITIES, [async_fold, indexes]).
   
   %% Macros for working with indexes
  --define(SELECT_BATCH_SIZE, 100).
  --define(EQ_MS(B,I,V), [{{{B,I,V,'_'},'_'},[],['$_']}]).
  --define(KEY_RANGE_MS(B,L,H), [{{{B,'$1'},'_'},
  -                               [{'>=', '$1', L},
  -                                {'=<', '$1', H}],
  -                               ['$_']}]).
  --define(RANGE_MS(B,I,L,H), [{{{B,I,'$1','$2'}, '_'},
  -                             [{'>=','$1',L},
  -                              {'=<','$1',H}],
  -                             ['$_']}]).
   -define(DELETE_PTN(B,K), {{B,'_','_',K},'_'}).
   
   %% ETS table name macros so we can break encapsulation for testing
  
positive.code:     MemoryMB = app_helper:get_prop_or_env(max_memory, Config, memory_backend),
      TableOpts = case app_helper:get_prop_or_env(test, Config, memory_backend) of
                      true ->
                          [public, named_table];
                      _ ->
                          []
                  end,
      case MemoryMB of
          undefined ->
  
negative.code:     end.
  
  %% @private
  get_index_folder(Folder, Acc0, {index, Bucket, {eq, <<"$bucket">>, _}}, DataRef, _) ->
      %% For the special $bucket index, turn it into a fold over the
      %% data table.
      fun() ->
              key_range_folder(Folder, Acc0, DataRef, {Bucket, undefined}, Bucket)
      end;
  get_index_folder(Folder, Acc0, {index, Bucket, {range, <<"$key">>, Min, Max}}, DataRef, _) ->
      %% For the special range lookup on the $key index, turn it into a
      %% fold on the data table
      fun() ->
              key_range_folder(Folder, Acc0, DataRef, {Bucket, Min}, {Bucket, Min, Max})
      end;
  get_index_folder(Folder, Acc0, {index, Bucket, {eq, Field, Term}}, _, IndexRef) ->
      fun() ->
              index_range_folder(Folder, Acc0, IndexRef, {Bucket, Field, Term, undefined}, {Bucket, Field, Term, Term})
      end;
  get_index_folder(Folder, Acc0, {index, Bucket, {range, Field, Min, Max}}, _, IndexRef) ->
      fun() ->
              index_range_folder(Folder, Acc0, IndexRef, {Bucket, Field, Min, undefined}, {Bucket, Field, Min, Max})
      end.
  
  
  %% Iterates over a range of keys, for the special $key and $bucket
  %% indexes.
  %% @private
  -spec key_range_folder(function(), term(), ets:tid(), {riak_object:bucket(), riak_object:key()}, binary() | {riak_object:bucket(), term(), term()}) -> term().
  key_range_folder(Folder, Acc0, DataRef, {B,_}=DataKey, B) ->
      case ets:lookup(DataRef, DataKey) of
          [] ->
              key_range_folder(Folder, Acc0, DataRef, ets:next(DataRef, DataKey), B);
          [Object] ->
              Acc = Folder(Object, Acc0),
              key_range_folder(Folder, Acc, DataRef, ets:next(DataRef, DataKey), B)
      end;
  key_range_folder(Folder, Acc0, DataRef, {B,K}=DataKey, {B, Min, Max}=Query) when K >= Min, K =< Max ->
      case ets:lookup(DataRef, DataKey) of
          [] ->
              key_range_folder(Folder, Acc0, DataRef, ets:next(DataRef, DataKey), Query);
          [Object] ->
              Acc = Folder(Object, Acc0),
              key_range_folder(Folder, Acc, DataRef, ets:next(DataRef, DataKey), Query)
      end;
  key_range_folder(_Folder, Acc, _DataRef, _DataKey, _Query) ->
      Acc.
  
  %% Iterates over a range of index postings
  index_range_folder(Folder, Acc0, IndexRef, {B, I, V, _K}=IndexKey, {B, I, Min, Max}=Query) when V >= Min, V =< Max ->
      case ets:lookup(IndexRef, IndexKey) of
          [] ->
              %% This will happen on the first iteration, where the key
              %% does not exist. In all other cases, ETS will give us a
              %% real key from next/2.
              index_range_folder(Folder, Acc0, IndexRef, ets:next(IndexRef, IndexKey), Query);
          [Posting] ->
              Acc = Folder(Posting, Acc0),
              index_range_folder(Folder, Acc, IndexRef, ets:next(IndexRef, IndexKey), Query)
      end;
  index_range_folder(_Folder, Acc, _IndexRef, _IndexKey, _Query) ->
      Acc.
  
  
  %% @private
  do_put(Bucket, Key, Val, IndexSpecs, DataRef, IndexRef) ->
  