Пример #1
0
void ParseArguments(int argc, char *argv[], configuration &state) {
  // Default Values
  state.operator_type = OPERATOR_TYPE_INVALID;

  state.scale_factor = 100.0;
  state.tuples_per_tilegroup = DEFAULT_TUPLES_PER_TILEGROUP;

  state.transactions = 1;
  state.selectivity = 1.0;
  state.projectivity = 1.0;

  state.layout_mode = LAYOUT_ROW;

  state.experiment_type = EXPERIMENT_TYPE_INVALID;

  state.column_count = 100;
  state.write_ratio = 0.0;

  state.access_num_groups = 1;
  state.subset_ratio = 1.0;
  state.subset_experiment_type = SUBSET_TYPE_INVALID;

  state.adapt = false;
  state.theta = 0.0;
  state.reorg = false;
  state.distribution = false;

  // Parse args
  while (1) {
    int idx = 0;
    int c = getopt_long(argc, argv, "aho:k:s:p:l:t:e:c:w:g:", opts, &idx);

    if (c == -1) break;

    switch (c) {
      case 'o':
        state.operator_type = (OperatorType)atoi(optarg);
        break;
      case 'k':
        state.scale_factor = atoi(optarg);
        break;
      case 's':
        state.selectivity = atof(optarg);
        break;
      case 'p':
        state.projectivity = atof(optarg);
        break;
      case 'l':
        state.layout_mode = (LayoutType)atoi(optarg);
        break;
      case 't':
        state.transactions = atoi(optarg);
        break;
      case 'e':
        state.experiment_type = (ExperimentType)atoi(optarg);
        break;
      case 'c':
        state.column_count = atoi(optarg);
        break;
      case 'w':
        state.write_ratio = atof(optarg);
        break;
      case 'g':
        state.tuples_per_tilegroup = atoi(optarg);
        break;
      case 'h':
        Usage(stderr);
        break;

      default:
        fprintf(stderr, "\nUnknown option: -%c-\n", c);
        Usage(stderr);
    }
  }

  if (state.experiment_type == EXPERIMENT_TYPE_INVALID) {
    // Print configuration
    ValidateOperator(state);
    ValidateLayout(state);
    ValidateSelectivity(state);
    ValidateProjectivity(state);
    ValidateScaleFactor(state);
    ValidateColumnCount(state);
    ValidateWriteRatio(state);
    ValidateTuplesPerTileGroup(state);

    std::cout << std::setw(20) << std::left << "transactions "
              << " : " << state.transactions << std::endl;
  } else {
    ValidateExperiment(state);
  }

  // cache orig scale factor
  orig_scale_factor = state.scale_factor;
}
void ParseArguments(int argc, char *argv[], configuration &state) {
  // Default Values
  state.hybrid_scan_type = HYBRID_SCAN_TYPE_HYBRID;
  state.operator_type = OPERATOR_TYPE_DIRECT;

  state.scale_factor = 100.0;
  state.tuples_per_tilegroup = DEFAULT_TUPLES_PER_TILEGROUP;

  state.transactions = 1;
  state.selectivity = 1.0;
  state.projectivity = 1.0;

  state.layout_mode = LAYOUT_TYPE_ROW;

  state.experiment_type = EXPERIMENT_TYPE_INVALID;

  state.column_count = 500;
  state.write_ratio = 0.0;

  state.index_count = 1;

  state.adapt = false;

  // Parse args
  while (1) {
    int idx = 0;
    int c = getopt_long(argc, argv, "aho:k:s:p:l:t:e:c:w:g:y:i:", opts, &idx);

    if (c == -1) break;

    switch (c) {
      case 'o':
        state.operator_type = (OperatorType)atoi(optarg);
        break;
      case 'k':
        state.scale_factor = atoi(optarg);
        break;
      case 's':
        state.selectivity = atof(optarg);
        break;
      case 'p':
        state.projectivity = atof(optarg);
        break;
      case 'l':
        state.layout_mode = (LayoutType)atoi(optarg);
        break;
      case 't':
        state.transactions = atoi(optarg);
        break;
      case 'e':
        state.experiment_type = (ExperimentType)atoi(optarg);
        break;
      case 'c':
        state.column_count = atoi(optarg);
        break;
      case 'w':
        state.write_ratio = atof(optarg);
        break;
      case 'g':
        state.tuples_per_tilegroup = atoi(optarg);
        break;
      case 'y':
        state.hybrid_scan_type = (HybridScanType)atoi(optarg);
        break;
      case 'i':
        state.index_count = atoi(optarg);
        break;

      case 'h':
        Usage();
        break;

      default:
        LOG_ERROR("Unknown option: -%c-", c);
        Usage();
    }
  }

  if (state.experiment_type == EXPERIMENT_TYPE_INVALID) {
    // Print configuration
    ValidateLayout(state);
    ValidateHybridScanType(state);
    ValidateOperator(state);
    ValidateSelectivity(state);
    ValidateProjectivity(state);
    ValidateScaleFactor(state);
    ValidateColumnCount(state);
    ValidateIndexCount(state);
    ValidateWriteRatio(state);
    ValidateTuplesPerTileGroup(state);

    LOG_INFO("%s : %lu", "transactions", state.transactions);
  } else {
    ValidateExperiment(state);
  }

  // cache orig scale factor
  orig_scale_factor = state.scale_factor;
}