All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yahoo.sketches.tuple.strings.ArrayOfStringsSketch Maven / Gradle / Ivy

There is a newer version: 0.6.0
Show newest version
/*
 * Copyright 2019, 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.tuple.strings;

import static com.yahoo.sketches.tuple.strings.ArrayOfStringsSummary.stringArrHash;

import com.yahoo.memory.Memory;
import com.yahoo.sketches.ResizeFactor;
import com.yahoo.sketches.tuple.UpdatableSketch;

/**
 * @author Lee Rhodes
 */
public class ArrayOfStringsSketch extends UpdatableSketch {

  /**
   * Constructs new sketch with default K = 4096 (lgK = 12), default ResizeFactor=X8,
   * and default p = 1.0.
   */
  public ArrayOfStringsSketch() {
    this(12);
  }

  /**
   * Constructs new sketch with default ResizeFactor=X8, default p = 1.0 and given lgK.
   * @param lgK Log_base2 of Nominal Entries.
   * See Nominal Entries
   */
  public ArrayOfStringsSketch(final int lgK) {
    this(lgK, ResizeFactor.X8, 1.0F);
  }

  /**
   * Constructs new sketch with given ResizeFactor, p and lgK.
   * @param lgK Log_base2 of Nominal Entries.
   * See Nominal Entries
   * @param rf ResizeFactor
   * See Resize Factor
   * @param p sampling probability
   * See Sampling Probability
   */
  public ArrayOfStringsSketch(final int lgK, final ResizeFactor rf, final float p) {
    super(1 << lgK, rf.lg(), p, new ArrayOfStringsSummaryFactory());
  }

  /**
   * Constructs this sketch from a Memory image, which must be from an ArrayOfStringsSketch, and
   * usually with data.
   * @param mem the given Memory
   */
  public ArrayOfStringsSketch(final Memory mem) {
    super(mem, new ArrayOfStringsSummaryDeserializer(), new ArrayOfStringsSummaryFactory());
  }

  /**
   * Updates the sketch with String arrays for both key and value.
   * @param strArrKey the given String array key
   * @param strArr the given String array value
   */
  public void update(final String[] strArrKey, final String[] strArr) {
    super.update(stringArrHash(strArrKey), strArr);
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy