<commit_before>/*
 * Copyright (C) 2014 Google Inc.
 *
 * 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
 *
 * http://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.cloud.genomics.dataflow.readers;

import com.google.api.services.genomics.model.Read;
import com.google.api.services.genomics.model.SearchReadsRequest;
import com.google.api.services.genomics.model.SearchReadsResponse;
import com.google.cloud.genomics.dataflow.utils.GenomicsApi;

import java.io.IOException;

public class ReadReader extends GenomicsApiReader<SearchReadsRequest, Read> {
private String readFields;
  
  public ReadReader(String accessToken, String apiKey, String readFields) {
    super(accessToken, apiKey);
    this.readFields = readFields;
  }

  @Override
  protected void processApiCall(GenomicsApi api, ProcessContext c, SearchReadsRequest request)
      throws IOException {

    do {
      SearchReadsResponse response = api.executeRequest(
          api.getService().reads().search(request), readFields);

      if (response.getReads() == null) {
        break;
      }

      for (Read read : response.getReads()) {
        c.output(read);
      }
      request.setPageToken(response.getNextPageToken());
    } while (request.getPageToken() != null);
  }<commit_msg>Added logging to readreader<commit_after>/*
 * Copyright (C) 2014 Google Inc.
 *
 * 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
 *
 * http://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.cloud.genomics.dataflow.readers;

import com.google.api.services.genomics.model.Read;
import com.google.api.services.genomics.model.SearchReadsRequest;
import com.google.api.services.genomics.model.SearchReadsResponse;
import com.google.cloud.genomics.dataflow.utils.GenomicsApi;

import java.io.IOException;
import java.util.logging.Logger;

public class ReadReader extends GenomicsApiReader<SearchReadsRequest, Read> {
  private static final Logger LOG = Logger.getLogger(ReadReader.class.getName());
  private String readFields;
  
  public ReadReader(String accessToken, String apiKey, String readFields) {
    super(accessToken, apiKey);
    this.readFields = readFields;
  }

  @Override
  protected void processApiCall(GenomicsApi api, ProcessContext c, SearchReadsRequest request)
      throws IOException {
    long total = 0;
    do {
      SearchReadsResponse response = api.executeRequest(
          api.getService().reads().search(request), readFields);

      if (response.getReads() == null) {
        break;
      }
      
      for (Read read : response.getReads()) {
        c.output(read);
      }
      
      total += response.getReads().size();
      LOG.info("Read " + total + " reads");
      request.setPageToken(response.getNextPageToken());
    } while (request.getPageToken() != null);
  }
{'fraction_non_alphanumeric': 0.09740259740259741, 'fraction_numerical': 0.0045995670995671, 'mean_word_length': 3.8012987012987014, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '1090587', 'n_tokens_mistral': 1046, 'n_tokens_neox': 1009, 'n_words': 311}