aweisberg commented on code in PR #50:
URL: https://github.com/apache/cassandra-accord/pull/50#discussion_r1280893667
##########
accord-core/src/main/java/accord/impl/InMemoryCommandStore.java:
##########
@@ -459,45 +408,63 @@ void update(Ranges add)
}
}
- class CFKLoader implements CommandLoader<TxnId>
+ static class CFKEntry extends TxnId
{
- private Command loadForCFK(TxnId data)
+ final boolean uninitialised;
+ public CFKEntry(TxnId copy, boolean uninitialised)
+ {
+ super(copy);
+ this.uninitialised = uninitialised;
+ }
+ }
+
+ class CFKLoader implements CommandLoader<CFKEntry>
+ {
+ final RoutableKey key;
+ CFKLoader(RoutableKey key)
+ {
+ this.key = key;
+ }
+
+ private Command loadForCFK(CFKEntry entry)
{
- GlobalCommand globalCommand = ifPresent(data);
+ GlobalCommand globalCommand = ifPresent(entry);
if (globalCommand != null)
return globalCommand.value();
- throw new IllegalStateException("Could not find command for CFK
for " + data);
+ if (entry.uninitialised)
+ return uninitialised(entry);
+ throw new IllegalStateException("Could not find command for CFK
for " + entry);
}
@Override
- public TxnId txnId(TxnId txnId)
+ public TxnId txnId(CFKEntry txnId)
{
return loadForCFK(txnId).txnId();
}
@Override
- public Timestamp executeAt(TxnId txnId)
+ public Timestamp executeAt(CFKEntry txnId)
{
return loadForCFK(txnId).executeAt();
}
@Override
- public SaveStatus saveStatus(TxnId txnId)
+ public SaveStatus saveStatus(CFKEntry txnId)
{
return loadForCFK(txnId).saveStatus();
}
@Override
- public List<TxnId> depsIds(TxnId data)
+ public List<TxnId> depsIds(CFKEntry data)
{
PartialDeps deps = loadForCFK(data).partialDeps();
return deps != null ? deps.txnIds() : Collections.emptyList();
}
@Override
- public TxnId saveForCFK(Command command)
+ public CFKEntry saveForCFK(Command command)
{
- return command.txnId();
+ return new CFKEntry(command.txnId(), command.saveStatus() ==
SaveStatus.Uninitialised);
Review Comment:
Changed
--
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]