dcapwell commented on code in PR #3743:
URL: https://github.com/apache/cassandra/pull/3743#discussion_r1917524125
##########
src/java/org/apache/cassandra/index/accord/ParticipantsJournalIndex.java:
##########
@@ -108,42 +111,57 @@ public enum RegisterStatus
private volatile boolean initBuildStarted = false;
private volatile RegisterStatus registerStatus = RegisterStatus.PENDING;
- public RouteIndex(ColumnFamilyStore baseCfs, IndexMetadata indexMetadata)
+ public ParticipantsJournalIndex(ColumnFamilyStore baseCfs, IndexMetadata
indexMetadata)
{
- if
(!SchemaConstants.ACCORD_KEYSPACE_NAME.equals(baseCfs.getKeyspaceName()))
- throw new IllegalArgumentException("Route index is only allowed
for accord commands table; given " + baseCfs().metadata());
- if (!AccordKeyspace.COMMANDS.equals(baseCfs.name))
- throw new IllegalArgumentException("Route index is only allowed
for accord commands table; given " + baseCfs().metadata());
-
- TableMetadata tableMetadata = baseCfs.metadata();
- Pair<ColumnMetadata, IndexTarget.Type> target =
TargetParser.parse(tableMetadata, indexMetadata);
- if
(!AccordKeyspace.CommandsColumns.participants.name.equals(target.left.name))
- throw new IllegalArgumentException("Attempted to index the wrong
column; needed " + AccordKeyspace.CommandsColumns.participants.name + " but
given " + target.left.name);
-
- if (target.right != IndexTarget.Type.VALUES)
- throw new IllegalArgumentException("Attempted to index " +
AccordKeyspace.CommandsColumns.participants.name + " with index type " +
target.right + "; only " + IndexTarget.Type.VALUES + " is supported");
+ validateTargets(baseCfs, indexMetadata);
this.baseCfs = baseCfs;
+ // type is only IndexTarget.Type.VALUES
+ this.record = AccordKeyspace.JournalColumns.record;
+ this.user_version = AccordKeyspace.JournalColumns.user_version;
this.indexMetadata = indexMetadata;
+
this.memtableIndexManager = new RouteMemtableIndexManager(this);
this.sstableManager = new RouteSSTableManager();
this.indexMetrics = new IndexMetrics(this);
- this.column = target.left;
Tracker tracker = baseCfs.getTracker();
tracker.subscribe(this);
}
- public ColumnMetadata column()
+ public static boolean allowed(JournalKey id)
+ {
+ return id.type == JournalKey.Type.COMMAND_DIFF && allowed(id.id);
+ }
+
+ public static boolean allowed(TxnId id)
{
- return column;
+ return id.domain().isRange();
+ }
+
+ private static void validateTargets(ColumnFamilyStore baseCfs,
IndexMetadata indexMetadata)
+ {
+ // this contains 2 columns....
+ if
(!SchemaConstants.ACCORD_KEYSPACE_NAME.equals(baseCfs.getKeyspaceName()))
+ throw new IllegalArgumentException("Route index is only allowed
for accord journal table; given " + baseCfs.metadata());
+ if (!AccordKeyspace.JOURNAL.equals(baseCfs.name))
+ throw new IllegalArgumentException("Route index is only allowed
for accord journal table; given " + baseCfs.metadata());
+ Set<String> columns =
Splitter.on(',').trimResults().omitEmptyStrings().splitToStream(indexMetadata.options.get("target")).collect(Collectors.toSet());
+ Set<String> expected = Set.of("record", "user_version");
+ if (!expected.equals(columns))
+ throw new IllegalArgumentException("Route index is only allowed
for accord journal table, and on the record/user_value columns; given " +
baseCfs.metadata() + " and columns " + columns);
}
public IndexMetrics indexMetrics()
{
return indexMetrics;
}
+ public RegisterStatus registerStatus()
+ {
+ return registerStatus;
+ }
+
Review Comment:
> and I think we do not need forceBlockingFlush anymore.
personally rather keep it... as i try to bake in the assumption memtable
doesn't change into this index things start to break... this is part of the
correctness of table 2i so still prefer to keep.
We do not have any logic right now that blocks an insert/update/delete into
the table... so why bake this into the index itself which could actually handle
those?
--
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]