maedhroz commented on code in PR #2498:
URL: https://github.com/apache/cassandra/pull/2498#discussion_r1270105910
##########
src/java/org/apache/cassandra/index/sai/utils/PrimaryKey.java:
##########
@@ -92,25 +93,17 @@ abstract class AbstractPrimaryKey implements PrimaryKey
{
public ByteSource asComparableBytes(ByteComparable.Version version)
{
- ByteSource tokenComparable =
token().asComparableBytes(version);
- if (partitionKey() == null)
- return ByteSource.withTerminator(version ==
ByteComparable.Version.LEGACY ? ByteSource.END_OF_STREAM
-
: ByteSource.TERMINATOR,
- tokenComparable,
- null,
- null);
ByteSource keyComparable =
ByteSource.of(partitionKey().getKey(), version);
+ if (clusteringComparator.size() == 0)
+ return keyComparable;
// It is important that the
ClusteringComparator.asBytesComparable method is used
// to maintain the correct clustering sort order
- ByteSource clusteringComparable = clusteringComparator == null
||
- clusteringComparator.size()
== 0 ||
- clustering() == null ||
+ ByteSource clusteringComparable = clustering() == null ||
clustering().isEmpty() ? null
Review Comment:
It's kind of funny that, because we have `@Nullable` on `clustering()`, IDEA
throws up a bunch of warnings about this possibly causing an NPE...even though
we have a short-circuiting `clustering() == null ||` immediately before it. We
could always throw `@SuppressWarnings("DataFlowIssue")` on these methods...
--
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]