示例#1
0
  private short generateWarehouseId() {
    short w_id = -1;

    // WAREHOUSE AFFINITY
    if (config.warehouse_affinity) {
      w_id = (short) this.affineWarehouse;
    }
    // TEMPORAL SKEW
    else if (config.temporal_skew) {
      if (generator.number(1, 100) <= config.temporal_skew_mix) {
        if (config.temporal_skew_rotate) {
          w_id =
              (short) ((this.tick_counter % parameters.warehouses) + parameters.starting_warehouse);
        } else {
          w_id = (short) config.first_warehouse;
        }
        this.temporal_counter++;
      } else {
        w_id = (short) generator.number(parameters.starting_warehouse, parameters.last_warehouse);
      }
    }
    // ZIPFIAN SKEWED WAREHOUSE ID
    else if (config.neworder_skew_warehouse) {
      assert (this.zipf != null);
      // w_id = (short)this.zipf.nextInt();
      w_id = (short) this.custom_skew.nextInt();
    }
    // GAUSSIAN SKEWED WAREHOUSE ID
    else if (skewFactor > 0.0d) {
      w_id =
          (short)
              generator.skewedNumber(
                  parameters.starting_warehouse, parameters.last_warehouse, skewFactor);
    }
    // UNIFORM DISTRIBUTION
    else {
      w_id = (short) generator.number(parameters.starting_warehouse, parameters.last_warehouse);
    }

    assert (w_id >= parameters.starting_warehouse)
        : String.format(
            "Invalid W_ID: %d [min=%d, max=%d]",
            w_id, parameters.starting_warehouse, parameters.last_warehouse);
    assert (w_id <= parameters.last_warehouse)
        : String.format(
            "Invalid W_ID: %d [min=%d, max=%d]",
            w_id, parameters.starting_warehouse, parameters.last_warehouse);

    this.lastWarehouseHistory.put(w_id);
    this.totalWarehouseHistory.put(w_id);

    return w_id;
  }