Skip to content

Commit 75a467b

Browse files
committed
Correct offset for UNSAFE.getLong()
1 parent 855374b commit 75a467b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

unsafe/src/main/java/org/apache/spark/unsafe/bitset/BitSetMethods.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ public static boolean isSet(Object baseObject, long baseOffset, int index) {
7474
public static boolean anySet(Object baseObject, long baseOffset, long bitSetWidthInBytes) {
7575
assert bitSetWidthInBytes % SIZE_OF_LONG == 0;
7676
int widthInLong = (int)(bitSetWidthInBytes / SIZE_OF_LONG);
77-
for (int i = 0; i <= widthInLong; i++) {
78-
if (PlatformDependent.UNSAFE.getLong(baseObject, baseOffset + i) != 0) {
77+
long addr = baseOffset;
78+
for (int i = 0; i <= widthInLong; i++, addr += 8) {
79+
if (PlatformDependent.UNSAFE.getLong(baseObject, addr) != 0) {
7980
return true;
8081
}
8182
}

0 commit comments

Comments
 (0)