Skip to content

Commit a8ffe30

Browse files
liyafan82kou
authored andcommitted
ARROW-6264: [Java] There is no need to consider byte order in ArrowBufHasher
According to the discussion in apache/arrow#5063 (comment), Arrow has a mechanism to make sure the data is stored in little-endian, so there is no need to check byte order. Closes #5098 from liyafan82/fly_0816_order and squashes the following commits: 538ce59d7 <liyafan82> ARROW-6264 There is no need to consider byte order in ArrowBufHasher Authored-by: liyafan82 <fan_li_ya@foxmail.com> Signed-off-by: Pindikura Ravindra <ravindra@dremio.com>
1 parent 149b938 commit a8ffe30

File tree

3 files changed

+0
-18
lines changed

3 files changed

+0
-18
lines changed

memory/src/main/java/org/apache/arrow/memory/util/ArrowBufPointer.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
package org.apache.arrow.memory.util;
1919

20-
import java.nio.ByteOrder;
21-
2220
import org.apache.arrow.memory.util.hash.ArrowBufHasher;
2321
import org.apache.arrow.memory.util.hash.SimpleHasher;
2422
import org.apache.arrow.util.Preconditions;
@@ -31,8 +29,6 @@
3129
*/
3230
public final class ArrowBufPointer {
3331

34-
public static final boolean LITTLE_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN;
35-
3632
/**
3733
* The hash code when the arrow buffer is null.
3834
*/

memory/src/main/java/org/apache/arrow/memory/util/hash/MurmurHasher.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import static io.netty.util.internal.PlatformDependent.getByte;
2121
import static io.netty.util.internal.PlatformDependent.getInt;
2222

23-
import org.apache.arrow.memory.util.ArrowBufPointer;
24-
2523
import io.netty.buffer.ArrowBuf;
2624

2725
/**
@@ -93,9 +91,6 @@ public static int hashCode(long address, int length, int seed) {
9391
int hash = seed;
9492
while (index + 4 <= length) {
9593
int intValue = getInt(address + index);
96-
if (!ArrowBufPointer.LITTLE_ENDIAN) {
97-
intValue = Integer.reverseBytes(intValue);
98-
}
9994
hash = combineHashCode(hash, intValue);
10095
index += 4;
10196
}

memory/src/main/java/org/apache/arrow/memory/util/hash/SimpleHasher.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import static io.netty.util.internal.PlatformDependent.getInt;
2222
import static io.netty.util.internal.PlatformDependent.getLong;
2323

24-
import org.apache.arrow.memory.util.ArrowBufPointer;
25-
2624
import io.netty.buffer.ArrowBuf;
2725

2826
/**
@@ -61,20 +59,13 @@ public int hashCode(long address, int length) {
6159
int index = 0;
6260
while (index + 8 <= length) {
6361
long longValue = getLong(address + index);
64-
if (!ArrowBufPointer.LITTLE_ENDIAN) {
65-
// assume the buffer is in little endian
66-
longValue = Long.reverseBytes(longValue);
67-
}
6862
int longHash = getLongHashCode(longValue);
6963
hashValue = combineHashCode(hashValue, longHash);
7064
index += 8;
7165
}
7266

7367
while (index + 4 <= length) {
7468
int intValue = getInt(address + index);
75-
if (!ArrowBufPointer.LITTLE_ENDIAN) {
76-
intValue = Integer.reverseBytes(intValue);
77-
}
7869
int intHash = intValue;
7970
hashValue = combineHashCode(hashValue, intHash);
8071
index += 4;

0 commit comments

Comments
 (0)