mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-20 11:38:28 -06:00
nosqlbench-79 Add tests for ratio 0 - fixed bug
This commit is contained in:
parent
81682d70c1
commit
06ad034a6a
@ -83,7 +83,9 @@ public class BucketSequencer<T> implements ElementSequencer<T> {
|
|||||||
for (int i = 0; i < elems.size(); i++) {
|
for (int i = 0; i < elems.size(); i++) {
|
||||||
T elem = elems.get(i);
|
T elem = elems.get(i);
|
||||||
long ratio = ratios.get(i);
|
long ratio = ratios.get(i);
|
||||||
buckets.add(new OpBucket<>(elem,i,ratio));
|
if (ratio>0) {
|
||||||
|
buckets.add(new OpBucket<>(elem,i,ratio));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while(!buckets.isEmpty()) {
|
while(!buckets.isEmpty()) {
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
package io.nosqlbench.engine.api.activityapi.planning;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
public class BucketSequencerTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBasicRatios() {
|
||||||
|
BucketSequencer<String> buckets = new BucketSequencer<>();
|
||||||
|
int[] ints = buckets.seqIndexesByRatios(List.of("a","b","c"), List.of(0L, 2L, 3L));
|
||||||
|
assertThat(ints).containsExactly(1,2,1,2,2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -40,10 +40,17 @@ public class ConcatSequencerTest {
|
|||||||
assertThat(ints).containsExactly(0,0,1,1,1,1,1);
|
assertThat(ints).containsExactly(0,0,1,1,1,1,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSeqIndexWithZeroRatios() {
|
||||||
|
ConcatSequencer<String> concat = new ConcatSequencer<>();
|
||||||
|
int[] ints = concat.seqIndexesByRatios(strings(a,b), ratios(0,3));
|
||||||
|
assertThat(ints).containsExactly(1,1,1);
|
||||||
|
}
|
||||||
|
|
||||||
private static List<String> strings(String... strings) {
|
private static List<String> strings(String... strings) {
|
||||||
return Arrays.asList(strings);
|
return Arrays.asList(strings);
|
||||||
}
|
}
|
||||||
private static List<Long> ratios(long... longs) {
|
private static List<Long> ratios(long... longs) {
|
||||||
return Arrays.stream(longs).boxed().collect(Collectors.toList());
|
return Arrays.stream(longs).boxed().collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* /
|
* /
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.nosqlbench.engine.api.util;
|
package io.nosqlbench.engine.api.activityapi.planning;
|
||||||
|
|
||||||
import io.nosqlbench.engine.api.activityapi.planning.ElementSequencer;
|
import io.nosqlbench.engine.api.activityapi.planning.ElementSequencer;
|
||||||
import io.nosqlbench.engine.api.activityapi.planning.IntervalSequencer;
|
import io.nosqlbench.engine.api.activityapi.planning.IntervalSequencer;
|
||||||
@ -32,6 +32,7 @@ public class IntervalSequencerTest {
|
|||||||
|
|
||||||
private static ElementSequencer<AnEvent> seqr = new IntervalSequencer<>();
|
private static ElementSequencer<AnEvent> seqr = new IntervalSequencer<>();
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFixture() {
|
public void testFixture() {
|
||||||
List<AnEvent> events = fromText("A:1,B:15");
|
List<AnEvent> events = fromText("A:1,B:15");
|
||||||
@ -49,6 +50,13 @@ public class IntervalSequencerTest {
|
|||||||
assertThat(seq).isEqualTo("ABCDAABAABCAABA");
|
assertThat(seq).isEqualTo("ABCDAABAABCAABA");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testO4I3L0() {
|
||||||
|
List<AnEvent> events = fromText("O:4,I:3,L:0");
|
||||||
|
String seq = seqr.sequenceSummary(events, ratioFunc, "");
|
||||||
|
assertThat(seq).isEqualTo("OIOIOIO");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testO4I3() {
|
public void testO4I3() {
|
||||||
List<AnEvent> events = fromText("O:4,I:3");
|
List<AnEvent> events = fromText("O:4,I:3");
|
||||||
@ -98,4 +106,4 @@ public class IntervalSequencerTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user