mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
nosqlbench-828 nosqlbench-824
This commit is contained in:
parent
97cf9a32cb
commit
7737ffc0f9
@ -47,7 +47,7 @@ public class TriangularStepFunction implements LongUnaryOperator {
|
||||
private final long variance;
|
||||
|
||||
|
||||
@Example({"TriangularStepFunction(100,20)","Create a sequence of values where the average and median is 100, but the range of values is between 90 and 120."})
|
||||
@Example({"TriangularStepFunction(100,20)","Create a sequence of values where the average and median is 100, but the range of values is between 80 and 120."})
|
||||
@Example({"TriangularStepFunction(80,10)","Create a sequence of values where the average and median is 80, but the range of values is between 70 and 90."})
|
||||
TriangularStepFunction(long average, long variance) {
|
||||
if (variance < 0 || variance > average) {
|
||||
@ -63,9 +63,6 @@ public class TriangularStepFunction implements LongUnaryOperator {
|
||||
|
||||
TriangularStepFunction(long average) {
|
||||
this(average, average/2);
|
||||
// if (maxOffset>=avgsize) {
|
||||
// throw new RuntimeException("max offset " + maxOffset + " has to be less than avg size " + avgsize);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -85,10 +82,6 @@ public class TriangularStepFunction implements LongUnaryOperator {
|
||||
return result;
|
||||
}
|
||||
|
||||
public long inlined(long operand) {
|
||||
return (operand < operand - operand % median + sizer.applyAsLong(operand - operand % median)) ? operand / median : operand / median + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getClass().getSimpleName()+"{median="+median+",variance="+variance+"}";
|
||||
|
@ -48,30 +48,6 @@ public class TriangularStepFunctionTest {
|
||||
assertThat(IntStream.of(runLengths).max().orElseThrow()).isEqualTo(90L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStepSlice() {
|
||||
int avgsize=10;
|
||||
TriangularStepFunction f = new TriangularStepFunction(avgsize);
|
||||
int[] ary = new int[avgsize*2];
|
||||
long current=0L;
|
||||
int count=0;
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
long result = f.applyAsLong(i);
|
||||
if (result==current) {
|
||||
count++;
|
||||
} else {
|
||||
ary[count]++;
|
||||
current=result;
|
||||
count=0;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < ary.length; i++) {
|
||||
System.out.println("bucket " + i + ", count " + ary[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testIncrementalVariance() {
|
||||
TriangularStepFunction f = new TriangularStepFunction(100, 0);
|
||||
@ -141,6 +117,5 @@ public class TriangularStepFunctionTest {
|
||||
stats.accept(count);
|
||||
}
|
||||
return stats;
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user