Skip to content

Commit 9e84273

Browse files
authored
Merge pull request #683 from apache/Cleanup_phase1
Cleanup phase 1
2 parents 0115a7e + b2aa63c commit 9e84273

63 files changed

Lines changed: 672 additions & 850 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/org/apache/datasketches/common/Family.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public enum Family {
177177
lookupFamName.put(f.getFamilyName().toUpperCase(Locale.US), f);
178178
}
179179
if (ByteOrder.nativeOrder() != ByteOrder.LITTLE_ENDIAN) {
180-
throw new BigEndianNativeOrderNotSupportedException();
180+
throw new SketchesNotSupportedException("Machine Native Endianness must be LITTLE_ENDIAN.");
181181
}
182182
}
183183

src/main/java/org/apache/datasketches/common/MemorySegmentRequest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,16 @@ default MemorySegment request(final MemorySegment prevSeg, final long newByteSiz
5050
* It is up to the user to override this as appropriate.
5151
* @param prevSeg the previous MemorySegment to be closed.
5252
*/
53-
default void requestClose(final MemorySegment prevSeg) { }
53+
default void requestClose(final MemorySegment prevSeg) {
54+
//Because the default request goes on the heap, this default is a no-op
55+
}
5456

5557
/**
5658
* This class implements the defaults
5759
*/
58-
public static class Default implements MemorySegmentRequest { }
60+
public static class Default implements MemorySegmentRequest {
61+
//A convenience class that creates the target for the static member DEFAULT.
62+
}
5963

6064
/**
6165
* Create Default as static member.

src/main/java/org/apache/datasketches/common/BigEndianNativeOrderNotSupportedException.java renamed to src/main/java/org/apache/datasketches/common/SketchesNotSupportedException.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,28 @@
2020
package org.apache.datasketches.common;
2121

2222
/**
23-
* The DataSketches Library is not supported on Big Endian machines.
23+
* This operation or mode is not supported.
24+
*
25+
* @author Lee Rhodes
2426
*/
25-
public class BigEndianNativeOrderNotSupportedException extends SketchesException {
27+
public class SketchesNotSupportedException extends SketchesException {
2628
private static final long serialVersionUID = 1L;
29+
private static final String baseStr = "This operation or mode is not supported: ";
30+
31+
//other constructors to be added as needed.
2732

2833
/**
29-
* Constructs a new runtime exception with the message:
30-
* "The DataSketches Library is not supported on Big Endian machines."
34+
* Constructs a new runtime exception with the specified detail message. The cause is not
35+
* initialized, and may subsequently be initialized by a call to
36+
* Throwable.initCause(java.lang.Throwable).
37+
*
38+
* @param message the detail message which is appended to the base message:<br>
39+
* "This operation or mode is not supported: ".
40+
*
41+
* <p>The detail message is saved for later retrieval by the Throwable.getMessage() method.</p>
3142
*/
32-
public BigEndianNativeOrderNotSupportedException() {
33-
super("The DataSketches Library is not supported on Big Endian machines.");
43+
public SketchesNotSupportedException(final String message) {
44+
super(baseStr + message);
3445
}
46+
3547
}

src/main/java/org/apache/datasketches/common/Util.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public final class Util {
4141

4242
static {
4343
if (ByteOrder.nativeOrder() != ByteOrder.LITTLE_ENDIAN) {
44-
throw new BigEndianNativeOrderNotSupportedException();
44+
throw new SketchesNotSupportedException("Machine Native Endianness must be LITTLE_ENDIAN.");
4545
}
4646
}
4747

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ boolean isRebuildCurMinNumKxQFlag() {
112112
}
113113

114114
@Override
115-
void putEmptyFlag(final boolean empty) {} //no-op for coupons
115+
void putEmptyFlag(final boolean empty) { /*no-op for coupons */ }
116116

117117
@Override
118-
void putOutOfOrder(final boolean outOfOrder) {} //no-op for coupons
118+
void putOutOfOrder(final boolean outOfOrder) { /*no-op for coupons */ }
119119

120120
@Override
121-
void putRebuildCurMinNumKxQFlag(final boolean rebuild) {} //no-op for coupons
121+
void putRebuildCurMinNumKxQFlag(final boolean rebuild) { /*no-op for coupons */ }
122122

123123
@Override
124124
byte[] toCompactByteArray() {

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ final class DirectCouponHashSet extends DirectCouponList {
5555
}
5656

5757
//Constructs this sketch with read-only data, may be compact.
58-
DirectCouponHashSet(final int lgConfigK, final TgtHllType tgtHllType, final MemorySegment seg,
59-
final boolean readOnly) {
60-
super(lgConfigK, tgtHllType, CurMode.SET, seg, true);
58+
DirectCouponHashSet(final int lgConfigK, final TgtHllType tgtHllType, final MemorySegment seg, final boolean readOnly) {
59+
super(lgConfigK, tgtHllType, CurMode.SET, seg, readOnly);
6160
assert seg.get(JAVA_BYTE, LG_K_BYTE) > 7;
6261
}
6362

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private static int checkSegCompactFlag(final MemorySegment wseg, final int lgCon
8282
final boolean readOnly) {
8383
super(lgConfigK, tgtHllType, curMode);
8484
wseg = null;
85-
this.seg = seg;
85+
this.seg = readOnly ? seg.asReadOnly() : seg;
8686
compact = extractCompactFlag(seg);
8787
}
8888

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ final class DirectHll4Array extends DirectHllArray {
5353

5454
//Called by HllSketch.wrap(MemorySegment)
5555
DirectHll4Array(final int lgConfigK, final MemorySegment seg, final boolean readOnly) {
56-
super(lgConfigK, TgtHllType.HLL_4, seg, true);
56+
super(lgConfigK, TgtHllType.HLL_4, seg, readOnly);
5757
final int auxCount = extractAuxCount(seg);
5858
if (auxCount > 0) {
5959
final boolean compact = extractCompactFlag(seg);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ final class DirectHll6Array extends DirectHllArray {
4040

4141
//Called by HllSketch.wrap(MemorySegment)
4242
DirectHll6Array(final int lgConfigK, final MemorySegment seg, final boolean readOnly) {
43-
super(lgConfigK, TgtHllType.HLL_6, seg, true);
43+
super(lgConfigK, TgtHllType.HLL_6, seg, readOnly);
4444
}
4545

4646
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ final class DirectHll8Array extends DirectHllArray {
4242

4343
//Called by HllSketch.wrap(MemorySegment)
4444
DirectHll8Array(final int lgConfigK, final MemorySegment seg, final boolean readOnly) {
45-
super(lgConfigK, TgtHllType.HLL_8, seg, true);
45+
super(lgConfigK, TgtHllType.HLL_8, seg, readOnly);
4646
}
4747

4848
@Override

0 commit comments

Comments
 (0)