<commit_before>/*
 * Copyright 2016, Yahoo! Inc.
 * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
 */

package com.yahoo.sketches.hive.quantiles;

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AbstractAggregationBuffer;

import com.yahoo.sketches.memory.NativeMemory;
import com.yahoo.sketches.quantiles.DoublesSketch;
import com.yahoo.sketches.quantiles.DoublesUnion;
import com.yahoo.sketches.quantiles.DoublesUnionBuilder;

class DoublesUnionState extends AbstractAggregationBuffer {

  private DoublesUnion union;

  // initializing is needed only in the first phase (iterate)
  void init(final int k) {
    final DoublesUnionBuilder unionBuilder = DoublesUnion.builder();
    if (k > 0) unionBuilder.setK(k);
    union = unionBuilder.build();
  }

  boolean isInitialized() {
    return union != null;
  }

  void update(final double value) {
    if (union == null) union = DoublesUnion.builder().build();
    union.update(value);
  }

  void update(final byte[] serializedSketch) {
    final DoublesSketch incomingSketch = DoublesSketch.heapify(new NativeMemory(serializedSketch));
    if (union == null) {
      union = DoublesUnionBuilder.build(incomingSketch);
    } else {
      union.update(incomingSketch);
    }<commit_msg>rolled back the change to static call since it was not yet static in version 0.7.0<commit_after>/*
 * Copyright 2016, Yahoo! Inc.
 * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
 */

package com.yahoo.sketches.hive.quantiles;

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AbstractAggregationBuffer;

import com.yahoo.sketches.memory.NativeMemory;
import com.yahoo.sketches.quantiles.DoublesSketch;
import com.yahoo.sketches.quantiles.DoublesUnion;
import com.yahoo.sketches.quantiles.DoublesUnionBuilder;

class DoublesUnionState extends AbstractAggregationBuffer {

  private DoublesUnion union;

  // initializing is needed only in the first phase (iterate)
  void init(final int k) {
    final DoublesUnionBuilder unionBuilder = DoublesUnion.builder();
    if (k > 0) unionBuilder.setK(k);
    union = unionBuilder.build();
  }

  boolean isInitialized() {
    return union != null;
  }

  void update(final double value) {
    if (union == null) union = DoublesUnion.builder().build();
    union.update(value);
  }

  void update(final byte[] serializedSketch) {
    final DoublesSketch incomingSketch = DoublesSketch.heapify(new NativeMemory(serializedSketch));
    if (union == null) {
      union = DoublesUnion.builder().build(incomingSketch);
    } else {
      union.update(incomingSketch);
    }
{'fraction_non_alphanumeric': 0.099925705794948, 'fraction_numerical': 0.006315007429420505, 'mean_word_length': 4.249512670565302, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5108327', 'n_tokens_mistral': 850, 'n_tokens_neox': 813, 'n_words': 207}