Skip to content

Commit 4a020cc

Browse files
authored
Merge pull request #517 from apache/5.0.X-backport
5.0.x backport
2 parents b50100d + 14cf83b commit 4a020cc

27 files changed

+594
-410
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232

3333
# Initializes the CodeQL tools for scanning.
3434
- name: Initialize CodeQL
35-
uses: github/codeql-action/init@v2
35+
uses: github/codeql-action/init@v3
3636
with:
3737
languages: ${{ matrix.language }}
3838
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -46,7 +46,7 @@ jobs:
4646
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
4747
# If this step fails, then you should remove it and run the build manually (see below)
4848
- name: Autobuild
49-
uses: github/codeql-action/autobuild@v2
49+
uses: github/codeql-action/autobuild@v3
5050

5151
# ℹ️ Command-line programs to run using the OS shell.
5252
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -59,6 +59,6 @@ jobs:
5959
# ./location_of_script_within_repo/buildscript.sh
6060

6161
- name: Perform CodeQL Analysis
62-
uses: github/codeql-action/analyze@v2
62+
uses: github/codeql-action/analyze@v3
6363
with:
6464
category: "/language:${{matrix.language}}"

src/main/java/org/apache/datasketches/fdt/FdtSketch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
*
4747
* @author Lee Rhodes
4848
*/
49-
public class FdtSketch extends ArrayOfStringsSketch {
49+
public final class FdtSketch extends ArrayOfStringsSketch {
5050

5151
/**
5252
* Create new instance of Frequent Distinct Tuples sketch with the given

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* @author Lee Rhodes
4343
* @author Kevin Lang
4444
*/
45-
class CouponHashSet extends CouponList {
45+
final class CouponHashSet extends CouponList {
4646

4747
/**
4848
* Constructs this sketch with the intent of loading it with data

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,23 @@ class CouponList extends AbstractCoupons {
4141
int couponCount;
4242
int[] couponIntArr;
4343

44+
private static int checkLgConfigK(final CurMode curMode, final int lgConfigK) {
45+
if (curMode == CurMode.SET) { assert lgConfigK > 7; }
46+
return lgConfigK;
47+
}
48+
4449
/**
4550
* New instance constructor for LIST or SET.
4651
* @param lgConfigK the configured Lg K
4752
* @param tgtHllType the configured HLL target
4853
* @param curMode LIST or SET
4954
*/
5055
CouponList(final int lgConfigK, final TgtHllType tgtHllType, final CurMode curMode) {
51-
super(lgConfigK, tgtHllType, curMode);
56+
super(checkLgConfigK(curMode, lgConfigK), tgtHllType, curMode);
5257
if (curMode == CurMode.LIST) {
5358
lgCouponArrInts = LG_INIT_LIST_SIZE;
5459
} else { //SET
5560
lgCouponArrInts = LG_INIT_SET_SIZE;
56-
assert lgConfigK > 7;
5761
}
5862
couponIntArr = new int[1 << lgCouponArrInts];
5963
couponCount = 0;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
/**
3737
* @author Lee Rhodes
3838
*/
39-
class DirectAuxHashMap implements AuxHashMap {
39+
final class DirectAuxHashMap implements AuxHashMap {
4040
private final DirectHllArray host; //hosts the WritableMemory and read-only Memory
4141
private final boolean readOnly;
4242

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
/**
4343
* @author Lee Rhodes
4444
*/
45-
class DirectCouponHashSet extends DirectCouponList {
45+
final class DirectCouponHashSet extends DirectCouponList {
4646

4747
//Constructs this sketch with data.
4848
DirectCouponHashSet(final int lgConfigK, final TgtHllType tgtHllType,

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,21 @@ class DirectCouponList extends AbstractCoupons {
6161
Memory mem;
6262
final boolean compact;
6363

64-
//called from newInstance, writableWrap and DirectCouponHashSet
65-
DirectCouponList(final int lgConfigK, final TgtHllType tgtHllType, final CurMode curMode,
66-
final WritableMemory wmem) {
67-
super(lgConfigK, tgtHllType, curMode);
64+
private static int checkMemCompactFlag(final WritableMemory wmem, final int lgConfigK) {
65+
assert !extractCompactFlag(wmem);
66+
return lgConfigK;
67+
}
68+
69+
//called from newInstance, writableWrap and DirectCouponHashSet, must be compact
70+
DirectCouponList(final int lgConfigK, final TgtHllType tgtHllType, final CurMode curMode, final WritableMemory wmem) {
71+
super(checkMemCompactFlag(wmem, lgConfigK), tgtHllType, curMode);
6872
this.wmem = wmem;
6973
mem = wmem;
7074
compact = extractCompactFlag(wmem);
71-
assert !compact;
7275
}
7376

74-
//called from HllSketch.wrap and from DirectCouponHashSet constructor, may be compact
75-
DirectCouponList(final int lgConfigK, final TgtHllType tgtHllType, final CurMode curMode,
76-
final Memory mem) {
77+
//called from HllSketch.wrap and from DirectCouponHashSet constructor, may or may not be compact
78+
DirectCouponList(final int lgConfigK, final TgtHllType tgtHllType, final CurMode curMode, final Memory mem) {
7779
super(lgConfigK, tgtHllType, curMode);
7880
wmem = null;
7981
this.mem = mem;

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,19 @@ abstract class DirectHllArray extends AbstractHllArray {
5959
long memAdd;
6060
final boolean compact;
6161

62+
private static int checkMemCompactFlag(final WritableMemory wmem, final int lgConfigK) {
63+
assert !extractCompactFlag(wmem);
64+
return lgConfigK;
65+
}
66+
6267
//Memory must be already initialized and may have data
6368
DirectHllArray(final int lgConfigK, final TgtHllType tgtHllType, final WritableMemory wmem) {
64-
super(lgConfigK, tgtHllType, CurMode.HLL);
69+
super(checkMemCompactFlag(wmem, lgConfigK), tgtHllType, CurMode.HLL);
6570
this.wmem = wmem;
6671
mem = wmem;
6772
memObj = wmem.getArray();
6873
memAdd = wmem.getCumulativeOffset(0L);
6974
compact = extractCompactFlag(mem);
70-
assert !compact;
7175
insertEmptyFlag(wmem, false);
7276
}
7377

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* @author Lee Rhodes
3434
* @author Kevin Lang
3535
*/
36-
class HeapAuxHashMap implements AuxHashMap {
36+
final class HeapAuxHashMap implements AuxHashMap {
3737
private final int lgConfigK; //required for #slot bits
3838
private int lgAuxArrInts;
3939
private int auxCount;

src/main/java/org/apache/datasketches/hllmap/UniqueCountMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
* @author Alexander Saydakov
8181
* @author Kevin Lang
8282
*/
83-
public class UniqueCountMap {
83+
public final class UniqueCountMap {
8484
private static final String LS = System.getProperty("line.separator");
8585
private static final int NUM_LEVELS = 10; // total of single coupon + traverse + coupon maps + hll
8686
private static final int NUM_TRAVERSE_MAPS = 3;

0 commit comments

Comments
 (0)