From 598cc46bae089b95f34d0e5cc02b4f25c73c064f Mon Sep 17 00:00:00 2001 From: Roman Leventov Date: Fri, 25 Aug 2017 14:30:39 -0500 Subject: [PATCH] Replace HashMap with Obj2IntMap in StringDimensionIndexer; Small optimization in StringDimensionMergerV9 (#4721) --- .../io/druid/segment/StringDimensionIndexer.java | 14 +++++++------- .../io/druid/segment/StringDimensionMergerV9.java | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/processing/src/main/java/io/druid/segment/StringDimensionIndexer.java b/processing/src/main/java/io/druid/segment/StringDimensionIndexer.java index 30a14dcd5bd..6a7ab2b9ada 100644 --- a/processing/src/main/java/io/druid/segment/StringDimensionIndexer.java +++ b/processing/src/main/java/io/druid/segment/StringDimensionIndexer.java @@ -23,7 +23,6 @@ import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.base.Strings; import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import com.google.common.primitives.Ints; import io.druid.collections.bitmap.BitmapFactory; import io.druid.collections.bitmap.MutableBitmap; @@ -44,6 +43,8 @@ import io.druid.segment.incremental.IncrementalIndex; import io.druid.segment.incremental.IncrementalIndexStorageAdapter; import it.unimi.dsi.fastutil.ints.IntArrays; import it.unimi.dsi.fastutil.ints.IntIterator; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2IntRBTreeMap; import it.unimi.dsi.fastutil.objects.Object2IntSortedMap; @@ -53,7 +54,6 @@ import java.util.Arrays; import java.util.BitSet; import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.function.Function; public class StringDimensionIndexer implements DimensionIndexer @@ -65,7 +65,7 @@ public class StringDimensionIndexer implements DimensionIndexer valueToId = Maps.newHashMap(); + private final Object2IntMap valueToId = new Object2IntOpenHashMap<>(); private final List idToValue = Lists.newArrayList(); private final Object lock; @@ -73,13 +73,13 @@ public class StringDimensionIndexer implements DimensionIndexer= 0) { return prev; } final int index = size(); diff --git a/processing/src/main/java/io/druid/segment/StringDimensionMergerV9.java b/processing/src/main/java/io/druid/segment/StringDimensionMergerV9.java index 296e911d187..887620c36ac 100644 --- a/processing/src/main/java/io/druid/segment/StringDimensionMergerV9.java +++ b/processing/src/main/java/io/druid/segment/StringDimensionMergerV9.java @@ -583,7 +583,7 @@ public class StringDimensionMergerV9 implements DimensionMergerV9 @Override public int skip(int n) { - return IntIteratorUtils.skip(this, n); + return IntIteratorUtils.skip(baseIterator, n); } }; }