MCPcopy Create free account
hub / github.com/questdb/questdb / compare

Method compare

core/src/main/java/io/questdb/std/Long256Util.java:68–98  ·  view source on GitHub ↗
(Long256 a, Long256 b)

Source from the content-addressed store, hash-verified

66
67 // this method is used by byte-code generator
68 public static int compare(Long256 a, Long256 b) {
69
70 // Special handling for NULLs. Q: Why is it needed?
71 // A: We use 4xLong.MIN_VALUEs to represent Long256 null value.
72 // However, Long256 is unsigned and Long.MIN_VALUE has the highest bit is 1, all others bits are 0.
73 // Without this special handling some values would be considered higher than NULL and some lower.
74 // Having nulls values in the middle of the range would be confusing. INT and LONG types consider NULL
75 // to be the lowest possible value so we follow the same convention here.
76 if (Long256Impl.isNull(a)) {
77 return Long256Impl.isNull(b) ? 0 : -1;
78 } else if (Long256Impl.isNull(b)) {
79 return 1;
80 }
81
82 int cmp = Long.compareUnsigned(a.getLong3(), b.getLong3());
83 if (cmp != 0) {
84 return cmp;
85 }
86
87 cmp = Long.compareUnsigned(a.getLong2(), b.getLong2());
88 if (cmp != 0) {
89 return cmp;
90 }
91
92 cmp = Long.compareUnsigned(a.getLong1(), b.getLong1());
93 if (cmp != 0) {
94 return cmp;
95 }
96
97 return Long.compareUnsigned(a.getLong0(), b.getLong0());
98 }
99}

Callers

nothing calls this directly

Calls 6

isNullMethod · 0.95
compareUnsignedMethod · 0.80
getLong3Method · 0.65
getLong2Method · 0.65
getLong1Method · 0.65
getLong0Method · 0.65

Tested by

no test coverage detected