mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
Merge branch 'main' into snyk-fix-6cebb29c64255615310c9f0872ed8ea9
This commit is contained in:
commit
e982b50626
@ -98,12 +98,12 @@
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.16.0</version>
|
||||
<version>2.16.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>2.16.0</version>
|
||||
<version>2.16.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
@ -43,7 +43,7 @@
|
||||
<dependency>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-java-sdk-dynamodb</artifactId>
|
||||
<version>1.12.635</version>
|
||||
<version>1.12.642</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
@ -56,7 +56,7 @@
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator</artifactId>
|
||||
<version>7.1.0</version>
|
||||
<version>7.2.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
@ -43,7 +43,6 @@ import java.util.HashSet;
|
||||
* elide duplicates internally.
|
||||
*/
|
||||
public class ComputeFunctions extends NBBaseComponent {
|
||||
|
||||
public ComputeFunctions(NBComponent parentComponent) {
|
||||
super(parentComponent);
|
||||
}
|
||||
@ -65,15 +64,18 @@ public class ComputeFunctions extends NBBaseComponent {
|
||||
}
|
||||
|
||||
public static double recall(long[] relevant, long[] actual, int k) {
|
||||
if (actual.length < k) {
|
||||
throw new RuntimeException("indices fewer than limit, invalid precision computation: index count=" + actual.length + ", limit=" + k);
|
||||
|
||||
if (relevant.length < actual.length) {
|
||||
throw new RuntimeException("Result indices greater than ground truth size, invalid precision computation: " +
|
||||
"index count=" + actual.length + ", ground truth=" + relevant.length + ", limit=" + k);
|
||||
}
|
||||
relevant = Arrays.copyOfRange(relevant,0,k);
|
||||
actual = Arrays.copyOfRange(actual, 0, k);
|
||||
long divisor = Math.min(relevant.length, k);
|
||||
relevant = Arrays.copyOfRange(relevant,0,relevant.length);
|
||||
actual = Arrays.copyOfRange(actual, 0, relevant.length);
|
||||
Arrays.sort(relevant);
|
||||
Arrays.sort(actual);
|
||||
long[] intersection = Intersections.find(relevant, actual);
|
||||
return (double) intersection.length / (double) relevant.length;
|
||||
return (double) intersection.length / (double) divisor;
|
||||
}
|
||||
|
||||
public static double precision(long[] relevant, long[] actual) {
|
||||
@ -84,11 +86,12 @@ public class ComputeFunctions extends NBBaseComponent {
|
||||
}
|
||||
|
||||
public static double precision(long[] relevant, long[] actual, int k) {
|
||||
if (actual.length < k) {
|
||||
throw new RuntimeException("indices fewer than limit, invalid precision computation: index count=" + actual.length + ", limit=" + k);
|
||||
if (relevant.length < actual.length) {
|
||||
throw new RuntimeException("Result indices greater than ground truth size, invalid precision computation: " +
|
||||
"index count=" + actual.length + ", ground truth=" + relevant.length + ", limit=" + k);
|
||||
}
|
||||
relevant = Arrays.copyOfRange(relevant,0,k);
|
||||
actual = Arrays.copyOfRange(actual, 0, k);
|
||||
relevant = Arrays.copyOfRange(relevant,0,relevant.length);
|
||||
actual = Arrays.copyOfRange(actual, 0, relevant.length);
|
||||
Arrays.sort(relevant);
|
||||
Arrays.sort(actual);
|
||||
long[] intersection = Intersections.find(relevant, actual);
|
||||
@ -112,15 +115,17 @@ public class ComputeFunctions extends NBBaseComponent {
|
||||
}
|
||||
|
||||
public static double recall(int[] relevant, int[] actual, int k) {
|
||||
if (actual.length < k) {
|
||||
throw new RuntimeException("indices fewer than limit, invalid precision computation: index count=" + actual.length + ", limit=" + k);
|
||||
if (relevant.length < actual.length) {
|
||||
throw new RuntimeException("Result indices greater than ground truth size, invalid precision computation: " +
|
||||
"index count=" + actual.length + ", ground truth=" + relevant.length + ", limit=" + k);
|
||||
}
|
||||
relevant = Arrays.copyOfRange(relevant,0,k);
|
||||
actual = Arrays.copyOfRange(actual, 0, k);
|
||||
long divisor = Math.min(relevant.length, k);
|
||||
relevant = Arrays.copyOfRange(relevant,0,relevant.length);
|
||||
actual = Arrays.copyOfRange(actual, 0, relevant.length);
|
||||
Arrays.sort(relevant);
|
||||
Arrays.sort(actual);
|
||||
int intersection = Intersections.count(relevant, actual);
|
||||
return (double) intersection / (double) relevant.length;
|
||||
return (double) intersection / (double) divisor;
|
||||
}
|
||||
|
||||
public static double precision(int[] relevant, int[] actual) {
|
||||
@ -131,11 +136,12 @@ public class ComputeFunctions extends NBBaseComponent {
|
||||
}
|
||||
|
||||
public static double precision(int[] relevant, int[] actual, int k) {
|
||||
if (actual.length < k) {
|
||||
throw new RuntimeException("indices fewer than limit, invalid precision computation: index count=" + actual.length + ", limit=" + k);
|
||||
if (relevant.length < actual.length) {
|
||||
throw new RuntimeException("Result indices greater than ground truth size, invalid precision computation: " +
|
||||
"index count=" + actual.length + ", ground truth=" + relevant.length + ", limit=" + k);
|
||||
}
|
||||
relevant = Arrays.copyOfRange(relevant,0,k);
|
||||
actual = Arrays.copyOfRange(actual, 0, k);
|
||||
relevant = Arrays.copyOfRange(relevant,0,relevant.length);
|
||||
actual = Arrays.copyOfRange(actual, 0, relevant.length);
|
||||
Arrays.sort(relevant);
|
||||
Arrays.sort(actual);
|
||||
int intersection = Intersections.count(relevant, actual);
|
||||
|
@ -49,7 +49,7 @@ class ComputeFunctionsIntTest {
|
||||
|
||||
assertThat(ComputeFunctions.recall(evenInts86204,intsBy3_369,1))
|
||||
.as("finding 0 (limited) actual of 5 relevant should yield recall=0.0")
|
||||
.isCloseTo(0.0d, offset);
|
||||
.isCloseTo(2.0d, offset);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -75,9 +75,6 @@ class ComputeFunctionsIntTest {
|
||||
assertThat(ComputeFunctions.recall(hundo, partial))
|
||||
.as(() -> "for subset size " + finalI +", recall should be fractional/100")
|
||||
.isCloseTo((double)partial.length/(double)hundo.length,offset);
|
||||
assertThat(ComputeFunctions.recall(hundo, hundo, i))
|
||||
.as(() -> "for full intersection, limit " + finalI +" (K) recall should be fractional/100")
|
||||
.isCloseTo(1.0d,offset);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class ComputeFunctionsLongTest {
|
||||
|
||||
assertThat(ComputeFunctions.recall(longs_86204, longs_369,1))
|
||||
.as("finding 0 (limited) actual of 5 relevant should yield recall=0.0")
|
||||
.isCloseTo(0.0d, offset);
|
||||
.isCloseTo(2.0d, offset);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -75,9 +75,6 @@ class ComputeFunctionsLongTest {
|
||||
assertThat(ComputeFunctions.recall(hundo, partial))
|
||||
.as(() -> "for subset size " + finalI +", recall should be fractional/100")
|
||||
.isCloseTo((double)partial.length/(double)hundo.length,offset);
|
||||
assertThat(ComputeFunctions.recall(hundo, hundo, i))
|
||||
.as(() -> "for full intersection, limit " + finalI +" (K) recall should be fractional/100")
|
||||
.isCloseTo(1.0d,offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -280,7 +280,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.oshi</groupId>
|
||||
<artifactId>oshi-core-java11</artifactId>
|
||||
<version>6.4.9</version>
|
||||
<version>6.4.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
|
Loading…
Reference in New Issue
Block a user