anchor.diff:              %% fix final name so outputs look like old API
               lists:reverse([Final#fitting_spec{name=Int}|Rest])
       end.
  -
  -%% @doc Produce a function (closure over the bucket and tag match) to
  -%% do link extraction via {@link riak_pipe_w_xform}.  The function
  -%% produced will extract all links matching Bucket and Tag from on
  -%% input object, and send them as fitting output.
  --spec link_xform_compat(link_match(), link_match(), term()) ->
  -         fun( (Input :: term(),
  -               riak_pipe_vnode:partition(),
  -               riak_pipe_fitting:details()) -> ok ).
  -link_xform_compat(Bucket, Tag, _Arg) ->
  -    fun({ok, Input, _Keydata}, Partition, FittingDetails) ->
  -            ?T(FittingDetails, [map], {mapping, Input}),
  -            LinkFun = bucket_linkfun(Bucket),
  -            Results = LinkFun(Input, none, {Bucket, Tag}),
  -            ?T(FittingDetails, [map], {produced, Results}),
  -            [ riak_pipe_vnode_worker:send_output(R, Partition,
  -                                                 FittingDetails)
  -              || R <- Results ],
  -            ok;
  -       ({{error,_},_,_}, _Partition, _FittingDetails) ->
  -            ok
  -    end.
  -
  -%% @doc Compute the KV hash of the input.
  --spec bkey_chash(key_input()) -> chash:index().
  -bkey_chash(Input) ->
  -    riak_core_util:chash_key(riak_kv_pipe_get:bkey(Input)).
  -
  -%% @doc Find the N value for the bucket of the input.
  --spec bkey_nval(key_input()) -> integer().
  -bkey_nval(Input) ->
  -    {Bucket,_} = riak_kv_pipe_get:bkey(Input),
  -    BucketProps = riak_core_bucket:get_bucket(Bucket),
  -    {n_val, NVal} = lists:keyfind(n_val, 1, BucketProps),
  -    NVal.
  -
  -%% @doc Find the link-extraction function for the bucket.
  --spec bucket_linkfun(binary()) ->
  -        fun( (Object::term(), KeyData::term(),
  -              {Bucket::link_match(), Tag::link_match()}) -> [key_input()] ).
  -bucket_linkfun(Bucket) ->
  -    BucketProps = riak_core_bucket:get_bucket(Bucket),
  -    {_, {modfun, Module, Function}} = lists:keyfind(linkfun, 1, BucketProps),
  -    erlang:make_fun(Module, Function, 3).
   
   %% @doc How many phases have `keep=true'?
   -spec count_keeps_in_query([query_part()]) -> non_neg_integer().
  
positive.code:          group_outputs/2,
           mapred_plan/1,
           mapred_plan/2,
           compile_string/1
          ]).
  %% NOTE: Example functions are used by EUnit tests
  -export([example/0, example_bucket/0, example_reduce/0,
  
negative.code:          [ riak_pipe:fitting_spec() ].
  reduce2pipe(FunSpec, Arg, Keep, I, ConstHashCookie) ->
      Hash = chash:key_of(ConstHashCookie),
      [#fitting_spec{name={reduce,I},
                     module=riak_kv_w_reduce,
                     arg={rct,
                          riak_kv_w_reduce:reduce_compat(FunSpec),
                          Arg},
                     chashfun=Hash}
       |[#fitting_spec{name=I,
                       module=riak_pipe_w_tee,
                       arg=sink,
  