<commit_before>// Copyright 2020 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.

package com.google.graphgeckos.dashboard.storage;

import com.google.cloud.datastore.Entity;
import com.google.cloud.datastore.StructuredQuery.OrderBy;
import com.google.cloud.datastore.StructuredQuery.PropertyFilter;
import com.google.cloud.datastore.TimestampValue;
import com.google.cloud.datastore.Query;
import com.google.cloud.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.Date;
import java.util.List;
import org.springframework.boot.SpringApplication;
import org.springframework.cloud.gcp.data.datastore.core.DatastoreTemplate;
import org.springframework.stereotype.Repository;

/**
 * Implementation of the DataRepository, with the purpose of providing I/O to the Google Cloud
 * Datastore. Each individual database entry is modeled by the {@link #BuildInfo BuildInfo} class.
 * The relevant fields for the database, which are described in that class are:
 *    - Kind: "revision"
 *    - Key: commit hash
 * The database indexes after all the BuildInfo fields, besides the {@code builders} list.
 * It is unfeasable to query after the list of builders, since it would not be possible to
 * replicate such a list without querying the database for it first, and the complexity
 * of the indexing and querying would be great, without any apparent value.
 *
 * Useful links:
 * - https://googleapis.dev/java/google-cloud-datastore/latest/index.html
 * - https://googleapis.dev/java/spring-cloud-gcp/1.2.2.RELEASE/index.html
 * - https://cloud.google.com/datastore/docs/concepts/
 * - https://spring.io/projects/spring-cloud-gcp#overview
 */
@Repository
public class GCDataRepository implements DataRepository {
  private DatastoreTemplate storage;

  /**
   * {@inheritDoc}
   */
  public void createRevisionEntry(ParsedGitData entryData) throws IllegalArgumentException {
    if (entryData == null) {
      throw new IllegalArgumentException("entryData cannot be null");
    } else if (!entryData.validCreateData()) {
      throw new IllegalArgumentException("entryData does not contain all necessary fields");
    }

    if (getRevisionEntry(entryData.getCommitHash()) == null) {<commit_msg>rename class<commit_after>// Copyright 2020 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.

package com.google.graphgeckos.dashboard.storage;

import com.google.cloud.datastore.Entity;
import com.google.cloud.datastore.StructuredQuery.OrderBy;
import com.google.cloud.datastore.StructuredQuery.PropertyFilter;
import com.google.cloud.datastore.TimestampValue;
import com.google.cloud.datastore.Query;
import com.google.cloud.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.Date;
import java.util.List;
import org.springframework.boot.SpringApplication;
import org.springframework.cloud.gcp.data.datastore.core.DatastoreTemplate;
import org.springframework.stereotype.Repository;

/**
 * Implementation of the DataRepository, with the purpose of providing I/O to the Google Cloud
 * Datastore. Each individual database entry is modeled by the {@link #BuildInfo BuildInfo} class.
 * The relevant fields for the database, which are described in that class are:
 *    - Kind: "revision"
 *    - Key: commit hash
 * The database indexes after all the BuildInfo fields, besides the {@code builders} list.
 * It is unfeasable to query after the list of builders, since it would not be possible to
 * replicate such a list without querying the database for it first, and the complexity
 * of the indexing and querying would be great, without any apparent value.
 *
 * Useful links:
 * - https://googleapis.dev/java/google-cloud-datastore/latest/index.html
 * - https://googleapis.dev/java/spring-cloud-gcp/1.2.2.RELEASE/index.html
 * - https://cloud.google.com/datastore/docs/concepts/
 * - https://spring.io/projects/spring-cloud-gcp#overview
 */
@Repository
public class DatastoreRepository implements DataRepository {
  private DatastoreTemplate storage;

  /**
   * {@inheritDoc}
   */
  public void createRevisionEntry(ParsedGitData entryData) throws IllegalArgumentException {
    if (entryData == null) {
      throw new IllegalArgumentException("entryData cannot be null");
    } else if (!entryData.validCreateData()) {
      throw new IllegalArgumentException("entryData does not contain all necessary fields");
    }

    if (getRevisionEntry(entryData.getCommitHash()) == null) {
{'fraction_non_alphanumeric': 0.0943921978404737, 'fraction_numerical': 0.0038314176245210726, 'mean_word_length': 4.377340823970037, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 10, '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': '4558016', 'n_tokens_mistral': 1561, 'n_tokens_neox': 1519, 'n_words': 531}