smiklosovic commented on code in PR #3562:
URL: https://github.com/apache/cassandra/pull/3562#discussion_r1911961103
##########
src/java/org/apache/cassandra/cql3/Validation.java:
##########
@@ -64,4 +70,28 @@ public static void validateKey(TableMetadata metadata,
ByteBuffer key)
throw new InvalidRequestException(e.getMessage());
}
}
+
+ public static void validateKeyAndCheckConstraints(TableMetadata metadata,
ByteBuffer key)
+ {
+ validateKey(metadata, key);
+
+ List<ColumnMetadata> partitionKeys = metadata.partitionKeyColumns();
+ List<ColumnConstraint> partitionKeyConstraints = new
ArrayList<>(partitionKeys.size());
+ for (ColumnMetadata column : partitionKeys)
+ {
+ if (column.hasConstraint())
+ partitionKeyConstraints.add(column.getColumnConstraints());
+ }
+ if (!partitionKeyConstraints.isEmpty())
+ {
+ try
+ {
+ metadata.partitionKeyType.checkConstraints(key, new
ColumnConstraints(partitionKeyConstraints));
Review Comment:
why do we actually need `new ColumnConstraints` here? Why we need to create
a new object? If you passed `partitionKeyConstraints` into `checkConstraints`
method directly, then what I read in its implementations does not seem to
require `ColumnConstraints`. You can do it just with that list.
--
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]