Skip to content

Commit 5aa035c

Browse files
committed
Clean up.
Corrected random cases of "mem" variables that should have been refactored to "seg".
1 parent 779bb92 commit 5aa035c

11 files changed

Lines changed: 44 additions & 45 deletions

File tree

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -137,55 +137,55 @@ static CompressedState importFromSegment(final MemorySegment seg) {
137137
break;
138138
}
139139
case SPARSE_HYBRID_MERGED : {
140-
//state.fiCol = getFiCol(mem);
140+
//state.fiCol = getFiCol(seg;
141141
state.numCoupons = getNumCoupons(seg);
142142
state.numCsv = (int) state.numCoupons; //only true for sparse_hybrid
143143
state.csvLengthInts = getSvLengthInts(seg);
144-
//state.cwLength = getCwLength(mem);
145-
//state.kxp = getKxP(mem);
146-
//state.hipEstAccum = getHipAccum(mem);
144+
//state.cwLength = getCwLength(seg;
145+
//state.kxp = getKxP(seg;
146+
//state.hipEstAccum = getHipAccum(seg;
147147
checkCapacity(seg.byteSize(), state.getRequiredSerializedBytes());
148-
//state.cwStream = getCwStream(mem);
148+
//state.cwStream = getCwStream(seg;
149149
state.csvStream = getSvStream(seg);
150150
break;
151151
}
152152
case SPARSE_HYBRID_HIP : {
153-
//state.fiCol = getFiCol(mem);
153+
//state.fiCol = getFiCol(seg;
154154
state.numCoupons = getNumCoupons(seg);
155155
state.numCsv = (int) state.numCoupons; //only true for sparse_hybrid
156156
state.csvLengthInts = getSvLengthInts(seg);
157-
//state.cwLength = getCwLength(mem);
157+
//state.cwLength = getCwLength(seg;
158158
state.kxp = getKxP(seg);
159159
state.hipEstAccum = getHipAccum(seg);
160160
checkCapacity(seg.byteSize(), state.getRequiredSerializedBytes());
161-
//state.cwStream = getCwStream(mem);
161+
//state.cwStream = getCwStream(seg;
162162
state.csvStream = getSvStream(seg);
163163
break;
164164
}
165165
case PINNED_SLIDING_MERGED_NOSV : {
166166
state.fiCol = getFiCol(seg);
167167
state.numCoupons = getNumCoupons(seg);
168-
//state.numCsv = getNumCsv(mem);
169-
//state.csvLength = getCsvLength(mem);
168+
//state.numCsv = getNumCsv(seg;
169+
//state.csvLength = getCsvLength(seg;
170170
state.cwLengthInts = getWLengthInts(seg);
171-
//state.kxp = getKxP(mem);
172-
//state.hipEstAccum = getHipAccum(mem);
171+
//state.kxp = getKxP(seg;
172+
//state.hipEstAccum = getHipAccum(seg;
173173
checkCapacity(seg.byteSize(), state.getRequiredSerializedBytes());
174174
state.cwStream = getWStream(seg);
175-
//state.csvStream = getCsvStream(mem);
175+
//state.csvStream = getCsvStream(seg;
176176
break;
177177
}
178178
case PINNED_SLIDING_HIP_NOSV : {
179179
state.fiCol = getFiCol(seg);
180180
state.numCoupons = getNumCoupons(seg);
181-
//state.numCsv = getNumCsv(mem);
182-
//state.csvLength = getCsvLength(mem);
181+
//state.numCsv = getNumCsv(seg;
182+
//state.csvLength = getCsvLength(seg;
183183
state.cwLengthInts = getWLengthInts(seg);
184184
state.kxp = getKxP(seg);
185185
state.hipEstAccum = getHipAccum(seg);
186186
checkCapacity(seg.byteSize(), state.getRequiredSerializedBytes());
187187
state.cwStream = getWStream(seg);
188-
//state.csvStream = getCsvStream(mem);
188+
//state.csvStream = getCsvStream(seg;
189189
break;
190190
}
191191
case PINNED_SLIDING_MERGED : {
@@ -194,8 +194,8 @@ static CompressedState importFromSegment(final MemorySegment seg) {
194194
state.numCsv = getNumSv(seg);
195195
state.csvLengthInts = getSvLengthInts(seg);
196196
state.cwLengthInts = getWLengthInts(seg);
197-
//state.kxp = getKxP(mem);
198-
//state.hipEstAccum = getHipAccum(mem);
197+
//state.kxp = getKxP(seg;
198+
//state.hipEstAccum = getHipAccum(seg;
199199
checkCapacity(seg.byteSize(), state.getRequiredSerializedBytes());
200200
state.cwStream = getWStream(seg);
201201
state.csvStream = getSvStream(seg);

src/main/java/org/apache/datasketches/frequencies/PreambleUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static long checkPreambleSize(final MemorySegment seg) {
253253
private static void throwNotBigEnough(final long cap, final int required) {
254254
throw new SketchesArgumentException(
255255
"Possible Corruption: "
256-
+ "Size of byte array or Memory not large enough for Preamble: Size: " + cap
256+
+ "Size of byte array or MemorySegment not large enough for Preamble: Size: " + cap
257257
+ ", Required: " + required);
258258
}
259259

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private static int checkSegCompactFlag(final MemorySegment wseg, final int lgCon
6868
return lgConfigK;
6969
}
7070

71-
//Memory must be already initialized and may have data. Writable, must not be Compact.
71+
//MemorySegment must be already initialized and may have data. Writable, must not be Compact.
7272
DirectHllArray(final int lgConfigK, final TgtHllType tgtHllType, final MemorySegment wseg) {
7373
super(checkSegCompactFlag(wseg, lgConfigK), tgtHllType, CurMode.HLL);
7474
this.wseg = wseg;
@@ -78,7 +78,7 @@ private static int checkSegCompactFlag(final MemorySegment wseg, final int lgCon
7878
insertEmptyFlag(wseg, false);
7979
}
8080

81-
//Memory must already be initialized and should have data. Read-only. May be Compact or not
81+
//MemorySegment must already be initialized and should have data. Read-only. May be Compact or not
8282
DirectHllArray(final int lgConfigK, final TgtHllType tgtHllType, final MemorySegment seg, final boolean readOnly) {
8383
super(lgConfigK, tgtHllType, CurMode.HLL);
8484
wseg = null;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static int checkLgK(final int lgK) {
8484
static void checkSegSize(final long minBytes, final long capBytes) {
8585
if (capBytes < minBytes) {
8686
throw new SketchesArgumentException(
87-
"Given WritableMemory is not large enough: " + capBytes);
87+
"Given MemorySegment is not large enough: " + capBytes);
8888
}
8989
}
9090

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import java.lang.foreign.MemorySegment;
2626

2727
/**
28-
* Iterates within a given Memory extracting integer pairs.
28+
* Iterates within a given MemorySegment extracting integer pairs.
2929
*
3030
* @author Lee Rhodes
3131
*/

src/main/java/org/apache/datasketches/hll/package-info.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
*
3535
* <p>Accuracy for very small streams can be important because Big Data is often fragmented into millions of smaller
3636
* streams (or segments) that inevitably are power-law distributed in size. If you are sketching all these fragments,
37-
* as a general rule, more than 80% of your sketches will be very small, 20% will be much larger, and only a few very
38-
* large in cardinality.
37+
* as a general rule, more than 80% of your sketches will be very small, 20% will be much larger, and only a few will
38+
* be very large in cardinality.</p>
3939
*
4040
* <h4>HIP / Martingale Estimator</h4>
4141
* When obtaining a cardinality estimate, the sketch automatically determines if it was the result of the capture of
@@ -96,7 +96,7 @@
9696
* terms of update time, but has the smallest storage footprint of about <i>K/2 * 1.03</i> bytes.
9797
*
9898
* <h3>Off-Heap Operation</h3>
99-
* This HLL sketch also offers the capability of operating off-heap. Given a <i>WritableMemory[5]</i> object
99+
* This HLL sketch also offers the capability of operating off-heap. Given a <i>MemorySegment[5]</i> object
100100
* created by the user, the sketch will perform all of its updates and internal phase transitions
101101
* in that object, which can actually reside either on-heap or off-heap based on how it was
102102
* configured. In large systems that must update and union many millions of sketches, having the
@@ -146,9 +146,8 @@
146146
<i>Back to the Future: an Even More Nearly Optimal Cardinality Estimation Algorithm.</i></a>
147147
* arXiv 1708.06839, August 22, 2017, Yahoo Research.
148148
*
149-
* <p>[5] Memory Component,
150-
* <a href="https://datasketches.apache.org/docs/Memory/MemoryComponent.html">
151-
<i>DataSketches Memory Component</i></a>
149+
* <p>[5] MemorySegment Component, See
150+
* <a href="https://openjdk.org/jeps/454"><i>JEP 454: Foreign Function & Memory API</i></a>
152151
*
153152
* <p>[6] MacBook Pro 2.3 GHz 8-Core Intel Core i9
154153
*

src/main/java/org/apache/datasketches/thetacommon/HashOperations.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,18 +229,18 @@ public static int hashSearchMemorySegment(final MemorySegment seg, final int lgA
229229
* @param lgArrLongs The log_base2(hashTable.length.
230230
* <a href="{@docRoot}/resources/dictionary.html#lgArrLongs">See lgArrLongs</a>.
231231
* @param hash value that must not be zero and will be inserted into the array into an empty slot.
232-
* @param memOffsetBytes offset in the writable <i>MemorySegment</i> where the hashTable starts
232+
* @param segOffsetBytes offset in the writable <i>MemorySegment</i> where the hashTable starts
233233
* @return index of insertion. Always positive or zero.
234234
*/
235235
public static int hashInsertOnlyMemorySegment(final MemorySegment wseg, final int lgArrLongs,
236-
final long hash, final int memOffsetBytes) {
236+
final long hash, final int segOffsetBytes) {
237237
final int arrayMask = (1 << lgArrLongs) - 1; // current Size -1
238238
final int stride = getStride(hash, lgArrLongs);
239239
int curProbe = (int) (hash & arrayMask);
240240
// search for duplicate or zero
241241
final int loopIndex = curProbe;
242242
do {
243-
final int curProbeOffsetBytes = (curProbe << 3) + memOffsetBytes;
243+
final int curProbeOffsetBytes = (curProbe << 3) + segOffsetBytes;
244244
final long curArrayHash = wseg.get(JAVA_LONG_UNALIGNED, curProbeOffsetBytes);
245245
if (curArrayHash == EMPTY) {
246246
wseg.set(JAVA_LONG_UNALIGNED, curProbeOffsetBytes, hash);
@@ -262,18 +262,18 @@ public static int hashInsertOnlyMemorySegment(final MemorySegment wseg, final in
262262
* <a href="{@docRoot}/resources/dictionary.html#lgArrLongs">See lgArrLongs</a>.
263263
* @param hash The hash value to be potentially inserted into an empty slot only if it is not
264264
* a duplicate of any other hash value in the table. It must not be zero.
265-
* @param memOffsetBytes offset in the writable <i>MemorySegment</i> where the hash array starts
265+
* @param segOffsetBytes offset in the writable <i>MemorySegment</i> where the hash array starts
266266
* @return index &ge; 0 if found (duplicate); &lt; 0 if inserted, inserted at -(index + 1).
267267
*/
268268
public static int hashSearchOrInsertMemorySegment(final MemorySegment wseg, final int lgArrLongs,
269-
final long hash, final int memOffsetBytes) {
269+
final long hash, final int segOffsetBytes) {
270270
final int arrayMask = (1 << lgArrLongs) - 1; // current Size -1
271271
final int stride = getStride(hash, lgArrLongs);
272272
int curProbe = (int) (hash & arrayMask);
273273
// search for duplicate or zero
274274
final int loopIndex = curProbe;
275275
do {
276-
final int curProbeOffsetBytes = (curProbe << 3) + memOffsetBytes;
276+
final int curProbeOffsetBytes = (curProbe << 3) + segOffsetBytes;
277277
final long curArrayHash = wseg.get(JAVA_LONG_UNALIGNED, curProbeOffsetBytes);
278278
if (curArrayHash == EMPTY) {
279279
wseg.set(JAVA_LONG_UNALIGNED, curProbeOffsetBytes, hash);

src/test/java/org/apache/datasketches/cpc/CompressedStateTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private void updateStateUnion(final CpcSketch sk) {
6565
}
6666

6767
@Test
68-
public void checkLoadMemory() {
68+
public void checkLoadMemorySegment() {
6969
printf("%8s %8s %10s %35s\n", "vIn", "c", "Flavor", "Format");
7070
final CpcSketch sk = new CpcSketch(lgK);
7171
final int k = 1 << lgK;

src/test/java/org/apache/datasketches/filters/bloomfilter/DirectBitArrayRTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
public class DirectBitArrayRTest {
3939

40-
private static MemorySegment bitArrayToMemory(final HeapBitArray ba) {
40+
private static MemorySegment bitArrayToMemorySegment(final HeapBitArray ba) {
4141
// assumes we're using small enough an array to test that
4242
// size can be measured with an int
4343
final int numBytes = (int) ba.getSerializedSizeBytes();
@@ -53,7 +53,7 @@ public void createBitArrayTest() {
5353
final HeapBitArray hba = new HeapBitArray(119);
5454
assertTrue(hba.isEmpty());
5555

56-
final MemorySegment seg = bitArrayToMemory(hba);
56+
final MemorySegment seg = bitArrayToMemorySegment(hba);
5757
final DirectBitArrayR dba = DirectBitArrayR.wrap(seg, hba.isEmpty());
5858
assertTrue(dba.isEmpty());
5959
assertEquals(dba.getCapacity(), 128); // nearest multiple of 64
@@ -92,7 +92,7 @@ public void basicOperationTest() {
9292
assertTrue(hba.getBit(68));
9393
assertFalse(hba.isEmpty());
9494

95-
final MemorySegment seg = bitArrayToMemory(hba);
95+
final MemorySegment seg = bitArrayToMemorySegment(hba);
9696
final DirectBitArrayR dba = DirectBitArrayR.wrap(seg, hba.isEmpty());
9797
assertEquals(dba.getNumBitsSet(), 6);
9898
assertTrue(dba.getBit(68));
@@ -118,7 +118,7 @@ public void countBitsWhenDirty() {
118118
assertTrue(hba.getBit(68));
119119
assertFalse(hba.isEmpty());
120120

121-
final MemorySegment seg = bitArrayToMemory(hba);
121+
final MemorySegment seg = bitArrayToMemorySegment(hba);
122122
final DirectBitArrayR dba = DirectBitArrayR.wrap(seg, hba.isEmpty());
123123
assertEquals(dba.getNumBitsSet(), 6);
124124
assertTrue(dba.getBit(68));
@@ -130,7 +130,7 @@ public void countBitsWhenDirty() {
130130
public void bitAddressOutOfBoundsEmptyTest() {
131131
final int numBits = 256;
132132
final HeapBitArray hba = new HeapBitArray(numBits);
133-
final MemorySegment seg = bitArrayToMemory(hba);
133+
final MemorySegment seg = bitArrayToMemorySegment(hba);
134134
final DirectBitArrayR dba = DirectBitArrayR.wrap(seg, hba.isEmpty());
135135
assertFalse(dba.getBit(19)); // in range
136136
assertFalse(dba.getBit(-10)); // out of bounds
@@ -145,7 +145,7 @@ public void bitAddressOutOfBoundsNonEmptyTest() {
145145
hba.getAndSetBit(i);
146146
}
147147

148-
final MemorySegment seg = bitArrayToMemory(hba);
148+
final MemorySegment seg = bitArrayToMemorySegment(hba);
149149
final DirectBitArrayR dba = DirectBitArrayR.wrap(seg, hba.isEmpty());
150150
assertThrows(IndexOutOfBoundsException.class, () -> dba.getBit(-10));
151151
assertThrows(IndexOutOfBoundsException.class, () -> dba.getBit(2048));
@@ -159,7 +159,7 @@ public void checkInvalidMethods() {
159159
hba.getAndSetBit(i);
160160
}
161161

162-
final MemorySegment seg = bitArrayToMemory(hba);
162+
final MemorySegment seg = bitArrayToMemorySegment(hba);
163163
final DirectBitArrayR dba = DirectBitArrayR.wrap(seg, hba.isEmpty());
164164

165165
// all of these try to modify a read-only MemorySegment

src/test/java/org/apache/datasketches/hll/CouponListTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private static void toByteArrayHeapify(final int lgK) {
145145
}
146146

147147
@Test
148-
public void checkGetMemory() {
148+
public void checkGetMemorySegment() {
149149
final HllSketch sk1 = new HllSketch(4);
150150
final AbstractCoupons absCoup = (AbstractCoupons) sk1.hllSketchImpl;
151151
assertNull(absCoup.getMemorySegment());

0 commit comments

Comments
 (0)