<commit_before>/**
 * Copyright 2014 Google Inc. All Rights Reserved.
 *
 * 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.hadoop.util;

import com.google.common.base.Optional;

import org.apache.hadoop.util.VersionInfo;

/**
 * Provides information regarding the currently loaded Hadoop version.
 */
public class HadoopVersionInfo {

  private static final HadoopVersionInfo INSTANCE = new HadoopVersionInfo();
  public static HadoopVersionInfo getInstance() {
    return INSTANCE;
  }

  private Optional<Integer> majorVersion = Optional.absent();
  private Optional<Integer> minorVersion = Optional.absent();
  private Optional<Integer> patchLevel = Optional.absent();

  /**
   * Construct a HadoopVersionInfo using the version string contained in
   * {@link VersionInfo#getVersion()}.
   */
  public HadoopVersionInfo() {
    this(VersionInfo.getVersion());
  }

  /**
   * Construct a HadoopVersionInfo using the passed version string
   * @param versionString A string of the form major.minor.patch
   */
  public HadoopVersionInfo(String versionString) {
    parseVersionString(versionString);
  }

  static class ParseState {
    public final String input;
    public int currentIndex;

    ParseState(String input) {
      this.input = input;
      this.currentIndex = 0;
    }

    public void advanceInput(int characters) {
      currentIndex += characters;
    }

    public boolean isAtEndOfInput() {
      return currentIndex >= input.length();
    }

    public char currentCharacter() {
      return input.charAt(currentIndex);
    }
  }

  // version := <majorVersion> (<separator> <minorVersion>)* (<separator> <patch>)*
  // majorVersion := <numberPiece><commit_msg>Clean up javadoc build errors. 	Change on 2014/09/26 by jimmc <<EMAIL>> ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=76471626<commit_after>/**
 * Copyright 2014 Google Inc. All Rights Reserved.
 *
 * 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.hadoop.util;

import com.google.common.base.Optional;

import org.apache.hadoop.util.VersionInfo;

/**
 * Provides information regarding the currently loaded Hadoop version.
 */
public class HadoopVersionInfo {

  private static final HadoopVersionInfo INSTANCE = new HadoopVersionInfo();
  public static HadoopVersionInfo getInstance() {
    return INSTANCE;
  }

  private Optional<Integer> majorVersion = Optional.absent();
  private Optional<Integer> minorVersion = Optional.absent();
  private Optional<Integer> patchLevel = Optional.absent();

  /**
   * Construct a HadoopVersionInfo using the version string contained in
   * {@link VersionInfo#getVersion()}.
   */
  public HadoopVersionInfo() {
    this(VersionInfo.getVersion());
  }

  /**
   * Construct a HadoopVersionInfo using the passed version string
   * @param versionString A string of the form major.minor.patch
   */
  public HadoopVersionInfo(String versionString) {
    parseVersionString(versionString);
  }

  /**
   * ParseState is used by subclasses that are parsing version strings.
   */
  protected static class ParseState {
    public final String input;
    public int currentIndex;

    ParseState(String input) {
      this.input = input;
      this.currentIndex = 0;
    }

    public void advanceInput(int characters) {
      currentIndex += characters;
    }

    public boolean isAtEndOfInput() {
      return currentIndex >= input.length();
    }

    public char currentCharacter() {
      return input.charAt(currentIndex);
    }
  }

  // version := <majorVersion> (<separator> <minorVersion>)* (<separator> <patch>)*
  // majorVersion := <numberPiece>
{'fraction_non_alphanumeric': 0.0958173282116944, 'fraction_numerical': 0.007255655142979087, 'mean_word_length': 3.6498015873015874, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, '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': '3404181', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1235, 'n_words': 431}