shuwenwei commented on code in PR #307:
URL: https://github.com/apache/tsfile/pull/307#discussion_r1855892696
##########
java/common/src/main/java/org/apache/tsfile/utils/BitMap.java:
##########
@@ -147,6 +165,35 @@ public boolean equals(Object obj) {
return this.size == other.size && Arrays.equals(this.bits, other.bits);
}
+ public boolean equalsInRange(Object obj, int rangeSize) {
+ if (obj == this) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (!(obj instanceof BitMap)) {
+ return false;
+ }
+ BitMap other = (BitMap) obj;
+ // implement
+
+ int byteSize = rangeSize / Byte.SIZE;
+ for (int i = 0; i < byteSize; i++) {
+ if (this.bits[i] != other.bits[i]) {
+ return false;
+ }
+ }
+ int remainingBits = rangeSize % Byte.SIZE;
+ if (remainingBits > 0) {
+ byte mask = (byte) (0xFF >> (Byte.SIZE - remainingBits));
+ if ((this.bits[byteSize] & mask) != (other.bits[byteSize] & mask)) {
+ return false;
+ }
+ }
+ return true;
+ }
Review Comment:
Arrays.compare may not be available in lower java versions.
--
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]