anchor.diff:      end.
   
   
  -sequential_int_generator(Ref, MaxValue) ->
  +sequential_int_generator(Ref, MaxValue, Id) ->
      %% A bit of evil here. We want to generate numbers in sequence and stop
      %% at MaxKey. This means we need state in our anonymous function. Use the process
      %% dictionary to keep track of where we are.
      case erlang:get({sigen, Ref}) of
          undefined ->
  -           erlang:put({sigen, Ref}, 1),
  -           0;
  +           seq_gen_put(Ref, seq_gen_read_resume_value(Id)),
  +           sequential_int_generator(Ref, MaxValue, Id);
          MaxValue ->
              throw({stop, empty_keygen});
          Value ->
  +           case Value rem 500 of
  +               0 -> ok = seq_gen_write_resume_value(Id, Value);
  +               _ -> ok
  +           end,
              case Value rem 5000 of
                  0 ->
                      ?DEBUG("sequential_int_gen: ~p (~w%)\n", [Value, trunc(100 * (Value / MaxValue))]);
                  _ ->
                      ok
              end,
  -           erlang:put({sigen, Ref}, Value+1),
  +           seq_gen_put(Ref, Value+1),
              Value
      end.
  +
  +seq_gen_put(Ref, Value) ->
  +    erlang:put({sigen, Ref}, Value).
  +
  +seq_gen_write_resume_value(Id, Value) ->
  +    case seq_gen_state_dir() of
  +        "" ->
  +            ok;
  +        Path ->
  +            OutFile = Path ++ "/" ++ integer_to_list(Id),
  +            OutFileTmp = Path ++ "/" ++ integer_to_list(Id) ++ ".tmp",
  +            Bin = term_to_binary(Value),
  +            ok = file:write_file(OutFileTmp, Bin),
  +            {ok, Bin} = file:read_file(OutFileTmp),
  +            ok = file:rename(OutFileTmp, OutFile)
  +    end.
  +
  +seq_gen_read_resume_value(Id) ->
  +    case seq_gen_state_dir() of
  +        "" ->
  +            0;
  +        Path ->
  +            try
  +                InFile = Path ++ "/" ++ integer_to_list(Id),
  +                {ok, Bin} = file:read_file(InFile),
  +                Value = binary_to_term(Bin),
  +                ?DEBUG("Id ~p resuming from value ~p\n", [Id, Value]),
  +                Value
  +            catch
  +                error:{badmatch, _} ->
  +                    0;
  +                X:Y ->
  +                    ?DEBUG("Error reading resume value for Id ~p ~p: ~p ~p\n",
  +                           [Id, Path ++ "/" ++ integer_to_list(Id), X, Y]),
  +                    0
  +            end
  +    end.
  +
  +seq_gen_state_dir() ->
  +    Key = sequential_int_state_dir,
  +    case basho_bench_config:get(Key, "") of
  +        [$/|_] = Dir ->
  +            Dir;
  +        Else ->
  +            case get(you_have_been_warned) of
  +                undefined ->
  +                    ?WARN("Config value ~p -> ~p is not an absolute "
  +                          "path, ignoring!\n", [Key, Else]),
  +                    put(you_have_been_warned, true);
  +                _ ->
  +                    ok
  +            end,
  +            ""
  +    end.
  
positive.code: new({to_binstr, FmtStr, InputGen}, Id) ->
      Gen = new(InputGen, Id),
      fun() -> list_to_binary(io_lib:format(FmtStr, [Gen()])) end;
  new({sequential_int, MaxKey}, _Id) ->
      Ref = make_ref(),
      fun() -> sequential_int_generator(Ref, MaxKey) end;
  new({partitioned_sequential_int, MaxKey}, Id) ->
      new({partitioned_sequential_int, 0, MaxKey}, Id);
  new({partitioned_sequential_int, StartKey, NumKeys}, Id) ->
  
negative.code:     MaxValue = StartKey + Range * Id,
      Ref = make_ref(),
      ?DEBUG("ID ~p generating range ~p to ~p\n", [Id, MinValue, MaxValue]),
      fun() -> sequential_int_generator(Ref, Range, Id) + MinValue end;
  new({uniform_int, MaxKey}, _Id) ->
      fun() -> random:uniform(MaxKey) end;
  new({pareto_int, MaxKey}, _Id) ->
  