Skip to content

Commit 4827385

Browse files
committed
This changes the names to FrequentItemsSketch and FrequentLongsSketch.
In KLL, I changed the names of the enum constants to KLL_DOUBLES_SKETCH, etc. And the methods to isKllItmesSketch(), etc.
1 parent 5236461 commit 4827385

38 files changed

+369
-369
lines changed

src/main/java/org/apache/datasketches/frequencies/ItemsSketch.java renamed to src/main/java/org/apache/datasketches/frequencies/FrequentItemsSketch.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
* @author Justin Thaler
149149
* @author Alexander Saydakov
150150
*/
151-
public class ItemsSketch<T> {
151+
public class FrequentItemsSketch<T> {
152152

153153
/**
154154
* Log2 Maximum length of the arrays internal to the hash map supported by the data
@@ -190,7 +190,7 @@ public class ItemsSketch<T> {
190190
* 0.75 times * maxMapSize. Both the ultimate accuracy and size of this sketch are
191191
* functions of maxMapSize.
192192
*/
193-
public ItemsSketch(final int maxMapSize) {
193+
public FrequentItemsSketch(final int maxMapSize) {
194194
this(exactLog2OfInt(maxMapSize, "maxMapSize"), LG_MIN_MAP_SIZE);
195195
}
196196

@@ -205,7 +205,7 @@ public ItemsSketch(final int maxMapSize) {
205205
* @param lgCurMapSize Log2 of the starting (current) physical size of the internal hash
206206
* map managed by this sketch.
207207
*/
208-
ItemsSketch(final int lgMaxMapSize, final int lgCurMapSize) {
208+
FrequentItemsSketch(final int lgMaxMapSize, final int lgCurMapSize) {
209209
//set initial size of hash map
210210
this.lgMaxMapSize = Math.max(lgMaxMapSize, LG_MIN_MAP_SIZE);
211211
final int lgCurMapSz = Math.max(lgCurMapSize, LG_MIN_MAP_SIZE);
@@ -226,7 +226,7 @@ public ItemsSketch(final int maxMapSize) {
226226
* @param serDe an instance of ArrayOfItemsSerDe
227227
* @return a sketch instance of this class.
228228
*/
229-
public static <T> ItemsSketch<T> getInstance(final MemorySegment srcSeg,
229+
public static <T> FrequentItemsSketch<T> getInstance(final MemorySegment srcSeg,
230230
final ArrayOfItemsSerDe<T> serDe) {
231231
Objects.requireNonNull(srcSeg, "srcSeg must not be null.");
232232
Objects.requireNonNull(serDe, "serDe must not be null.");
@@ -263,13 +263,13 @@ public static <T> ItemsSketch<T> getInstance(final MemorySegment srcSeg,
263263
}
264264

265265
if (empty) {
266-
return new ItemsSketch<>(lgMaxMapSize, LG_MIN_MAP_SIZE);
266+
return new FrequentItemsSketch<>(lgMaxMapSize, LG_MIN_MAP_SIZE);
267267
}
268268
//get full preamble
269269
final long[] preArr = new long[preLongs];
270270
MemorySegment.copy(srcSeg, JAVA_LONG_UNALIGNED, 0, preArr, 0, preLongs);
271271

272-
final ItemsSketch<T> fis = new ItemsSketch<>(lgMaxMapSize, lgCurMapSize);
272+
final FrequentItemsSketch<T> fis = new FrequentItemsSketch<>(lgMaxMapSize, lgCurMapSize);
273273
fis.streamWeight = 0; //update after
274274
fis.offset = preArr[3];
275275

@@ -461,7 +461,7 @@ public boolean isEmpty() {
461461
* @return a sketch whose estimates are within the guarantees of the
462462
* largest error tolerance of the two merged sketches.
463463
*/
464-
public ItemsSketch<T> merge(final ItemsSketch<T> other) {
464+
public FrequentItemsSketch<T> merge(final FrequentItemsSketch<T> other) {
465465
if ((other == null) || other.isEmpty()) { return this; }
466466

467467
final long streamLen = streamWeight + other.streamWeight; //capture before merge
@@ -551,18 +551,18 @@ public String toString() {
551551
}
552552

553553
/**
554-
* Returns a human readable string of the preamble of a byte array image of a ItemsSketch.
554+
* Returns a human readable string of the preamble of a byte array image of a FrequentItemsSketch.
555555
* @param byteArr the given byte array
556-
* @return a human readable string of the preamble of a byte array image of a ItemsSketch.
556+
* @return a human readable string of the preamble of a byte array image of a FrequentItemsSketch.
557557
*/
558558
public static String toString(final byte[] byteArr) {
559559
return toString(MemorySegment.ofArray(byteArr));
560560
}
561561

562562
/**
563-
* Returns a human readable string of the preamble of a MemorySegment image of a ItemsSketch.
563+
* Returns a human readable string of the preamble of a MemorySegment image of a FrequentItemsSketch.
564564
* @param seg the given MemorySegment object
565-
* @return a human readable string of the preamble of a MemorySegment image of a ItemsSketch.
565+
* @return a human readable string of the preamble of a MemorySegment image of a FrequentItemsSketch.
566566
*/
567567
public static String toString(final MemorySegment seg) {
568568
return PreambleUtil.preambleToString(seg);

src/main/java/org/apache/datasketches/frequencies/LongsSketch.java renamed to src/main/java/org/apache/datasketches/frequencies/FrequentLongsSketch.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
* @author Lee Rhodes
145145
*/
146146
@SuppressFBWarnings(value = "SIC_INNER_SHOULD_BE_STATIC_ANON", justification = "Harmless, fix later")
147-
public class LongsSketch {
147+
public class FrequentLongsSketch {
148148

149149
private static final int STR_PREAMBLE_TOKENS = 6;
150150

@@ -188,7 +188,7 @@ public class LongsSketch {
188188
* 0.75 times * maxMapSize. Both the ultimate accuracy and size of this sketch are a
189189
* function of maxMapSize.
190190
*/
191-
public LongsSketch(final int maxMapSize) {
191+
public FrequentLongsSketch(final int maxMapSize) {
192192
this(exactLog2OfInt(maxMapSize, "maxMapSize"), LG_MIN_MAP_SIZE);
193193
}
194194

@@ -203,7 +203,7 @@ public LongsSketch(final int maxMapSize) {
203203
* @param lgCurMapSize Log2 of the starting (current) physical size of the internal hash
204204
* map managed by this sketch.
205205
*/
206-
LongsSketch(final int lgMaxMapSize, final int lgCurMapSize) {
206+
FrequentLongsSketch(final int lgMaxMapSize, final int lgCurMapSize) {
207207
//set initial size of hash map
208208
this.lgMaxMapSize = Math.max(lgMaxMapSize, LG_MIN_MAP_SIZE);
209209
final int lgCurMapSz = Math.max(lgCurMapSize, LG_MIN_MAP_SIZE);
@@ -222,7 +222,7 @@ public LongsSketch(final int maxMapSize) {
222222
* @param srcSeg a MemorySegment representation of a sketch of this class.
223223
* @return a sketch instance of this class.
224224
*/
225-
public static LongsSketch getInstance(final MemorySegment srcSeg) {
225+
public static FrequentLongsSketch getInstance(final MemorySegment srcSeg) {
226226
Objects.requireNonNull(srcSeg, "Source MemorySegment must not be null.");
227227
final long pre0 = PreambleUtil.checkPreambleSize(srcSeg); //check MemorySegment capacity
228228
final int maxPreLongs = Family.FREQUENCY.getMaxPreLongs();
@@ -256,13 +256,13 @@ public static LongsSketch getInstance(final MemorySegment srcSeg) {
256256
}
257257

258258
if (empty) {
259-
return new LongsSketch(lgMaxMapSize, LG_MIN_MAP_SIZE);
259+
return new FrequentLongsSketch(lgMaxMapSize, LG_MIN_MAP_SIZE);
260260
}
261261
//get full preamble
262262
final long[] preArr = new long[preLongs];
263263
MemorySegment.copy(srcSeg, JAVA_LONG_UNALIGNED, 0, preArr, 0, preLongs);
264264

265-
final LongsSketch fls = new LongsSketch(lgMaxMapSize, lgCurMapSize);
265+
final FrequentLongsSketch fls = new FrequentLongsSketch(lgMaxMapSize, lgCurMapSize);
266266
fls.streamWeight = 0; //update after
267267
fls.offset = preArr[3];
268268

@@ -294,7 +294,7 @@ public static LongsSketch getInstance(final MemorySegment srcSeg) {
294294
* @param string a String representation of a sketch of this class.
295295
* @return a sketch instance of this class.
296296
*/
297-
public static LongsSketch getInstance(final String string) {
297+
public static FrequentLongsSketch getInstance(final String string) {
298298
Objects.requireNonNull(string, "string must not be null.");
299299
final String[] tokens = string.split(",");
300300
if (tokens.length < (STR_PREAMBLE_TOKENS + 2)) {
@@ -328,7 +328,7 @@ public static LongsSketch getInstance(final String string) {
328328
+ ", numActive: " + numActive);
329329
}
330330

331-
final LongsSketch sketch = new LongsSketch(lgMax, lgCur);
331+
final FrequentLongsSketch sketch = new FrequentLongsSketch(lgMax, lgCur);
332332
sketch.streamWeight = streamWt;
333333
sketch.offset = offset;
334334
sketch.hashMap = deserializeFromStringArray(tokens);
@@ -512,7 +512,7 @@ public boolean isEmpty() {
512512
* @return a sketch whose estimates are within the guarantees of the
513513
* largest error tolerance of the two merged sketches.
514514
*/
515-
public LongsSketch merge(final LongsSketch other) {
515+
public FrequentLongsSketch merge(final FrequentLongsSketch other) {
516516
if ((other == null) || other.isEmpty()) { return this; }
517517

518518
final long streamWt = streamWeight + other.streamWeight; //capture before merge
@@ -620,18 +620,18 @@ public String toString() {
620620
}
621621

622622
/**
623-
* Returns a human readable string of the preamble of a byte array image of a LongsSketch.
623+
* Returns a human readable string of the preamble of a byte array image of a FrequentLongsSketch.
624624
* @param byteArr the given byte array
625-
* @return a human readable string of the preamble of a byte array image of a LongsSketch.
625+
* @return a human readable string of the preamble of a byte array image of a FrequentLongsSketch.
626626
*/
627627
public static String toString(final byte[] byteArr) {
628628
return toString(MemorySegment.ofArray(byteArr));
629629
}
630630

631631
/**
632-
* Returns a human readable string of the preamble of a MemorySegment image of a LongsSketch.
632+
* Returns a human readable string of the preamble of a MemorySegment image of a FrequentLongsSketch.
633633
* @param seg the given MemorySegment object
634-
* @return a human readable string of the preamble of a MemorySegment image of a LongsSketch.
634+
* @return a human readable string of the preamble of a MemorySegment image of a FrequentLongsSketch.
635635
*/
636636
public static String toString(final MemorySegment seg) {
637637
return PreambleUtil.preambleToString(seg);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import static org.apache.datasketches.kll.KllSketch.SketchStructure.COMPACT_FULL;
4545
import static org.apache.datasketches.kll.KllSketch.SketchStructure.COMPACT_SINGLE;
4646
import static org.apache.datasketches.kll.KllSketch.SketchStructure.UPDATABLE;
47-
import static org.apache.datasketches.kll.KllSketch.SketchType.DOUBLES_SKETCH;
47+
import static org.apache.datasketches.kll.KllSketch.SketchType.KLL_DOUBLES_SKETCH;
4848

4949
import java.lang.foreign.MemorySegment;
5050

@@ -111,7 +111,7 @@ static KllDirectDoublesSketch newDirectUpdatableInstance(
111111
offset += 2 * ITEM_BYTES;
112112
//new empty items array
113113
MemorySegment.copy(new double[k], 0, dstSeg, JAVA_DOUBLE_UNALIGNED, offset, k);
114-
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(dstSeg, DOUBLES_SKETCH, null);
114+
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(dstSeg, KLL_DOUBLES_SKETCH, null);
115115
final MemorySegment wSeg = dstSeg;
116116
return new KllDirectDoublesSketch(wSeg, segVal, mSegmentRequest);
117117
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import static org.apache.datasketches.kll.KllSketch.SketchStructure.COMPACT_FULL;
4545
import static org.apache.datasketches.kll.KllSketch.SketchStructure.COMPACT_SINGLE;
4646
import static org.apache.datasketches.kll.KllSketch.SketchStructure.UPDATABLE;
47-
import static org.apache.datasketches.kll.KllSketch.SketchType.FLOATS_SKETCH;
47+
import static org.apache.datasketches.kll.KllSketch.SketchType.KLL_FLOATS_SKETCH;
4848

4949
import java.lang.foreign.MemorySegment;
5050

@@ -111,7 +111,7 @@ static KllDirectFloatsSketch newDirectUpdatableInstance(
111111
offset += 2 * ITEM_BYTES;
112112
//new empty items array
113113
MemorySegment.copy(new float[k], 0, dstSeg, JAVA_FLOAT_UNALIGNED, offset, k);
114-
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(dstSeg, FLOATS_SKETCH, null);
114+
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(dstSeg, KLL_FLOATS_SKETCH, null);
115115
final MemorySegment wSeg = dstSeg;
116116
return new KllDirectFloatsSketch(wSeg, segVal, mSegmentRequest);
117117
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import static org.apache.datasketches.kll.KllSketch.SketchStructure.COMPACT_FULL;
4545
import static org.apache.datasketches.kll.KllSketch.SketchStructure.COMPACT_SINGLE;
4646
import static org.apache.datasketches.kll.KllSketch.SketchStructure.UPDATABLE;
47-
import static org.apache.datasketches.kll.KllSketch.SketchType.LONGS_SKETCH;
47+
import static org.apache.datasketches.kll.KllSketch.SketchType.KLL_LONGS_SKETCH;
4848

4949
import java.lang.foreign.MemorySegment;
5050

@@ -111,7 +111,7 @@ static KllDirectLongsSketch newDirectUpdatableInstance(
111111
offset += 2 * ITEM_BYTES;
112112
//new empty items array
113113
MemorySegment.copy(new long[k], 0, dstSeg, JAVA_LONG_UNALIGNED, offset, k);
114-
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(dstSeg, LONGS_SKETCH, null);
114+
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(dstSeg, KLL_LONGS_SKETCH, null);
115115
final MemorySegment wSeg = dstSeg;
116116
return new KllDirectLongsSketch(wSeg, segVal, mSegmentRequest);
117117
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import static java.lang.Math.min;
2424
import static org.apache.datasketches.common.ByteArrayUtil.putDoubleLE;
2525
import static org.apache.datasketches.kll.KllSketch.SketchStructure.UPDATABLE;
26-
import static org.apache.datasketches.kll.KllSketch.SketchType.DOUBLES_SKETCH;
26+
import static org.apache.datasketches.kll.KllSketch.SketchType.KLL_DOUBLES_SKETCH;
2727

2828
import java.lang.foreign.MemorySegment;
2929
import java.util.Arrays;
@@ -51,7 +51,7 @@ public abstract class KllDoublesSketch extends KllSketch implements QuantilesDou
5151
* @param sketchStructure the current sketch structure
5252
*/
5353
KllDoublesSketch(final SketchStructure sketchStructure) {
54-
super(SketchType.DOUBLES_SKETCH, sketchStructure);
54+
super(SketchType.KLL_DOUBLES_SKETCH, sketchStructure);
5555
}
5656

5757
/**
@@ -167,7 +167,7 @@ public static KllDoublesSketch wrap(final MemorySegment srcSeg) {
167167
*/
168168
public static KllDoublesSketch wrap(final MemorySegment srcSeg, final MemorySegmentRequest mSegReq) {
169169
Objects.requireNonNull(srcSeg, "Parameter 'srcSeg' must not be null");
170-
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(srcSeg, DOUBLES_SKETCH);
170+
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(srcSeg, KLL_DOUBLES_SKETCH);
171171
return new KllDirectDoublesSketch(srcSeg, segVal, mSegReq);
172172
}
173173

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import static java.lang.Math.min;
2424
import static org.apache.datasketches.common.ByteArrayUtil.putFloatLE;
2525
import static org.apache.datasketches.kll.KllSketch.SketchStructure.UPDATABLE;
26-
import static org.apache.datasketches.kll.KllSketch.SketchType.FLOATS_SKETCH;
26+
import static org.apache.datasketches.kll.KllSketch.SketchType.KLL_FLOATS_SKETCH;
2727

2828
import java.lang.foreign.MemorySegment;
2929
import java.util.Arrays;
@@ -51,7 +51,7 @@ public abstract class KllFloatsSketch extends KllSketch implements QuantilesFloa
5151
* @param sketchStructure the current sketch structure
5252
*/
5353
KllFloatsSketch(final SketchStructure sketchStructure) {
54-
super(SketchType.FLOATS_SKETCH, sketchStructure);
54+
super(SketchType.KLL_FLOATS_SKETCH, sketchStructure);
5555
}
5656

5757
/**
@@ -167,7 +167,7 @@ public static KllFloatsSketch wrap(final MemorySegment srcSeg) {
167167
*/
168168
public static KllFloatsSketch wrap(final MemorySegment srcSeg, final MemorySegmentRequest mSegReq) {
169169
Objects.requireNonNull(srcSeg, "Parameter 'srcSeg' must not be null");
170-
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(srcSeg, FLOATS_SKETCH);
170+
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(srcSeg, KLL_FLOATS_SKETCH);
171171
return new KllDirectFloatsSketch(srcSeg, segVal, mSegReq);
172172
}
173173

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import static org.apache.datasketches.kll.KllSketch.SketchStructure.COMPACT_FULL;
2828
import static org.apache.datasketches.kll.KllSketch.SketchStructure.COMPACT_SINGLE;
2929
import static org.apache.datasketches.kll.KllSketch.SketchStructure.UPDATABLE;
30-
import static org.apache.datasketches.kll.KllSketch.SketchType.DOUBLES_SKETCH;
30+
import static org.apache.datasketches.kll.KllSketch.SketchType.KLL_DOUBLES_SKETCH;
3131

3232
import java.lang.foreign.MemorySegment;
3333
import java.util.Arrays;
@@ -154,7 +154,7 @@ else if (segStructure == COMPACT_FULL) {
154154

155155
static KllHeapDoublesSketch heapifyImpl(final MemorySegment srcSeg) {
156156
Objects.requireNonNull(srcSeg, "Parameter 'srcSeg' must not be null");
157-
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(srcSeg, DOUBLES_SKETCH);
157+
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(srcSeg, KLL_DOUBLES_SKETCH);
158158
return new KllHeapDoublesSketch(srcSeg, segVal);
159159
}
160160

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import static org.apache.datasketches.kll.KllSketch.SketchStructure.COMPACT_FULL;
2828
import static org.apache.datasketches.kll.KllSketch.SketchStructure.COMPACT_SINGLE;
2929
import static org.apache.datasketches.kll.KllSketch.SketchStructure.UPDATABLE;
30-
import static org.apache.datasketches.kll.KllSketch.SketchType.FLOATS_SKETCH;
30+
import static org.apache.datasketches.kll.KllSketch.SketchType.KLL_FLOATS_SKETCH;
3131

3232
import java.lang.foreign.MemorySegment;
3333
import java.util.Arrays;
@@ -154,7 +154,7 @@ else if (segStructure == COMPACT_FULL) {
154154

155155
static KllHeapFloatsSketch heapifyImpl(final MemorySegment srcSeg) {
156156
Objects.requireNonNull(srcSeg, "Parameter 'srcSeg' must not be null");
157-
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(srcSeg, FLOATS_SKETCH);
157+
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(srcSeg, KLL_FLOATS_SKETCH);
158158
return new KllHeapFloatsSketch(srcSeg, segVal);
159159
}
160160

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ final class KllHeapItemsSketch<T> extends KllItemsSketch<T> {
111111
final Comparator<? super T> comparator,
112112
final ArrayOfItemsSerDe<T> serDe) {
113113
super(SketchStructure.UPDATABLE, comparator, serDe);
114-
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(srcSeg, SketchType.ITEMS_SKETCH, serDe);
114+
final KllMemorySegmentValidate segVal = new KllMemorySegmentValidate(srcSeg, SketchType.KLL_ITEMS_SKETCH, serDe);
115115
k = segVal.k;
116116
m = segVal.m;
117117
levelsArr = segVal.levelsArr;

0 commit comments

Comments
 (0)