Merge pull request #351 from apache/MinorUpdates
Minor updates
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 698d6c6..f20252f 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -4,6 +4,7 @@
pull_request:
push:
branches: [ master ]
+ workflow_dispatch:
env:
MAVEN_OPTS: -Xmx4g -Xms1g
diff --git a/pom.xml b/pom.xml
index a27a23e..9faa58e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -189,8 +189,8 @@
<artifactId>versions-maven-plugin</artifactId>
<version>${versions-maven-plugin.version}</version>
</plugin>
- <plugin>
+ <plugin>
<!-- We want to deploy the artifacts to a staging location for perusal -->
<!-- Apache Parent pom: apache-release profile -->
<groupId>org.apache.maven.plugins</groupId>
@@ -362,7 +362,7 @@
<goals>
<goal>report</goal>
</goals>
- </execution>
+ </execution>
</executions>
</plugin>
diff --git a/src/main/java/org/apache/datasketches/frequencies/ReversePurgeItemHashMap.java b/src/main/java/org/apache/datasketches/frequencies/ReversePurgeItemHashMap.java
index 796c9b4..f80896b 100644
--- a/src/main/java/org/apache/datasketches/frequencies/ReversePurgeItemHashMap.java
+++ b/src/main/java/org/apache/datasketches/frequencies/ReversePurgeItemHashMap.java
@@ -71,7 +71,7 @@
* @return true if the cell in the array contains an active key
*/
boolean isActive(final int probe) {
- return (states[probe] > 0);
+ return states[probe] > 0;
}
/**
@@ -84,7 +84,7 @@
if (key == null) { return 0; }
final int probe = hashProbe(key);
if (states[probe] > 0) {
- assert (keys[probe]).equals(key);
+ assert keys[probe].equals(key);
return values[probe];
}
return 0;
@@ -92,7 +92,7 @@
/**
* Increments the value mapped to the key if the key is present in the map. Otherwise,
- * the key is inserted with the putAmount.
+ * the key is inserted with the adjustAmount.
*
* @param key the key of the value to increment
* @param adjustAmount the amount by which to increment the value
@@ -102,15 +102,15 @@
int probe = (int) hash(key.hashCode()) & arrayMask;
int drift = 1;
while (states[probe] != 0 && !keys[probe].equals(key)) {
- probe = (probe + 1) & arrayMask;
+ probe = probe + 1 & arrayMask;
drift++;
//only used for theoretical analysis
- assert (drift < DRIFT_LIMIT) : "drift: " + drift + " >= DRIFT_LIMIT";
+ assert drift < DRIFT_LIMIT : "drift: " + drift + " >= DRIFT_LIMIT";
}
if (states[probe] == 0) {
// adding the key to the table the value
- assert (numActive <= loadThreshold)
+ assert numActive <= loadThreshold
: "numActive: " + numActive + " > loadThreshold: " + loadThreshold;
keys[probe] = key;
values[probe] = adjustAmount;
@@ -118,7 +118,7 @@
numActive++;
} else {
// adjusting the value of an existing key
- assert (keys[probe].equals(key));
+ assert keys[probe].equals(key);
values[probe] += adjustAmount;
}
}
@@ -178,7 +178,7 @@
j++;
}
}
- assert (j == numActive) : "j: " + j + " != numActive: " + numActive;
+ assert j == numActive : "j: " + j + " != numActive: " + numActive;
return returnedKeys;
}
@@ -195,7 +195,7 @@
j++;
}
}
- assert (j == numActive);
+ assert j == numActive;
return returnedValues;
}
@@ -306,7 +306,7 @@
states[deleteProbe] = 0; //mark as empty
int drift = 1;
final int arrayMask = keys.length - 1;
- int probe = (deleteProbe + drift) & arrayMask; //map length must be a power of 2
+ int probe = deleteProbe + drift & arrayMask; //map length must be a power of 2
// advance until you find a free location replacing locations as needed
while (states[probe] != 0) {
if (states[probe] > drift) {
@@ -319,10 +319,10 @@
drift = 0;
deleteProbe = probe;
}
- probe = (probe + 1) & arrayMask;
+ probe = probe + 1 & arrayMask;
drift++;
//only used for theoretical analysis
- assert (drift < DRIFT_LIMIT) : "drift: " + drift + " >= DRIFT_LIMIT";
+ assert drift < DRIFT_LIMIT : "drift: " + drift + " >= DRIFT_LIMIT";
}
}
@@ -330,13 +330,13 @@
final int arrayMask = keys.length - 1;
int probe = (int) hash(key.hashCode()) & arrayMask;
while (states[probe] > 0 && !keys[probe].equals(key)) {
- probe = (probe + 1) & arrayMask;
+ probe = probe + 1 & arrayMask;
}
return probe;
}
Iterator<T> iterator() {
- return new Iterator<T>(keys, values, states, numActive);
+ return new Iterator<>(keys, values, states, numActive);
}
// This iterator uses strides based on golden ratio to avoid clustering during merge
@@ -364,13 +364,13 @@
}
boolean next() {
- i_ = (i_ + stride_) & mask_;
+ i_ = i_ + stride_ & mask_;
while (count_ < numActive_) {
if (states_[i_] > 0) {
count_++;
return true;
}
- i_ = (i_ + stride_) & mask_;
+ i_ = i_ + stride_ & mask_;
}
return false;
}
diff --git a/src/main/java/org/apache/datasketches/req/ReqAuxiliary.java b/src/main/java/org/apache/datasketches/req/ReqAuxiliary.java
index 06074af..c329ba4 100644
--- a/src/main/java/org/apache/datasketches/req/ReqAuxiliary.java
+++ b/src/main/java/org/apache/datasketches/req/ReqAuxiliary.java
@@ -146,16 +146,11 @@
float getQuantile(final double normRank, final boolean ltEq) {
final int len = weights.length;
final long rank = (int)(normRank * N);
- final int index;
- final InequalitySearch crit;
- if (ltEq) { //less-than or equals
- crit = InequalitySearch.GE;
- index = InequalitySearch.find(weights, 0, len - 1, rank, crit);
- if (index == -1) { return items[len - 1]; }
- } else { //less-than
- crit = InequalitySearch.GT;
- index = InequalitySearch.find(weights, 0, len - 1, rank, crit);
- if (index == -1) { return items[len - 1]; }
+ //Note that when ltEq=false, GT matches KLL & Quantiles behavior.
+ final InequalitySearch crit = ltEq ? InequalitySearch.GE : InequalitySearch.GT;
+ final int index = InequalitySearch.find(weights, 0, len - 1, rank, crit);
+ if (index == -1) {
+ return items[len - 1]; //resolves high end (GE & GT) -1 only!
}
return items[index];
}
diff --git a/tools/SketchesCheckstyle.xml b/tools/SketchesCheckstyle.xml
index 03a69c3..a51083d 100644
--- a/tools/SketchesCheckstyle.xml
+++ b/tools/SketchesCheckstyle.xml
@@ -39,7 +39,7 @@
<property name="fileExtensions" value="java"/>
<module name="BeforeExecutionExclusionFileFilter">
- <property name="fileNamePattern" value="src/test/java/.+$"/>
+ <property name="fileNamePattern" value="src/test/java/.+$"/>
</module>
<module name="FileTabCharacter">