-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove reverse in ByteFunctionHelpers
- Loading branch information
1 parent
41030c4
commit dbd0923
Showing
2 changed files
with
95 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
java/vector/src/test/java/org/apache/arrow/vector/util/TestByteFunctionHelpers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.arrow.vector.util; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.apache.arrow.memory.BufferAllocator; | ||
import org.apache.arrow.memory.RootAllocator; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import io.netty.buffer.ArrowBuf; | ||
|
||
public class TestByteFunctionHelpers { | ||
|
||
private BufferAllocator allocator; | ||
|
||
private static final int SIZE = 100; | ||
|
||
@Before | ||
public void init() { | ||
allocator = new RootAllocator(Long.MAX_VALUE); | ||
|
||
} | ||
|
||
@After | ||
public void terminate() throws Exception { | ||
allocator.close(); | ||
} | ||
|
||
@Test | ||
public void testEquals() { | ||
ArrowBuf buffer1 = allocator.buffer(SIZE); | ||
ArrowBuf buffer2 = allocator.buffer(SIZE); | ||
|
||
for (int i = 0; i < SIZE; i++) { | ||
buffer1.setByte(i, i); | ||
buffer2.setByte(i, i); | ||
} | ||
|
||
assertEquals(1, ByteFunctionHelpers.equal(buffer1, 0, SIZE - 1, | ||
buffer2, 0, SIZE - 1)); | ||
|
||
buffer1.setByte(50, 10); | ||
|
||
assertEquals(0, ByteFunctionHelpers.equal(buffer1, 0, SIZE - 1, | ||
buffer2, 0, SIZE - 1)); | ||
|
||
buffer1.close(); | ||
buffer2.close(); | ||
|
||
} | ||
|
||
@Test | ||
public void testCompare() { | ||
ArrowBuf buffer1 = allocator.buffer(SIZE); | ||
ArrowBuf buffer2 = allocator.buffer(SIZE); | ||
|
||
for (int i = 0; i < SIZE; i++) { | ||
buffer1.setByte(i, i); | ||
buffer2.setByte(i, i); | ||
} | ||
|
||
assertEquals(0, ByteFunctionHelpers.compare(buffer1, 0, SIZE - 1, | ||
buffer2, 0, SIZE - 1)); | ||
|
||
buffer1.setByte(50, 10); | ||
|
||
assertEquals(-1, ByteFunctionHelpers.compare(buffer1, 0, SIZE - 1, | ||
buffer2, 0, SIZE - 1)); | ||
|
||
buffer1.close(); | ||
buffer2.close(); | ||
|
||
} | ||
} |