You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/01/31 21:35:38 UTC

[GitHub] [arrow] emkornfield commented on a change in pull request #7276: ARROW-8947: [Java] MapWithOrdinal javadoc doesn't describe actual behaviour

emkornfield commented on a change in pull request #7276:
URL: https://github.com/apache/arrow/pull/7276#discussion_r567487571



##########
File path: java/vector/src/main/java/org/apache/arrow/vector/util/MapWithOrdinalImpl.java
##########
@@ -105,12 +105,18 @@ public boolean put(K key, V value, boolean override) {
     public V remove(Object key) {
       final Entry<Integer, V> oldPair = primary.remove(key);
       if (oldPair != null) {
-        final int lastOrdinal = secondary.size();
+        final int lastOrdinal = secondary.size() - 1;
         final V last = secondary.get(lastOrdinal);
         // normalize mappings so that all numbers until primary.size() is assigned
         // swap the last element with the deleted one
         secondary.put(oldPair.getKey(), last);
-        primary.put((K) key, new AbstractMap.SimpleImmutableEntry<>(oldPair.getKey(), last));
+        secondary.remove(lastOrdinal);
+        primary.entrySet()

Review comment:
       This seems like it might be a performance regression, would it be better to keep a datastructure that tracks unused ordinals?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org