org.apache.datasketches.tuple.strings.ArrayOfStringsSketch Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of datasketches-java Show documentation
Show all versions of datasketches-java Show documentation
Core sketch algorithms used alone and by other Java repositories in the DataSketches library.
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.datasketches.tuple.strings;
import static org.apache.datasketches.tuple.strings.ArrayOfStringsSummary.stringArrHash;
import org.apache.datasketches.ResizeFactor;
import org.apache.datasketches.memory.Memory;
import org.apache.datasketches.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