message: [tf.data] Refactor some code from `optimize_dataset_op.cc` to `dataset_utils.cc`
diff: @@ -738,25 +738,9 @@ std::vector<tstring> ConfigureExperimentsAndSelectOptimizations(
  };
  // clang-format on
  auto hash_func = [](const string& str) { return Hash64(str); };
  - auto optimizations = SelectOptimizations(
  - job_name, live_experiments, optimizations_enabled, optimizations_disabled,
  - optimizations_default, hash_func);
  -
  - // Log and record the live experiments that will be applied.
  - if (!job_name.empty() && !live_experiments.empty()) {
  - VLOG(1) << "The input pipeline is subject to tf.data experiment. "
  - "Please see `go/tf-data-experiments` for more details.";
  -
  - for (auto& pair : live_experiments) {
  - string experiment = pair.first;
  - if (std::find(optimizations.begin(), optimizations.end(), experiment) !=
  - optimizations.end()) {
  - VLOG(1) << "The live experiment \"" << experiment << "\" is applied.";
  - metrics::RecordTFDataExperiment(experiment);
  - }
  - }
  - }
  - return optimizations;
  + return SelectOptimizations(job_name, live_experiments, optimizations_enabled,
  + optimizations_disabled, optimizations_default,
  + hash_func);
  }
  std::vector<tstring> SelectOptimizations(
  @@ -899,6 +883,21 @@ std::vector<tstring> SelectOptimizations(
  optimizations.insert(optimizations.end(), optimizations_set.begin(),
  optimizations_set.end());
  +
  + // Log and record the live experiments that will be applied.
  + if (!job_name.empty() && !live_experiments.empty()) {
  + VLOG(1) << "The input pipeline is subject to tf.data experiment. "
  + "Please see `go/tf-data-experiments` for more details.";
  +
  + for (auto& pair : live_experiments) {
  + string experiment = pair.first;
  + if (std::find(optimizations.begin(), optimizations.end(), experiment) !=
  + optimizations.end()) {
  + VLOG(1) << "The live experiment \"" << experiment << "\" is applied.";
  + metrics::RecordTFDataExperiment(experiment);
  + }
  + }
  + }
  return optimizations;
  }
  