forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apacheGH-14936: [Java] Remove netty dependency from arrow-vector (apa…
…che#38493) ### Rationale for this change This removes Netty from core Arrow modules that do not have net code (aside from tests). ### What changes are included in this PR? * Change use of IntObjectHashMap to come from Eclipse instead of Netty-common to remove the dependency on Netty from arrow-vector. * Add test cases for MapWithOrdinal. ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * Closes: apache#14936 Authored-by: James Duong <james.duong@improving.com> Signed-off-by: David Li <li.davidm96@gmail.com>
- Loading branch information
Showing
4 changed files
with
105 additions
and
13 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
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
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
97 changes: 97 additions & 0 deletions
97
java/vector/src/test/java/org/apache/arrow/vector/util/TestMapWithOrdinal.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,97 @@ | ||
/* | ||
* 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 junit.framework.TestCase.assertNull; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.util.Collection; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class TestMapWithOrdinal { | ||
|
||
private MapWithOrdinal<String, String> map; | ||
|
||
@Before | ||
public void setUp() { | ||
map = new MapWithOrdinalImpl<>(); | ||
} | ||
|
||
@Test | ||
public void testGetByOrdinal() { | ||
map.put("key0", "val0", true); | ||
assertEquals("val0", map.getByOrdinal(0)); | ||
|
||
map.put("key1", "val1", true); | ||
assertEquals("val1", map.getByOrdinal(1)); | ||
assertEquals("val0", map.getByOrdinal(0)); | ||
} | ||
|
||
@Test | ||
public void testGetByKey() { | ||
map.put("key0", "val0", true); | ||
assertEquals("val0", map.get("key0")); | ||
|
||
map.put("key1", "val1", true); | ||
assertEquals("val1", map.get("key1")); | ||
assertEquals("val0", map.get("key0")); | ||
} | ||
|
||
@Test | ||
public void testInvalidOrdinal() { | ||
map.put("key0", "val0", true); | ||
assertNull(map.getByOrdinal(1)); | ||
|
||
map.removeAll("key0"); | ||
assertNull(map.getByOrdinal(0)); | ||
} | ||
|
||
@Test | ||
public void testInvalidKey() { | ||
MapWithOrdinalImpl<String, String> map = new MapWithOrdinalImpl<>(); | ||
map.put("key0", "val0", true); | ||
assertNull(map.get("fake_key")); | ||
|
||
map.removeAll("key0"); | ||
assertNull(map.get("key0")); | ||
} | ||
|
||
@Test | ||
public void testValues() { | ||
map.put("key0", "val0", true); | ||
map.put("key1", "val1", true); | ||
|
||
Collection<String> values = map.values(); | ||
assertTrue(values.contains("val0")); | ||
assertTrue(values.contains("val1")); | ||
|
||
map.put("key1", "new_val1", true); | ||
values = map.values(); | ||
assertTrue(values.contains("val0")); | ||
assertTrue(values.contains("new_val1")); | ||
assertFalse(values.contains("val1")); | ||
|
||
map.removeAll("key0"); | ||
assertTrue(values.contains("new_val1")); | ||
assertFalse(values.contains("val0")); | ||
} | ||
} |