<commit_before>/* Copyright 2019 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "ml_metadata/metadata_store/metadata_access_object_factory.h"

#include <memory>

#include "absl/memory/memory.h"
#include "absl/status/status.h"
#include "ml_metadata/metadata_store/query_config_executor.h"
#include "ml_metadata/metadata_store/rdbms_metadata_access_object.h"
#include "ml_metadata/util/return_utils.h"

namespace ml_metadata {

namespace {
// Creates MetadataAccessObject (MAO) with the input query config and the
// MetadataSource and returns the created MAO pointer.
// The query config has template queries and other config information.
// The MetadataSource is used to execute specific queries.
absl::Status CreateRDBMSMetadataAccessObject(
    const MetadataSourceQueryConfig& query_config,
    MetadataSource* const metadata_source, absl::optional<int64> schema_version,
    std::unique_ptr<MetadataAccessObject>* result) {
  if (!metadata_source->is_connected())
    MLMD_RETURN_IF_ERROR(metadata_source->Connect());
  std::unique_ptr<QueryExecutor> executor =
      schema_version && *schema_version != query_config.schema_version()
          ? absl::WrapUnique(new QueryConfigExecutor(
                query_config, metadata_source, *schema_version))
          : absl::WrapUnique(
                new QueryConfigExecutor(query_config, metadata_source));
  *result =
      absl::WrapUnique(new RDBMSMetadataAccessObject(std::move(executor)));
  return absl::OkStatus();
}


}  // namespace

absl::Status CreateMetadataAccessObject(
    const MetadataSourceQueryConfig& query_config,<commit_msg>Makes `enable_bufferwrite` available for MLMD Service through CDPush.<commit_after>/* Copyright 2019 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "ml_metadata/metadata_store/metadata_access_object_factory.h"

#include <memory>

#include "absl/memory/memory.h"
#include "absl/status/status.h"
#include "ml_metadata/metadata_store/query_config_executor.h"
#include "ml_metadata/metadata_store/rdbms_metadata_access_object.h"
#include "ml_metadata/proto/metadata_source.pb.h"
#include "ml_metadata/util/return_utils.h"

namespace ml_metadata {

namespace {
// Creates MetadataAccessObject (MAO) with the input query config and the
// MetadataSource and returns the created MAO pointer.
// The query config has template queries and other config information.
// The MetadataSource is used to execute specific queries.
absl::Status CreateRDBMSMetadataAccessObject(
    const MetadataSourceQueryConfig& query_config,
    MetadataSource* const metadata_source, absl::optional<int64> schema_version,
    std::unique_ptr<MetadataAccessObject>* result) {
  if (!metadata_source->is_connected())
    MLMD_RETURN_IF_ERROR(metadata_source->Connect());
  std::unique_ptr<QueryExecutor> executor =
      schema_version && *schema_version != query_config.schema_version()
          ? absl::WrapUnique(new QueryConfigExecutor(
                query_config, metadata_source, *schema_version))
          : absl::WrapUnique(
                new QueryConfigExecutor(query_config, metadata_source));
  *result =
      absl::WrapUnique(new RDBMSMetadataAccessObject(std::move(executor)));
  return absl::OkStatus();
}


}  // namespace

absl::Status CreateMetadataAccessObject(
    const MetadataSourceQueryConfig& query_config,
{'fraction_non_alphanumeric': 0.11643528884908196, 'fraction_numerical': 0.0044782803403493054, 'mean_word_length': 5.318246110325318, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '935361', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1174, 'n_words': 358}