low hanging fruit - presize hash map for DruidSegmentReader (#9836)

This commit is contained in:
Clint Wylie 2020-05-07 12:39:14 -07:00 committed by GitHub
parent 2c0746cfab
commit 267a6cc175
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -21,7 +21,6 @@ package org.apache.druid.indexing.input;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import org.apache.druid.data.input.InputEntity; import org.apache.druid.data.input.InputEntity;
import org.apache.druid.data.input.InputEntity.CleanableFile; import org.apache.druid.data.input.InputEntity.CleanableFile;
import org.apache.druid.data.input.InputRow; import org.apache.druid.data.input.InputRow;
@ -49,6 +48,7 @@ import org.apache.druid.segment.column.ColumnHolder;
import org.apache.druid.segment.data.IndexedInts; import org.apache.druid.segment.data.IndexedInts;
import org.apache.druid.segment.filter.Filters; import org.apache.druid.segment.filter.Filters;
import org.apache.druid.segment.realtime.firehose.WindowedStorageAdapter; import org.apache.druid.segment.realtime.firehose.WindowedStorageAdapter;
import org.apache.druid.utils.CollectionUtils;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import java.io.File; import java.io.File;
@ -245,7 +245,8 @@ public class DruidSegmentReader extends IntermediateRowParsingReader<Map<String,
if (!hasNext()) { if (!hasNext()) {
throw new NoSuchElementException(); throw new NoSuchElementException();
} }
final Map<String, Object> theEvent = Maps.newLinkedHashMap(); final Map<String, Object> theEvent =
CollectionUtils.newLinkedHashMapWithExpectedSize(dimSelectors.size() + metSelectors.size() + 1);
for (Entry<String, DimensionSelector> dimSelector : dimSelectors.entrySet()) { for (Entry<String, DimensionSelector> dimSelector : dimSelectors.entrySet()) {
final String dim = dimSelector.getKey(); final String dim = dimSelector.getKey();