gortiz commented on code in PR #10687:
URL: https://github.com/apache/pinot/pull/10687#discussion_r1183355852
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/indexsegment/mutable/MutableSegmentImpl.java:
##########
@@ -1390,125 +1224,67 @@ private class IndexContainer implements Closeable {
final PartitionFunction _partitionFunction;
final Set<Integer> _partitions;
final ValuesInfo _valuesInfo;
- final MutableForwardIndex _forwardIndex;
final MutableDictionary _dictionary;
- final MutableInvertedIndex _invertedIndex;
- final RangeIndexReader _rangeIndex;
- final MutableH3Index _h3Index;
- final MutableTextIndex _textIndex;
- final MutableTextIndex _fstIndex;
- final MutableJsonIndex _jsonIndex;
- final BloomFilterReader _bloomFilter;
final MutableNullValueVector _nullValueVector;
+ final Map<IndexType, MutableIndex> _mutableIndexes;
final String _sourceColumn;
final ValueAggregator _valueAggregator;
volatile Comparable _minValue;
volatile Comparable _maxValue;
-
- // Hold the dictionary id for the latest record
+ /**
+ * The dictionary id for the latest single-value record.
+ * It is set on {@link #updateDictionary(GenericRow)} and read in {@link
#addNewRow(int, GenericRow)}
+ */
int _dictId = Integer.MIN_VALUE;
+ /**
+ * The dictionary ids for the latest multi-value record.
+ * It is set on {@link #updateDictionary(GenericRow)} and read in {@link
#addNewRow(int, GenericRow)}
+ */
int[] _dictIds;
IndexContainer(FieldSpec fieldSpec, @Nullable PartitionFunction
partitionFunction,
- @Nullable Set<Integer> partitions, ValuesInfo valuesInfo,
MutableForwardIndex forwardIndex,
- @Nullable MutableDictionary dictionary, @Nullable MutableInvertedIndex
invertedIndex,
- @Nullable RangeIndexReader rangeIndex, @Nullable MutableTextIndex
textIndex,
- @Nullable MutableTextIndex fstIndex, @Nullable MutableJsonIndex
jsonIndex, @Nullable MutableH3Index h3Index,
- @Nullable BloomFilterReader bloomFilter, @Nullable
MutableNullValueVector nullValueVector,
+ @Nullable Set<Integer> partitions, ValuesInfo valuesInfo,
Map<IndexType, MutableIndex> mutableIndexes,
+ @Nullable MutableDictionary dictionary, @Nullable
MutableNullValueVector nullValueVector,
@Nullable String sourceColumn, @Nullable ValueAggregator
valueAggregator) {
+
Preconditions.checkArgument(mutableIndexes.containsKey(StandardIndexes.forward()),
"Forward index is required");
_fieldSpec = fieldSpec;
+ _mutableIndexes = mutableIndexes;
+ _dictionary = dictionary;
+ _nullValueVector = nullValueVector;
_partitionFunction = partitionFunction;
_partitions = partitions;
_valuesInfo = valuesInfo;
- _forwardIndex = forwardIndex;
- _dictionary = dictionary;
- _invertedIndex = invertedIndex;
- _rangeIndex = rangeIndex;
- _h3Index = h3Index;
-
- _textIndex = textIndex;
- _fstIndex = fstIndex;
- _jsonIndex = jsonIndex;
- _bloomFilter = bloomFilter;
- _nullValueVector = nullValueVector;
_sourceColumn = sourceColumn;
_valueAggregator = valueAggregator;
}
DataSource toDataSource() {
return new MutableDataSource(_fieldSpec, _numDocsIndexed,
_valuesInfo._numValues,
_valuesInfo._maxNumValuesPerMVEntry, _dictionary == null ? -1 :
_dictionary.length(), _partitionFunction,
- _partitions, _minValue, _maxValue, _forwardIndex, _dictionary,
_invertedIndex, _rangeIndex, _textIndex,
- _fstIndex, _jsonIndex, _h3Index, _bloomFilter, _nullValueVector,
_valuesInfo._varByteMVMaxRowLengthInBytes);
+ _partitions, _minValue, _maxValue, _mutableIndexes, _dictionary,
_nullValueVector,
+ _valuesInfo._varByteMVMaxRowLengthInBytes);
}
@Override
public void close() {
String column = _fieldSpec.getName();
- try {
- _forwardIndex.close();
- } catch (Exception e) {
- _logger.error("Caught exception while closing forward index for
column: {}, continuing with error", column, e);
- }
- if (_dictionary != null) {
- try {
- _dictionary.close();
- } catch (Exception e) {
- _logger.error("Caught exception while closing dictionary for column:
{}, continuing with error", column, e);
- }
- }
- if (_invertedIndex != null) {
- try {
- _invertedIndex.close();
- } catch (Exception e) {
- _logger.error("Caught exception while closing inverted index for
column: {}, continuing with error", column,
- e);
- }
- }
- if (_rangeIndex != null) {
- try {
- _rangeIndex.close();
- } catch (Exception e) {
- _logger.error("Caught exception while closing range index for
column: {}, continuing with error", column, e);
- }
- }
- if (_textIndex != null) {
- try {
- _textIndex.close();
- } catch (Exception e) {
- _logger.error("Caught exception while closing text index for column:
{}, continuing with error", column, e);
- }
- }
- if (_fstIndex != null) {
- try {
- _fstIndex.close();
- } catch (Exception e) {
- _logger.error("Caught exception while closing fst index for column:
{}, continuing with error", column, e);
- }
- }
- if (_jsonIndex != null) {
- try {
- _jsonIndex.close();
- } catch (Exception e) {
- _logger.error("Caught exception while closing json index for column:
{}, continuing with error", column, e);
- }
- }
- if (_h3Index != null) {
- try {
- _h3Index.close();
- } catch (Exception e) {
- _logger.error("Caught exception while closing H3 index for column:
{}, continuing with error", column, e);
- }
- }
- if (_bloomFilter != null) {
+
+ BiConsumer<IndexType<?, ?, ?>, AutoCloseable> closer = (indexType,
closeable) -> {
try {
- _bloomFilter.close();
+ if (closeable != null) {
Review Comment:
> Is this specifically for _dictionary and _nullValueVector?
Yes
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]