belliottsmith commented on code in PR #106:
URL: https://github.com/apache/cassandra-accord/pull/106#discussion_r1692255704
##########
accord-core/src/main/java/accord/local/CommandsForKey.java:
##########
@@ -372,112 +483,208 @@ public String toString()
return "Info{" +
"txnId=" + toPlainString() +
", status=" + status +
- ", executeAt=" + (executeAt == this ? toPlainString() :
executeAt.toString()) +
+ ", executeAt=" + plainExecuteAt() +
'}';
}
public String toPlainString()
{
return super.toString();
}
+
+ public int compareExecuteAt(TxnInfo that)
+ {
+ return this.executeAt.compareTo(that.executeAt);
+ }
+
+ Timestamp executeAtIfKnownElseTxnId()
+ {
+ return status == INVALID_OR_TRUNCATED ? this : executeAt;
+ }
}
- public static class TxnInfoWithMissing extends TxnInfo
+ public static class TxnInfoExtra extends TxnInfo
{
public final TxnId[] missing;
+ public final Ballot ballot;
- TxnInfoWithMissing(TxnId txnId, InternalStatus status, Timestamp
executeAt, TxnId[] missing)
+ TxnInfoExtra(TxnId txnId, InternalStatus status, Timestamp executeAt,
TxnId[] missing, Ballot ballot)
{
super(txnId, status, executeAt);
this.missing = missing;
+ this.ballot = ballot;
}
+ @Override
public TxnId[] missing()
{
return missing;
}
+ @Override
+ public Ballot ballot()
+ {
+ return ballot;
+ }
+
+ public TxnInfo update(TxnId[] newMissing)
+ {
+ if (newMissing == missing)
+ return this;
+
+ return newMissing == NO_TXNIDS && ballot == Ballot.ZERO
+ ? new TxnInfo(this, status, executeAt)
+ : new TxnInfoExtra(this, status, executeAt, newMissing,
ballot);
+ }
+
@Override
public String toString()
{
return "Info{" +
"txnId=" + toPlainString() +
", status=" + status +
- ", executeAt=" + (this == executeAt ? toPlainString() :
executeAt) +
+ ", executeAt=" + plainExecuteAt() +
+ (ballot != Ballot.ZERO ? ", ballot=" + ballot : "") +
", missing=" + Arrays.toString(missing) +
'}';
}
}
private final Key key;
private final RedundantBefore.Entry redundantBefore;
+ private final TxnInfo prunedBefore;
+ // TODO (desired): avoid loading if we know a transaction that should have
witnessed it has already been registered/applied
+ private final Object[] loadingPruned;
Review Comment:
I don't like adding types to parameter names, but I will certainly document
it with comments. Though, I think in the Cassandra codebase `Object[]` is very
likely to be a BTree so it's mentally a BTree marker for me without any
additional information, but perhaps that is arcane knowledge.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]