smiklosovic commented on code in PR #3562:
URL: https://github.com/apache/cassandra/pull/3562#discussion_r1912829456
##########
src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java:
##########
@@ -316,6 +320,61 @@ public <V> void validate(V input, ValueAccessor<V>
accessor)
}
}
+ // a int, b text
+ // PARTITION KEY ((a, b), c)
+
+ @Override
+ public void checkConstraints(ByteBuffer input, ColumnConstraints
constraints) throws ConstraintViolationException
+ {
+ boolean allNoopConstraint = true;
+ for (ColumnConstraint c : constraints.getConstraints())
+ {
+ assert c instanceof ColumnConstraints;
+ allNoopConstraint = allNoopConstraint && c instanceof
ColumnConstraints.Noop;
+ // no constraints defined for the partition keys
+ if (allNoopConstraint)
+ return;
+ }
+
+ ValueAccessor<ByteBuffer> accessor = ByteBufferAccessor.instance;
+
+ boolean isStatic = readIsStatic(input, accessor);
+ int offset = startingOffset(isStatic);
+
+ int i = 0;
+ List<Object> partitionKeyValues = new ArrayList<>();
+ while (!accessor.isEmptyFromOffset(input, offset))
+ {
+ AbstractType<?> comparator = getComparator(i, input, accessor,
offset);
+ offset += getComparatorSize(i, input, accessor, offset);
+
+ int length = accessor.getUnsignedShort(input, offset);
+ offset += 2;
+
+ ByteBuffer value = accessor.slice(input, offset, length);
+ partitionKeyValues.add(comparator.compose(value));
+ offset += length;
+
+ accessor.getByte(input, offset++);
+ ++i;
+ }
+
+ if (partitionKeyValues.size() != constraints.getConstraints().size())
+ {
+ // contraints list should have the exact size of partition key
values.
+ // Noop constraints are filled for the partition key columns w/o
any constraints.
+ throw new IllegalStateException("Partition key values and number
of constraints do not match.");
Review Comment:
would be nice to say what is the size of each in the message
--
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]