This is an automated email from the ASF dual-hosted git repository.
jbarrett pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-benchmarks.git
The following commit(s) were added to refs/heads/develop by this push:
new a173546 Fixes negative index. (#164)
a173546 is described below
commit a1735467ff9fe1a6688ee4820c3a7f1535af3d76
Author: Jacob Barrett <[email protected]>
AuthorDate: Fri Mar 4 16:21:53 2022 -0800
Fixes negative index. (#164)
---
.../src/main/java/benchmark/geode/data/Portfolio.java | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/geode-benchmarks/src/main/java/benchmark/geode/data/Portfolio.java
b/geode-benchmarks/src/main/java/benchmark/geode/data/Portfolio.java
index 36d3f67..a691bd7 100644
--- a/geode-benchmarks/src/main/java/benchmark/geode/data/Portfolio.java
+++ b/geode-benchmarks/src/main/java/benchmark/geode/data/Portfolio.java
@@ -17,6 +17,8 @@
package benchmark.geode.data;
+import static java.lang.Math.abs;
+
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
@@ -67,17 +69,17 @@ public class Portfolio {
pkid = "" + i;
status = i % 2 == 0 ? "active" : "inactive";
type = "type" + (i % 3);
- position1 = new Position(secIds[Position.cnt % secIds.length],
Position.cnt * 1000L);
+ position1 = new Position(secIds[getPositionIndex()], Position.cnt * 1000L);
if (i % 2 != 0) {
- position2 = new Position(secIds[Position.cnt % secIds.length],
Position.cnt * 1000L);
+ position2 = new Position(secIds[getPositionIndex()], Position.cnt *
1000L);
} else {
position2 = null;
}
- positions.put(secIds[Position.cnt % secIds.length],
- new Position(secIds[Position.cnt % secIds.length], Position.cnt *
1000L));
- positions.put(secIds[Position.cnt % secIds.length],
- new Position(secIds[Position.cnt % secIds.length], Position.cnt *
1000L));
+ positions.put(secIds[getPositionIndex()],
+ new Position(secIds[getPositionIndex()], Position.cnt * 1000L));
+ positions.put(secIds[getPositionIndex()],
+ new Position(secIds[getPositionIndex()], Position.cnt * 1000L));
collectionHolderMap.put("0", new CollectionHolder());
collectionHolderMap.put("1", new CollectionHolder());
@@ -87,6 +89,10 @@ public class Portfolio {
unicodeṤtring = i % 2 == 0 ? "ṤṶẐ" : "ṤẐṶ";
}
+ private int getPositionIndex() {
+ return abs(Position.cnt % secIds.length);
+ }
+
public Portfolio(int i, int j) {
this(i);
this.position1.portfolioId = j;