dcapwell commented on code in PR #4006: URL: https://github.com/apache/cassandra/pull/4006#discussion_r2010648526
########## src/java/org/apache/cassandra/cql3/terms/Constants.java: ########## @@ -489,8 +489,10 @@ public void execute(DecoratedKey partitionKey, UpdateParameters params) throws I else if (column.type instanceof NumberType<?>) { @SuppressWarnings("unchecked") NumberType<Number> type = (NumberType<Number>) column.type; - ByteBuffer increment = t.bindAndGet(params.options); - ByteBuffer current = getCurrentCellBuffer(partitionKey, params); + ByteBuffer increment = type.sanitize(t.bindAndGet(params.options)); Review Comment: `type.sanitize` is a bug fix for empty bytes. Numeric types allow `byte[0]` and its semantic is weird... in 90% of the codebase its `null` but in that 10% its not... this code path hits a NPE as its part of the 90%... empty is only not null if and only if you do `col = <empty>`, any other path its `null`... ########## src/java/org/apache/cassandra/cql3/terms/Constants.java: ########## @@ -524,19 +526,48 @@ public Substracter(ColumnMetadata column, Term t) super(column, t); } + @Override + public boolean requiresRead() + { + return !column.type.isCounter(); + } + public void execute(DecoratedKey partitionKey, UpdateParameters params) throws InvalidRequestException { - ByteBuffer bytes = t.bindAndGet(params.options); - if (bytes == null) - throw new InvalidRequestException("Invalid null value for counter increment"); - if (bytes == ByteBufferUtil.UNSET_BYTE_BUFFER) - return; + if (column.type instanceof CounterColumnType) + { + ByteBuffer bytes = t.bindAndGet(params.options); + if (bytes == null) + throw new InvalidRequestException("Invalid null value for counter increment"); + if (bytes == ByteBufferUtil.UNSET_BYTE_BUFFER) + return; - long increment = ByteBufferUtil.toLong(bytes); - if (increment == Long.MIN_VALUE) - throw new InvalidRequestException("The negation of " + increment + " overflows supported counter precision (signed 8 bytes integer)"); + long increment = ByteBufferUtil.toLong(bytes); + if (increment == Long.MIN_VALUE) + throw new InvalidRequestException("The negation of " + increment + " overflows supported counter precision (signed 8 bytes integer)"); - params.addCounter(column, -increment); + params.addCounter(column, -increment); + } + else if (column.type instanceof NumberType<?>) Review Comment: new feature, `-=` now supports numeric types, just like `+=` does -- 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: pr-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org