mike-tr-adamson commented on code in PR #2540:
URL: https://github.com/apache/cassandra/pull/2540#discussion_r1290157708
##########
src/java/org/apache/cassandra/index/sai/disk/v1/sortedterms/SortedTermsWriter.java:
##########
@@ -152,20 +136,30 @@ private void writeTermData(BytesRef term) throws
IOException
}
else
{
- int prefixLength = StringHelper.bytesDifference(prevTerm.get(),
term);
- int suffixLength = term.length - prefixLength;
- assert suffixLength > 0: "terms must be unique";
-
+ int prefixLength = 0;
+ int suffixLength = 0;
+
+ // If the term is the same as the previous term then we use prefix
and suffix lengths of 0.
+ // This means that we store a byte of 0 and don't write any data
for the term.
+ if (compareTerms(prevTerm.get(), term) != 0)
Review Comment:
If the terms are equal, then we only want to write a byte zero. If the terms
are not equal, then `bytesDifference` returns the number of bytes of matching
prefix. The term does not need to be in any sorted order. The exception thrown
by the `bytesDifference` method is not correct. It will get `-1` back from
`Arrays.mismatch` if the terms are equal.
--
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]