Skip to content

Commit

Permalink
fix simple query gen and operation instance bug (#24)
Browse files Browse the repository at this point in the history
* udpate params and fix operation instance problem

* fix simple generator problem and add dummy results

* update rw2 input
  • Loading branch information
BingTong0 authored May 11, 2023
1 parent 648df86 commit 97be39d
Show file tree
Hide file tree
Showing 52 changed files with 559 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,6 @@ public LdbcFinBenchSimpleReadGenerator(double initialProbability,
simpleQueryFactories[SimpleRead5.TYPE] = null;
simpleQueryFactories[SimpleRead6.TYPE] = null;

/*
FACTORIES
<if> (LAST_PERSON_INDEX != MAX_INTEGER) <then>
LAST_PERSON_INDEX (S1/S2/S3) -> FIRST_MESSAGE
<if> (LAST_MESSAGE_INDEX != MAX_INTEGER) <then>
LAST_MESSAGE_INDEX (S4/S5/S6/S7) -> FIRST_PERSON
*/
if (Integer.MAX_VALUE != lastAccountQueryIndex) {
simpleQueryFactories[lastAccountQueryIndex] = firstPersonQuery;
}
Expand All @@ -318,27 +311,6 @@ public LdbcFinBenchSimpleReadGenerator(double initialProbability,
simpleQueryFactories[lastCompanyQueryIndex] = firstAccountQuery;
}

/*
FACTORIES
S1_INDEX -> <if> (ENABLED[S1_INDEX] && UNASSIGNED == FACTORIES[S1_INDEX]) <then>
index = indexOfNextEnabledAndUnassigned(MAPPING,S1_INDEX)
<if> (index > LAST_PERSON_INDEX) <then> FIRST_MESSAGE <else> MAPPING[index]
S2_INDEX -> <if> (ENABLED[S2_INDEX] && UNASSIGNED == FACTORIES[S2_INDEX]) <then>
index = indexOfNextEnabledAndUnassigned(MAPPING,S2_INDEX)
<if> (index > LAST_PERSON_INDEX) <then> FIRST_MESSAGE <else> MAPPING[index]
S3_INDEX -> // must have already been assigned, or is disabled
S4_INDEX -> <if> (ENABLED[S4_INDEX] && UNASSIGNED == FACTORIES[S4_INDEX]) <then>
index = indexOfNextEnabledAndUnassigned(MAPPING,S4_INDEX)
<if> (index > LAST_MESSAGE_INDEX) <then> FIRST_PERSON <else> MAPPING[index]
S5_INDEX -> <if> (ENABLED[S5_INDEX] && UNASSIGNED == FACTORIES[S5_INDEX]) <then>
index = indexOfNextEnabledAndUnassigned(MAPPING,S5_INDEX)
<if> (index > LAST_MESSAGE_INDEX) <then> FIRST_PERSON <else> MAPPING[index]
S6_INDEX -> <if> (ENABLED[S6_INDEX] && UNASSIGNED == FACTORIES[S6_INDEX]) <then>
index = indexOfNextEnabledAndUnassigned(MAPPING,S6_INDEX)
<if> (index > LAST_MESSAGE_INDEX) <then> FIRST_PERSON <else> MAPPING[index]
S7_INDEX -> // must have already been assigned, or is disabled
*/

for (int i = SimpleRead1.TYPE; i <= SimpleRead6.TYPE; i++) {
if (enabledSimpleReads[i] && null == simpleQueryFactories[i]) {
int index = indexOfNextEnabled(enabledSimpleReads, i);
Expand Down Expand Up @@ -582,21 +554,21 @@ private Tuple2<Integer, LdbcSimpleQueryFactory> firstAccountQueryOrNoOp(
);
} else if (enabledSimpleReadOperationTypes.contains(SimpleRead4.class)) {
return Tuple.<Integer, LdbcSimpleQueryFactory>tuple2(
SimpleRead3.TYPE,
SimpleRead4.TYPE,
new CoinTossingFactory(randomFactory.newRandom(),
new LdbcSimpleQuery3Factory(scheduledStartTimePolicy), minProbability, maxProbability)
new LdbcSimpleQuery4Factory(scheduledStartTimePolicy), minProbability, maxProbability)
);
} else if (enabledSimpleReadOperationTypes.contains(SimpleRead5.class)) {
return Tuple.<Integer, LdbcSimpleQueryFactory>tuple2(
SimpleRead3.TYPE,
SimpleRead5.TYPE,
new CoinTossingFactory(randomFactory.newRandom(),
new LdbcSimpleQuery3Factory(scheduledStartTimePolicy), minProbability, maxProbability)
new LdbcSimpleQuery5Factory(scheduledStartTimePolicy), minProbability, maxProbability)
);
} else if (enabledSimpleReadOperationTypes.contains(SimpleRead6.class)) {
return Tuple.<Integer, LdbcSimpleQueryFactory>tuple2(
SimpleRead3.TYPE,
SimpleRead6.TYPE,
new CoinTossingFactory(randomFactory.newRandom(),
new LdbcSimpleQuery3Factory(scheduledStartTimePolicy), minProbability, maxProbability)
new LdbcSimpleQuery6Factory(scheduledStartTimePolicy), minProbability, maxProbability)
);
} else {
return Tuple.<Integer, LdbcSimpleQueryFactory>tuple2(
Expand Down Expand Up @@ -655,17 +627,17 @@ private Tuple2<Integer, LdbcSimpleQueryFactory> firstCompanyQueryOrNoOp(
}

private int lastAccountQueryIndex(Set<Class<? extends Operation>> enabledSimpleReadOperationTypes) {
if (enabledSimpleReadOperationTypes.contains(SimpleRead1.class)) {
if (enabledSimpleReadOperationTypes.contains(SimpleRead6.class)) {
return SimpleRead6.TYPE;
} else if (enabledSimpleReadOperationTypes.contains(SimpleRead2.class)) {
} else if (enabledSimpleReadOperationTypes.contains(SimpleRead5.class)) {
return SimpleRead5.TYPE;
} else if (enabledSimpleReadOperationTypes.contains(SimpleRead3.class)) {
return SimpleRead4.TYPE;
} else if (enabledSimpleReadOperationTypes.contains(SimpleRead4.class)) {
return SimpleRead4.TYPE;
} else if (enabledSimpleReadOperationTypes.contains(SimpleRead3.class)) {
return SimpleRead3.TYPE;
} else if (enabledSimpleReadOperationTypes.contains(SimpleRead5.class)) {
} else if (enabledSimpleReadOperationTypes.contains(SimpleRead2.class)) {
return SimpleRead2.TYPE;
} else if (enabledSimpleReadOperationTypes.contains(SimpleRead6.class)) {
} else if (enabledSimpleReadOperationTypes.contains(SimpleRead1.class)) {
return SimpleRead1.TYPE;
} else {
return Integer.MAX_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ public boolean hasNext() {
@Override
public Operation next() {
Operation query = operationStream.next();
// Operation operation = query.newInstance();
// operation.setDependencyTimeStamp(query.dependencyTimeStamp());
// operation.setExpiryTimeStamp(query.expiryTimeStamp());
return query;
Operation operation = query.newInstance();
operation.setDependencyTimeStamp(query.dependencyTimeStamp());
operation.setExpiryTimeStamp(query.expiryTimeStamp());
return operation;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ public ComplexRead1(@JsonProperty(ID) long id,
this.truncationOrder = truncationOrder;
}

public ComplexRead1(ComplexRead1 operation) {
this.id = operation.id;
this.startTime = operation.startTime;
this.endTime = operation.endTime;
this.truncationLimit = operation.truncationLimit;
this.truncationOrder = operation.truncationOrder;
}

@Override
public ComplexRead1 newInstance() {
return new ComplexRead1(this);
}

public long getId() {
return id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ public ComplexRead10(@JsonProperty(PID1) long pid1,
this.endTime = endTime;
}

public ComplexRead10(ComplexRead10 operation) {
this.pid1 = operation.pid1;
this.pid2 = operation.pid2;
this.startTime = operation.startTime;
this.endTime = operation.endTime;
}

@Override
public ComplexRead10 newInstance() {
return new ComplexRead10(this);
}

public long getPid1() {
return pid1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ public ComplexRead11(@JsonProperty(ID) long id,
this.truncationOrder = truncationOrder;
}

public ComplexRead11(ComplexRead11 operation) {
this.id = operation.id;
this.startTime = operation.startTime;
this.endTime = operation.endTime;
this.truncationLimit = operation.truncationLimit;
this.truncationOrder = operation.truncationOrder;
}

@Override
public ComplexRead11 newInstance() {
return new ComplexRead11(this);
}

public long getId() {
return id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ public ComplexRead12(@JsonProperty(ID) long id,
this.truncationOrder = truncationOrder;
}

public ComplexRead12(ComplexRead12 operation) {
this.id = operation.id;
this.startTime = operation.startTime;
this.endTime = operation.endTime;
this.truncationLimit = operation.truncationLimit;
this.truncationOrder = operation.truncationOrder;
}

@Override
public ComplexRead12 newInstance() {
return new ComplexRead12(this);
}

public long getId() {
return id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ public ComplexRead2(@JsonProperty(ID) long id,
this.truncationOrder = truncationOrder;
}

public ComplexRead2(ComplexRead2 operation) {
this.id = operation.id;
this.startTime = operation.startTime;
this.endTime = operation.endTime;
this.truncationLimit = operation.truncationLimit;
this.truncationOrder = operation.truncationOrder;
}

@Override
public ComplexRead2 newInstance() {
return new ComplexRead2(this);
}

public long getId() {
return id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* -- Shortest transfer path --
* Given two accounts and a specified time window between startTime and endTime, find the length
of shortest path between these two accounts by the transfer relationships. Note that all the edges
in the path should be in the time window and of type transfer. Return 0 if src and dst are directly
in the path should be in the time window and of type transfer. Return 1 if src and dst are directly
connected. Return -1 if there is no path found.
*/

Expand Down Expand Up @@ -50,6 +50,20 @@ public ComplexRead3(@JsonProperty(ID1) long id1,
this.truncationOrder = truncationOrder;
}

public ComplexRead3(ComplexRead3 operation) {
this.id1 = operation.id1;
this.id2 = operation.id2;
this.startTime = operation.startTime;
this.endTime = operation.endTime;
this.truncationLimit = operation.truncationLimit;
this.truncationOrder = operation.truncationOrder;
}

@Override
public ComplexRead3 newInstance() {
return new ComplexRead3(this);
}

public long getId1() {
return id1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ public ComplexRead4(@JsonProperty(ID1) long id1,
this.truncationOrder = truncationOrder;
}

public ComplexRead4(ComplexRead4 operation) {
this.id1 = operation.id1;
this.id2 = operation.id2;
this.startTime = operation.startTime;
this.endTime = operation.endTime;
this.truncationLimit = operation.truncationLimit;
this.truncationOrder = operation.truncationOrder;
}

@Override
public ComplexRead4 newInstance() {
return new ComplexRead4(this);
}

public long getId1() {
return id1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(otherId, numEdge2, sumEdge2Amount, maxEdge2Amount,
numEdge3, sumEdge3Amount, maxEdge3Amount);
return Objects.hash(otherId, numEdge2, sumEdge2Amount, maxEdge2Amount, numEdge3,
sumEdge3Amount, maxEdge3Amount);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ public ComplexRead5(@JsonProperty(ID) long id,
this.truncationOrder = truncationOrder;
}

public ComplexRead5(ComplexRead5 operation) {
this.id = operation.id;
this.startTime = operation.startTime;
this.endTime = operation.endTime;
this.truncationLimit = operation.truncationLimit;
this.truncationOrder = operation.truncationOrder;
}

@Override
public ComplexRead5 newInstance() {
return new ComplexRead5(this);
}

public long getId() {
return id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* Given an account of type card and a specified time window between startTime and endTime, find all
the connected accounts (mid) via withdrawal (edge2) satisfying, (1) More than 3 transfer-ins (edge1)
from other accounts (src) whose amount exceeds threshold1. (2) The amount of withdrawal (edge2)
exceeds threshold2. Return the sum of transfer amount from src to mid, the amount from mid to
dstCard grouped by mid.
from mid to dstCard whose exceeds threshold2. Return the sum of transfer amount from src to mid,
the amount from mid to dstCard grouped by mid.
*/

import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down Expand Up @@ -55,6 +55,21 @@ public ComplexRead6(@JsonProperty(ID) long id,
this.truncationOrder = truncationOrder;
}

public ComplexRead6(ComplexRead6 operation) {
this.id = operation.id;
this.threshold1 = operation.threshold1;
this.threshold2 = operation.threshold2;
this.startTime = operation.startTime;
this.endTime = operation.endTime;
this.truncationLimit = operation.truncationLimit;
this.truncationOrder = operation.truncationOrder;
}

@Override
public ComplexRead6 newInstance() {
return new ComplexRead6(this);
}

public long getId() {
return id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ public ComplexRead7(@JsonProperty(ID) long id,
this.truncationOrder = truncationOrder;
}

public ComplexRead7(ComplexRead7 operation) {
this.id = operation.id;
this.threshold = operation.threshold;
this.startTime = operation.startTime;
this.endTime = operation.endTime;
this.truncationLimit = operation.truncationLimit;
this.truncationOrder = operation.truncationOrder;
}

@Override
public ComplexRead7 newInstance() {
return new ComplexRead7(this);
}

public long getId() {
return id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
of each transfers or withdrawals between the account and the upstream account should exceed a
specified threshold of the upstream transfer. Return all the accounts’ id in the downstream of loan
with the final ratio and distanceFromLoan.
Note: Upstream means the last edge in the trace.
Note: Upstream of an edge refers to the aggregated total amounts of all transfer-in edges of its
source Account.
*/

import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down Expand Up @@ -53,6 +54,20 @@ public ComplexRead8(@JsonProperty(ID) long id,
this.truncationOrder = truncationOrder;
}

public ComplexRead8(ComplexRead8 operation) {
this.id = operation.id;
this.threshold = operation.threshold;
this.startTime = operation.startTime;
this.endTime = operation.endTime;
this.truncationLimit = operation.truncationLimit;
this.truncationOrder = operation.truncationOrder;
}

@Override
public ComplexRead8 newInstance() {
return new ComplexRead8(this);
}

public long getId() {
return id;
}
Expand Down
Loading

0 comments on commit 97be39d

Please sign in to comment.