Skip to content

Commit 7c39955

Browse files
committed
Improved javadocs for main code.
1 parent de0d96e commit 7c39955

26 files changed

+270
-15
lines changed

src/main/java/org/apache/datasketches/cpc/CompressionCharacterization.java

+15
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ public class CompressionCharacterization {
6868
private CompressedState[] compressedStates2;
6969
private CpcSketch[] unCompressedSketches;
7070

71+
/**
72+
* Only used in test.
73+
* @param lgMinK min lgK
74+
* @param lgMaxK max lgK
75+
* @param lgMinT min lgTrials
76+
* @param lgMaxT max lgTrials
77+
* @param lgMulK lg multiple
78+
* @param uPPO unique axis Points Per Octave
79+
* @param incLgK increment lgK
80+
* @param pS PrintStream
81+
* @param pW PrintWriter
82+
*/
7183
@SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "This is OK here")
7284
public CompressionCharacterization(
7385
final int lgMinK,
@@ -91,6 +103,9 @@ public CompressionCharacterization(
91103
assembleFormats();
92104
}
93105

106+
/**
107+
* Only used in test
108+
*/
94109
public void start() {
95110
printf(hfmt, (Object[]) hStrArr); //print header
96111
doRangeOfLgK();

src/main/java/org/apache/datasketches/filters/bloomfilter/BloomFilter.java

+16-2
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@
5454
* false positive probability.</p>
5555
*
5656
* <p>This implementation uses xxHash64 and follows the approach in Kirsch and Mitzenmacher,
57-
* "Less Hashing, Same Performance: Building a Better Bloom Filter," Wiley Interscience, 2008,
58-
* pp. 187-218.</p>
57+
* "Less Hashing, Same Performance: Building a Better Bloom Filter," Wiley Interscience, 2008, pp. 187-218.</p>
5958
*/
6059
public final class BloomFilter {
60+
/**
61+
* The maximum size of a bloom filter in bits.
62+
*/
6163
public static final long MAX_SIZE_BITS = (Integer.MAX_VALUE - Family.BLOOMFILTER.getMaxPreLongs()) * (long) Long.SIZE;
6264
private static final int SER_VER = 1;
6365
private static final int EMPTY_FLAG_MASK = 4;
@@ -133,11 +135,23 @@ public static BloomFilter heapify(final Memory mem) {
133135
return internalHeapifyOrWrap((WritableMemory) mem, false, false);
134136
}
135137

138+
/**
139+
* Wraps the given Memory into this filter class. The class itself only contains a few metadata items and holds
140+
* a reference to the Memory object, which contains all the data.
141+
* @param mem the given Memory object
142+
* @return the wrapping BloomFilter class.
143+
*/
136144
public static BloomFilter wrap(final Memory mem) {
137145
// casting to writable, but tracking that the object is read-only
138146
return internalHeapifyOrWrap((WritableMemory) mem, true, false);
139147
}
140148

149+
/**
150+
* Wraps the given WritableMemory into this filter class. The class itself only contains a few metadata items and holds
151+
* a reference to the Memory object, which contains all the data.
152+
* @param wmem the given WritableMemory object
153+
* @return the wrapping BloomFilter class.
154+
*/
141155
public static BloomFilter writableWrap(final WritableMemory wmem) {
142156
return internalHeapifyOrWrap(wmem, true, true);
143157
}

src/main/java/org/apache/datasketches/filters/bloomfilter/DirectBitArrayR.java

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
import org.apache.datasketches.memory.Memory;
2525
import org.apache.datasketches.memory.WritableMemory;
2626

27+
/**
28+
* This class can maintain the BitArray object off-heap.
29+
*/
2730
public class DirectBitArrayR extends BitArray {
2831
final static protected long NUM_BITS_OFFSET = Long.BYTES;
2932
final static protected long DATA_OFFSET = 2L * Long.BYTES;

src/main/java/org/apache/datasketches/hll/TgtHllType.java

+18-1
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,27 @@
5050
* </ul>
5151
* @author Lee Rhodes
5252
*/
53-
public enum TgtHllType { HLL_4, HLL_6, HLL_8;
53+
public enum TgtHllType {
54+
/**
55+
* An HLL sketch with a bin size of 4 bits
56+
*/
57+
HLL_4,
58+
/**
59+
* An HLL sketch with a bin size of 6 bits
60+
*/
61+
HLL_6,
62+
/**
63+
* An Hll Sketch with a bin size of 8 bits
64+
*/
65+
HLL_8;
5466

5567
private static final TgtHllType values[] = values();
5668

69+
/**
70+
* Convert the typeId to the enum type
71+
* @param typeId the given typeId
72+
* @return the enum type
73+
*/
5774
public static final TgtHllType fromOrdinal(final int typeId) {
5875
return values[typeId];
5976
}

src/main/java/org/apache/datasketches/kll/KllItemsSketch.java

+4
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,10 @@ public void reset() {
290290
itemsSV = null;
291291
}
292292

293+
/**
294+
* Export the current sketch as a compact byte array.
295+
* @return the current sketch as a compact byte array.
296+
*/
293297
public byte[] toByteArray() {
294298
return KllHelper.toByteArray(this, false);
295299
}

src/main/java/org/apache/datasketches/kll/KllItemsSketchIterator.java

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
/**
2525
* Iterator over KllItemsSketch. The order is not defined.
26+
* @param <T> the item class type
2627
*/
2728
public final class KllItemsSketchIterator<T> extends KllSketchIterator implements QuantilesGenericSketchIterator<T> {
2829
private final Object[] quantiles;

src/main/java/org/apache/datasketches/kll/KllSketch.java

+42-3
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ public boolean hasMemory() {
218218
return (wmem != null);
219219
}
220220

221+
/**
222+
* Returns true if this sketch is in a Compact Memory Format.
223+
* @return true if this sketch is in a Compact Memory Format.
224+
*/
221225
public boolean isCompactMemoryFormat() {
222226
return hasMemory() && sketchStructure != UPDATABLE;
223227
}
@@ -488,9 +492,18 @@ final void setLevelsArrayAt(final int index, final int idxVal) {
488492
* Used to define the variable type of the current instance of this class.
489493
*/
490494
public enum SketchType {
491-
DOUBLES_SKETCH(Double.BYTES, "DoublesSketch"),
492-
FLOATS_SKETCH(Float.BYTES, "FloatsSketch"),
493-
ITEMS_SKETCH(0, "ItemsSketch");
495+
/**
496+
* KllDoublesSketch
497+
*/
498+
DOUBLES_SKETCH(Double.BYTES, "KllDoublesSketch"),
499+
/**
500+
* KllFloatsSketch
501+
*/
502+
FLOATS_SKETCH(Float.BYTES, "KllFloatsSketch"),
503+
/**
504+
* KllItemsSketch
505+
*/
506+
ITEMS_SKETCH(0, "KllItemsSketch");
494507

495508
private int typeBytes;
496509
private String name;
@@ -500,18 +513,30 @@ private SketchType(final int typeBytes, final String name) {
500513
this.name = name;
501514
}
502515

516+
/**
517+
* Gets the item size in bytes. If the item is generic, this returns zero.
518+
* @return the item size in bytes
519+
*/
503520
public int getBytes() { return typeBytes; }
504521

522+
/**
523+
* Get the name of the associated sketch
524+
* @return the name of the associated sketch
525+
*/
505526
public String getName() { return name; }
506527
}
507528

508529
/**
509530
* Used primarily to define the structure of the serialized sketch. Also used by the Heap Sketch.
510531
*/
511532
public enum SketchStructure {
533+
/** Compact Empty Structure */
512534
COMPACT_EMPTY(PREAMBLE_INTS_EMPTY_SINGLE, SERIAL_VERSION_EMPTY_FULL),
535+
/** Compact Single Item Structure */
513536
COMPACT_SINGLE(PREAMBLE_INTS_EMPTY_SINGLE, SERIAL_VERSION_SINGLE),
537+
/** Compact Full Preamble Structure */
514538
COMPACT_FULL(PREAMBLE_INTS_FULL, SERIAL_VERSION_EMPTY_FULL),
539+
/** Updatable Preamble Structure */
515540
UPDATABLE(PREAMBLE_INTS_FULL, SERIAL_VERSION_UPDATABLE); //also used by the heap sketch.
516541

517542
private int preInts;
@@ -522,10 +547,24 @@ private SketchStructure(final int preInts, final int serVer) {
522547
this.serVer = serVer;
523548
}
524549

550+
/**
551+
* gets the Preamble Integers for this Structure.
552+
* @return the Preamble Integers for this Structure
553+
*/
525554
public int getPreInts() { return preInts; }
526555

556+
/**
557+
* gets the Serialization Version for this Structure.
558+
* @return the Serialization Version for this Structure.
559+
*/
527560
public int getSerVer() { return serVer; }
528561

562+
/**
563+
* gets the SketchStructure given preInts and serVer.
564+
* @param preInts the given preamble size in integers
565+
* @param serVer the given Serialization Version
566+
* @return the SketchStructure given preInts and serVer.
567+
*/
529568
public static SketchStructure getSketchStructure(final int preInts, final int serVer) {
530569
final SketchStructure[] ssArr = SketchStructure.values();
531570
for (int i = 0; i < ssArr.length; i++) {

src/main/java/org/apache/datasketches/partitions/BoundsRule.java

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
package org.apache.datasketches.partitions;
2121

22+
/**
23+
* This instructs the user about which of the upper and lower bounds of a partition definition row
24+
* should be included with the returned data.
25+
*/
2226
public enum BoundsRule {
2327

2428
/**
@@ -30,10 +34,12 @@ public enum BoundsRule {
3034
* Include only the upper bound but not the lower bound
3135
*/
3236
INCLUDE_UPPER,
37+
3338
/**
3439
* Include only the lower bound but not the upper bound
3540
*/
3641
INCLUDE_LOWER,
42+
3743
/**
3844
* Include none
3945
*/

src/main/java/org/apache/datasketches/partitions/Partitioner.java

+21
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,22 @@ private void partitionSearch(final ArrayDeque<StackElement<T>> stack) {
162162

163163
/**
164164
* Holds data for a Stack element
165+
* @param <T> the item class type
165166
*/
166167
public static class StackElement<T> {
168+
/** A reference to the relevant GenericPartitionBoundaries class */
167169
public final GenericPartitionBoundaries<T> gpb;
170+
/** The partition index */
168171
public int part;
172+
/** A brief string description of the partition and its hierarchy */
169173
public String levelPartId;
170174

175+
/**
176+
* Constructs this StackElement
177+
* @param gpb the given GenericPartitionBoundarie reference
178+
* @param part The partition index
179+
* @param levelPartId A brief string description of the partition and its hierarchy
180+
*/
171181
public StackElement(final GenericPartitionBoundaries<T> gpb, final int part, final String levelPartId) {
172182
this.gpb = gpb;
173183
this.part = part;
@@ -177,15 +187,26 @@ public StackElement(final GenericPartitionBoundaries<T> gpb, final int part, fin
177187

178188
/**
179189
* Defines a row for List of PartitionBounds.
190+
* @param <T> the item class type
180191
*/
181192
public static class PartitionBoundsRow<T> {
193+
/** The partition index */
182194
public int part;
195+
/** A brief string description of the partition and its hierarchy */
183196
public String levelPartId;
197+
/** The approximate number of items represented by this partition description row. */
184198
public long approxNumDeltaItems;
199+
/** The BoundsRule for this partition description row. */
185200
public BoundsRule rule;
201+
/** The lower bound value */
186202
public T lowerBound;
203+
/** The upper bound value */
187204
public T upperBound;
188205

206+
/**
207+
* The constructor for the StackElement class.
208+
* @param se the given stack element.
209+
*/
189210
public PartitionBoundsRow(final StackElement<T> se) {
190211
final GenericPartitionBoundaries<T> gpb = se.gpb;
191212
final QuantileSearchCriteria searchCrit = gpb.getSearchCriteria();

src/main/java/org/apache/datasketches/partitions/SketchFillRequest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
/**
2626
* This is a callback request to the data source to fill a quantiles sketch,
2727
* which is returned to the caller.
28-
*
28+
* @param <T> the item class type
29+
* @param <S> the sketch type
2930
* @author Lee Rhodes
3031
*/
3132
public interface SketchFillRequest<T, S extends QuantilesGenericAPI<T> & PartitioningFeature<T>> {

src/main/java/org/apache/datasketches/quantilescommon/DoublesSortedViewIterator.java

+6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
public final class DoublesSortedViewIterator extends SortedViewIterator {
2626
private final double[] quantiles;
2727

28+
/**
29+
* Constructor.
30+
* @param quantiles the given array of quantiles, which must be ordered.
31+
* @param cumWeights the given array of cumulative weights, which must be ordered, start with the value one, and
32+
* the last value must be equal to N, the total number of items updated to the sketch.
33+
*/
2834
public DoublesSortedViewIterator(final double[] quantiles, final long[] cumWeights) {
2935
super(cumWeights);
3036
this.quantiles = quantiles; //SpotBugs EI_EXPOSE_REP2 suppressed by FindBugsExcludeFilter

src/main/java/org/apache/datasketches/quantilescommon/FloatsSortedViewIterator.java

+6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
public final class FloatsSortedViewIterator extends SortedViewIterator {
2626
private final float[] quantiles;
2727

28+
/**
29+
* Constructor.
30+
* @param quantiles the given array of quantiles, which must be ordered.
31+
* @param cumWeights the given array of cumulative weights, which must be ordered, start with the value one, and
32+
* the last value must be equal to N, the total number of items updated to the sketch.
33+
*/
2834
public FloatsSortedViewIterator(final float[] quantiles, final long[] cumWeights) {
2935
super(cumWeights);
3036
this.quantiles = quantiles; //SpotBugs EI_EXPOSE_REP2 suppressed by FindBugsExcludeFilter

src/main/java/org/apache/datasketches/quantilescommon/GenericPartitionBoundaries.java

+11
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
/**
2828
* This defines the returned results of the getParitionBoundaries() function and
2929
* includes the basic methods needed to construct actual partitions.
30+
* @param <T> the item class type
3031
*/
3132
public final class GenericPartitionBoundaries<T> {
3233
private long totalN; //totalN of source sketch
@@ -40,6 +41,16 @@ public final class GenericPartitionBoundaries<T> {
4041
private long[] numDeltaItems; //num of items in each partition
4142
private int numPartitions; //num of partitions
4243

44+
/**
45+
* Constructor.
46+
* @param totalN the total number of items input to the sketch.
47+
* @param boundaries The quantile boundaries between partitions
48+
* @param natRanks The array of natural Ranks corresponding to the array of boundaries.
49+
* @param normRanks The normalized Ranks corresponding to the array of boundaries.
50+
* @param maxItem the maximum item of the stream.
51+
* @param minItem the minimum item of the stream.
52+
* @param searchCrit the user defined search criteria
53+
*/
4354
public GenericPartitionBoundaries(
4455
final long totalN,
4556
final T[] boundaries,

src/main/java/org/apache/datasketches/quantilescommon/GenericSortedViewIterator.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,17 @@
2323

2424
/**
2525
* Iterator over quantile sketches of generic type.
26-
* @param <T> The generic quantile type
26+
* @param <T> The generic item class type
2727
*/
2828
public class GenericSortedViewIterator<T> extends SortedViewIterator {
2929
private final T[] quantiles;
3030

31+
/**
32+
* Constructor
33+
* @param quantiles the given array of quantiles
34+
* @param cumWeights the array of cumulative weights, corresponding to the array of quantiles,
35+
* starting with the value one and the end value must equal N, the total number of items input to the sketch.
36+
*/
3137
public GenericSortedViewIterator(final T[] quantiles, final long[] cumWeights) {
3238
super(cumWeights);
3339
this.quantiles = quantiles; //SpotBugs EI_EXPOSE_REP2 suppressed by FindBugsExcludeFilter

0 commit comments

Comments
 (0)