maedhroz commented on code in PR #4175: URL: https://github.com/apache/cassandra/pull/4175#discussion_r2151064092
########## src/java/org/apache/cassandra/service/accord/txn/TxnCondition.java: ########## @@ -289,54 +291,99 @@ public boolean applies(TxnData data) FilteredPartition partition = reference.getPartition(data); boolean exists = partition != null && !partition.isEmpty(); - Row row = null; - if (exists) + if (reference.column() != null + && !reference.column().isPartitionKey()) { - row = reference.getRow(partition); - exists = row != null && !row.isEmpty(); - } - - if (exists && reference.selectsColumn()) - { - ColumnData columnData = reference.getColumnData(row); - - if (columnData == null) + Row row = null; + if (exists) { - exists = false; + row = reference.getRow(partition); + exists = row != null && !row.isEmpty(); } - else if (columnData.column().isComplex()) + + if (exists && reference.selectsColumn()) { - if (reference.isElementSelection() || reference.isFieldSelection()) + ColumnData columnData = reference.getColumnData(row); + + if (columnData == null) + { + exists = false; + } + else if (columnData.column().isComplex()) + { + if (reference.isElementSelection()) + { + Cell<?> cell = (Cell<?>) columnData; + exists = !cell.isTombstone(); + // Collections don't support NULL but meangingless null types are supported, so byte[0] is allowed! + // This is NULL when touched, so need to still check each value + if (exists) + { + CollectionType<?> type = (CollectionType<?>) reference.column().type.unwrap(); + switch (type.kind) + { + case MAP: + { + exists = !type.nameComparator().isNull(cell.path().get(0)); + if (exists) + exists = !type.valueComparator().isNull(cell.buffer()); + } + break; + case SET: + { + exists = !type.nameComparator().isNull(cell.path().get(0)); + } + break; + case LIST: + { + exists = !type.valueComparator().isNull(cell.buffer()); + } + break; + default: + throw new UnsupportedOperationException(type.kind.name()); Review Comment: Do you think we could just fold this into `CollectionType` a la `makeCollectionReceiver()`? That might avoid the whole default branch throwing situation. -- 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