Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/com/yahoo/sketches/ByteArrayUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

package com.yahoo.sketches;

/**
* Useful methods for byte arrays.
* @author Lee Rhodes
*/
public final class ByteArrayUtil {

/**
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/yahoo/sketches/cpc/CpcSketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
public final class CpcSketch {
private static final String LS = System.getProperty("line.separator");
private static final double[] kxpByteLookup = new double[256];

/**
* The default Log_base2 of K
*/
public static final int DEFAULT_LG_K = 11;
final long seed;
//common variables
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/com/yahoo/sketches/fdt/Group.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ public class Group implements Comparable<Group> {
private final static String hfmt =
"%12s" + "%15s" + "%15s" + "%15s" + "%12s" + "%12s" + " %s";

/**
* Construct an empty Group
*/
public Group() { }

public Group copy() {
return new Group();
}

/**
* Specifies the parameters to be listed as columns
* @param priKey the primary key of the FDT sketch
Expand Down Expand Up @@ -117,7 +116,7 @@ public String toString() {
/**
* Note: this class has a natural ordering that is inconsistent with equals.
* Ignore FindBugs EQ_COMPARETO_USE_OBJECT_EQUALS warning.
* @param that the Group to compare to
* @param that The Group to compare to
*/
@Override
public int compareTo(final Group that) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/yahoo/sketches/fdt/PostProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private List<Group> populateList(final int numStdDev, final int limit) {
final double lb = sketch.getLowerBound(numStdDev, count);
final double thresh = (double) count / sketch.getRetainedEntries();
final double rse = (sketch.getUpperBound(1, count) / est) - 1.0;
final Group gp = group.copy();
final Group gp = new Group();
gp.init(priKey, count, est, ub, lb, thresh, rse);
list.add(gp);
}
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/com/yahoo/sketches/hash/XxHash.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ public class XxHash {
private static final long P4 = -8796714831421723037L;
private static final long P5 = 2870177450012600261L;


/**
* Compute the has of the given Memory object.
* @param mem The given Memory object
* @param offsetBytes Starting at this offset in bytes
* @param lengthBytes Continuing for this number of bytes
* @param seed use this seed for the hash function
* @return return the resulting 64-bit hash value.
*/
public static long hash(final Memory mem, final long offsetBytes, final long lengthBytes,
final long seed) {
return mem.xxHash64(offsetBytes, lengthBytes, seed);
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/yahoo/sketches/hll/HllSketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,15 @@
* @author Kevin Lang
*/
public class HllSketch extends BaseHllSketch {

/**
* The default Log_base2 of K
*/
public static final int DEFAULT_LG_K = 12;

/**
* The default HLL-TYPE is HLL_4
*/
public static final TgtHllType DEFAULT_HLL_TYPE = TgtHllType.HLL_4;

private static final String LS = System.getProperty("line.separator");
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/yahoo/sketches/hll/TgtHllType.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

* @author Lee Rhodes
*/
@SuppressWarnings("javadoc")
public enum TgtHllType { HLL_4, HLL_6, HLL_8;

static final TgtHllType values[] = values();
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/yahoo/sketches/kll/KllFloatsSketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@
*/
public class KllFloatsSketch {

/**
* The default value of K.
*/
public static final int DEFAULT_K = 200;
static final int DEFAULT_M = 8;
static final int MIN_K = DEFAULT_M;
Expand Down Expand Up @@ -479,7 +482,7 @@ public float[] getQuantiles(final double[] fractions) {
final float[] quantiles = new float[fractions.length];
for (int i = 0; i < fractions.length; i++) {
final double fraction = fractions[i];
if (fraction < 0.0 || fraction > 1.0) {
if ((fraction < 0.0) || (fraction > 1.0)) {
throw new SketchesArgumentException("Fraction cannot be less than zero or greater than 1.0");
}
if (fraction == 0.0) { quantiles[i] = minValue_; }
Expand Down Expand Up @@ -848,6 +851,9 @@ public static KllFloatsSketch heapify(final Memory mem) {
return new KllFloatsSketch(mem);
}

/**
* @return the iterator for this class
*/
public KllFloatsSketchIterator iterator() {
return new KllFloatsSketchIterator(items_, levels_, numLevels_);
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/yahoo/sketches/quantiles/DoublesSketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,9 @@ public void putMemory(final WritableMemory dstMem, final boolean compact) {
}
}

/**
* @return the iterator for this class
*/
public DoublesSketchIterator iterator() {
return new DoublesSketchIterator(this, getBitPattern());
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/yahoo/sketches/quantiles/ItemsSketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -567,11 +567,17 @@ public boolean isEmpty() {
return getN() == 0;
}

/**
* @return true if this sketch is off-heap
*/
@SuppressWarnings("static-method")
public boolean isDirect() {
return false;
}

/**
* @return true if in estimation mode
*/
public boolean isEstimationMode() {
return getN() >= (2L * k_);
}
Expand Down Expand Up @@ -684,6 +690,9 @@ public void putMemory(final WritableMemory dstMem, final ArrayOfItemsSerDe<T> se
dstMem.putByteArray(0, byteArr, 0, byteArr.length);
}

/**
* @return the iterator for this class
*/
public ItemsSketchIterator<T> iterator() {
return new ItemsSketchIterator<>(this, bitPattern_);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public static UpdateDoublesSketch heapify(final Memory srcMem) {
return HeapUpdateDoublesSketch.heapifyInstance(srcMem);
}

/**
* @return a CompactDoublesSketch of this class
*/
public CompactDoublesSketch compact() {
return compact(null);
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/yahoo/sketches/sampling/SampleSubsetSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,30 @@ public class SampleSubsetSummary {
this.totalSketchWeight = totalSketchWeight;
}

/**
* @return the Lower Bound
*/
public double getLowerBound() {
return lowerBound;
}

/**
* @return the total sketch weight
*/
public double getTotalSketchWeight() {
return totalSketchWeight;
}

/**
* @return the Upper Bound
*/
public double getUpperBound() {
return upperBound;
}

/**
* @return the unique count estimate
*/
public double getEstimate() {
return estimate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ public double getWeight() {
boolean getMark() { return sketch_.getMark(idx_); }
}

// standard iterator
/**
* The standard iterator
*/
public class VarOptItemsIterator implements Iterator<WeightedSample> {
int currIdx_;
int finalIdx_; // inclusive final index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ public class ArrayOfDoublesSetOperationBuilder {
private int numValues_;
private long seed_;

/**
* Default Nominal Entries (a.k.a. K)
*/
public static final int DEFAULT_NOMINAL_ENTRIES = 4096;

/**
* Default number of values
*/
public static final int DEFAULT_NUMBER_OF_VALUES = 1;

/**
Expand All @@ -46,7 +53,7 @@ public ArrayOfDoublesSetOperationBuilder() {

/**
* This is to set the nominal number of entries.
* @param nomEntries Nominal number of entries. Forced to the nearest power of 2 greater than
* @param nomEntries Nominal number of entries. Forced to the nearest power of 2 greater than
* given value.
* @return this builder
*/
Expand Down Expand Up @@ -95,7 +102,7 @@ public ArrayOfDoublesUnion buildUnion(final WritableMemory dstMem) {
}

/**
* Creates an instance of ArrayOfDoublesIntersection based on the current configuration of the
* Creates an instance of ArrayOfDoublesIntersection based on the current configuration of the
* builder.
* The new instance is allocated on the heap if the memory is not provided.
* The number of nominal entries is not relevant to this, so it is ignored.
Expand All @@ -106,7 +113,7 @@ public ArrayOfDoublesIntersection buildIntersection() {
}

/**
* Creates an instance of ArrayOfDoublesIntersection based on the current configuration of the
* Creates an instance of ArrayOfDoublesIntersection based on the current configuration of the
* builder.
* The new instance is allocated on the heap if the memory is not provided.
* The number of nominal entries is not relevant to this, so it is ignored.
Expand Down