timoninmaxim commented on code in PR #10080:
URL: https://github.com/apache/ignite/pull/10080#discussion_r913498431
##########
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/inline/types/BooleanInlineIndexKeyType.java:
##########
@@ -46,10 +48,15 @@ public BooleanInlineIndexKeyType() {
}
/** {@inheritDoc} */
- @Override public int compare0(long pageAddr, int off, BooleanIndexKey key)
{
+ @Override public boolean isComparableTo(IndexKey key) {
+ return key instanceof NumericIndexKey;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int compare0(long pageAddr, int off, IndexKey key) {
boolean bool1 = PageUtils.getByte(pageAddr, off + 1) != 0;
- return Integer.signum(Boolean.compare(bool1, (boolean)key.key()));
+ return -((NumericIndexKey)key).compareTo(bool1);
Review Comment:
> All NumericIndexKey's return -1, 0 or 1
As I can see it's not guaranteed. `BooleanIndexKey#compareTo(boolean)` leads
to `Boolean.compare` that has docs:
> Returns: the value 0 if x == y; a value less than 0 if !x && y; and a
value greater than 0 if x && !y
AFAIU, it means it may return different value for different implementations
of java. It is not guaranteed that it will be "-1" or "1" everywhere - just
negative or positive.
But our docs for `NullableInlineIndexKeyType#compare0` strictly describes
possible return values.
--
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]