From 362bea1090e2701a4d5852e2603e41e0305e035f Mon Sep 17 00:00:00 2001 From: binlijin Date: Fri, 11 Dec 2015 15:04:46 +0800 Subject: [PATCH] minor optimize IndexMerger's MMappedIndexRowIterable --- .../main/java/io/druid/segment/IndexMerger.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/processing/src/main/java/io/druid/segment/IndexMerger.java b/processing/src/main/java/io/druid/segment/IndexMerger.java index 489d3b794bb..6c61b857532 100644 --- a/processing/src/main/java/io/druid/segment/IndexMerger.java +++ b/processing/src/main/java/io/druid/segment/IndexMerger.java @@ -24,6 +24,7 @@ import com.google.common.base.Function; import com.google.common.base.Objects; import com.google.common.base.Preconditions; import com.google.common.base.Splitter; +import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Iterators; @@ -1157,6 +1158,18 @@ public class IndexMerger @Override public Iterator iterator() { + final IntBuffer[] converterArray = FluentIterable + .from(convertedDims) + .transform( + new Function() + { + @Override + public IntBuffer apply(String input) + { + return converters.get(input); + } + } + ).toArray(IntBuffer.class); return Iterators.transform( index.iterator(), new Function() @@ -1169,7 +1182,7 @@ public class IndexMerger int[][] dims = input.getDims(); int[][] newDims = new int[convertedDims.size()][]; for (int i = 0; i < convertedDims.size(); ++i) { - IntBuffer converter = converters.get(convertedDims.get(i)); + IntBuffer converter = converterArray[i]; if (converter == null) { continue;