mayankshriv commented on a change in pull request #5722:
URL: https://github.com/apache/incubator-pinot/pull/5722#discussion_r459058116
##########
File path:
pinot-core/src/main/java/org/apache/pinot/core/indexsegment/mutable/MutableSegmentImpl.java
##########
@@ -1033,13 +960,89 @@ void updateMVEntry(int numValuesInMVEntry) {
_numValues += numValuesInMVEntry;
_maxNumValuesPerMVEntry = Math.max(_maxNumValuesPerMVEntry,
numValuesInMVEntry);
}
+ }
+
+ private class IndexContainer implements Closeable {
+ final FieldSpec _fieldSpec;
+ final PartitionFunction _partitionFunction;
+ final int _partitionId;
+ final NumValuesInfo _numValuesInfo;
+ final MutableForwardIndex _forwardIndex;
+ final BaseMutableDictionary _dictionary;
+ final RealtimeInvertedIndexReader _invertedIndex;
+ final InvertedIndexReader _rangeIndex;
+ final RealtimeLuceneTextIndexReader _textIndex;
+ final BloomFilterReader _bloomFilter;
+ final MutableNullValueVector _nullValueVector;
+
+ volatile Comparable _minValue;
+ volatile Comparable _maxValue;
+
+ // Hold the dictionary id for the latest record
+ int _dictId = Integer.MIN_VALUE;
+ int[] _dictIds;
+
+ IndexContainer(FieldSpec fieldSpec, PartitionFunction partitionFunction,
int partitionId,
+ NumValuesInfo numValuesInfo, MutableForwardIndex forwardIndex,
BaseMutableDictionary dictionary,
+ RealtimeInvertedIndexReader invertedIndex, InvertedIndexReader
rangeIndex,
+ RealtimeLuceneTextIndexReader textIndex, BloomFilterReader bloomFilter,
+ MutableNullValueVector nullValueVector) {
+ _fieldSpec = fieldSpec;
+ _partitionFunction = partitionFunction;
+ _partitionId = partitionId;
+ _numValuesInfo = numValuesInfo;
+ _forwardIndex = forwardIndex;
+ _dictionary = dictionary;
+ _invertedIndex = invertedIndex;
+ _rangeIndex = rangeIndex;
+ _textIndex = textIndex;
+ _bloomFilter = bloomFilter;
+ _nullValueVector = nullValueVector;
+ }
- int getNumValues() {
- return _numValues;
+ DataSource toDataSource() {
+ return new MutableDataSource(_fieldSpec, _numDocsIndexed,
_numValuesInfo._numValues,
+ _numValuesInfo._maxNumValuesPerMVEntry, _partitionFunction,
_partitionId, _minValue, _maxValue, _forwardIndex,
+ _dictionary, _invertedIndex, _rangeIndex, _textIndex, _bloomFilter,
_nullValueVector);
}
- int getMaxNumValuesPerMVEntry() {
- return _maxNumValuesPerMVEntry;
+ @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) {
Review comment:
I meant using `optionalDictionary.ifPresent(<doSomething>)`:
https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#ifPresent-java.util.function.Consumer-
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]