anchor.diff:  %% TYPES
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   -ifdef(with_export_type_support).
  --export_type([distribution/0, db_type/0, db_parameter/0, db_status/0, failure_type/0]).
  +-export_type([distribution/0, db_distribution/0,
  +              db_type/0, db_parameter/0, db_status/0, failure_type/0]).
   -endif.
   
   -type distribution()    :: random |
  
positive.code:     OutputType = proplists:get_value(output, Options, list_key),
      case Distribution of
          uniform -> uniform_key_list([{Interval, ItemCount}], [], OutputType);
          {non_uniform, Fun} -> non_uniform_key_list(Interval, 1, ItemCount, Fun, [], OutputType)
      end.
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
  -spec uniform_key_list([{Interval, ToAdd}], Acc::Result, OutputType) -> Result when
      is_subtype(Interval,   intervals:continuous_interval()),
      is_subtype(ToAdd,      non_neg_integer()),
      is_subtype(OutputType, list_key_val | list_key),
      is_subtype(Result,     [result()]).
  uniform_key_list([], Acc, _) -> Acc;
  uniform_key_list([{I, Add} | R], Acc, AccType) ->    
      case Add > 100 of
          true -> 
              [I1, I2] = intervals:split(I, 2),
              uniform_key_list([{I1, Add div 2}, {I2, (Add div 2) + (Add rem 2)} | R], Acc, AccType);
          false ->
              {LBr, IL, IR, RBr} = intervals:get_bounds(I),
              End = Add + ?IIF(RBr =:= ')', 1, 0),
              ToAdd = util:for_to_ex(?IIF(LBr =:= '(', 1, 0),
                                     Add + ?IIF(LBr =:= '(', 0, -1),
                                     fun(Index) -> 
                                             Key = ?RT:get_split_key(IL, IR, {Index, End}),
                                             case AccType of
                                                 list_key -> Key;
                                                 list_key_val -> {Key, gen_value()}
                                             end
                                     end),
              uniform_key_list(R, lists:append(ToAdd, Acc), AccType)
      end.
  
  gen_value() ->
      tester_value_creator:create_value(integer, 0, tester_parse_state:new_parse_state()).
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
  -spec non_uniform_key_list(Interval, Step::Int, ToAdd::Int, Fun, Acc::Result, OutputType) -> Result when
      is_subtype(Interval,    intervals:continuous_interval()),
      is_subtype(Int,         pos_integer()),
      is_subtype(Fun,         random_bias:distribution_fun()),
      is_subtype(OutputType,  list_key_val | list_key),
      is_subtype(Result,      [result()]).
  non_uniform_key_list(I, Step, ToAdd, Fun, Acc, AccType) ->
      {Status, V} = Fun(),
      {_, LKey, RKey, _} = intervals:get_bounds(I),
      Add = erlang:round(V * ToAdd),
      NAcc = if Add >= 1 ->
                    StepSize = (RKey - LKey) / ToAdd,
                    SubI = intervals:new('(',
                                         LKey + erlang:trunc((Step - 1) * StepSize),
                                         LKey + ?IIF((X = erlang:trunc(Step * StepSize)) >= ?PLUS_INFINITY, ?MINUS_INFINITY, X),
                                         ']'),
                    uniform_key_list([{SubI, Add}], Acc, AccType);
                true -> Acc
             end,
      case Status of
          ok -> non_uniform_key_list(I, Step + 1, ToAdd, Fun, NAcc, AccType);
          last -> NAcc
      end.
  
  
negative.code: %   limitations under the License.
  
  %% @author Maik Lange <MLange@informatik.hu-berlin.de>
  %% @doc    Creates test-DBs for rrepair.
  %% @end
  %% @version $Id$
  -module(db_generator).
  