SegmentAnalyzer: Properly close column after retrieving it. (#10772)

This commit is contained in:
Gian Merlino 2021-01-16 19:26:34 -08:00 committed by GitHub
parent 95065bdf1a
commit 2b24dc3764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 5 deletions

View File

@ -37,6 +37,7 @@ import org.apache.druid.segment.QueryableIndex;
import org.apache.druid.segment.Segment;
import org.apache.druid.segment.StorageAdapter;
import org.apache.druid.segment.VirtualColumns;
import org.apache.druid.segment.column.BaseColumn;
import org.apache.druid.segment.column.BitmapIndex;
import org.apache.druid.segment.column.ColumnCapabilities;
import org.apache.druid.segment.column.ColumnCapabilitiesImpl;
@ -52,6 +53,7 @@ import org.joda.time.DateTime;
import org.joda.time.Interval;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Map;
@ -231,12 +233,17 @@ public class SegmentAnalyzer
}
} else if (capabilities.isDictionaryEncoded().isTrue()) {
// fallback if no bitmap index
DictionaryEncodedColumn<String> theColumn = (DictionaryEncodedColumn<String>) columnHolder.getColumn();
try (BaseColumn column = columnHolder.getColumn()) {
DictionaryEncodedColumn<String> theColumn = (DictionaryEncodedColumn<String>) column;
cardinality = theColumn.getCardinality();
if (analyzingMinMax() && cardinality > 0) {
min = NullHandling.nullToEmptyIfNeeded(theColumn.lookupName(0));
max = NullHandling.nullToEmptyIfNeeded(theColumn.lookupName(cardinality - 1));
}
}
catch (IOException e) {
throw new RuntimeException(e);
}
} else {
cardinality = 0;
}