jackjlli commented on a change in pull request #6479: URL: https://github.com/apache/incubator-pinot/pull/6479#discussion_r597401003
########## File path: pinot-core/src/main/java/org/apache/pinot/core/indexsegment/mutable/IntermediateSegment.java ########## @@ -0,0 +1,375 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.core.indexsegment.mutable; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.annotation.Nullable; +import org.apache.pinot.core.common.DataSource; +import org.apache.pinot.core.data.partition.PartitionFunction; +import org.apache.pinot.core.data.partition.PartitionFunctionFactory; +import org.apache.pinot.core.indexsegment.generator.SegmentGeneratorConfig; +import org.apache.pinot.core.io.readerwriter.PinotDataBufferMemoryManager; +import org.apache.pinot.core.io.writer.impl.DirectMemoryManager; +import org.apache.pinot.core.io.writer.impl.MmapMemoryManager; +import org.apache.pinot.core.realtime.impl.dictionary.MutableDictionaryFactory; +import org.apache.pinot.core.realtime.impl.forward.FixedByteMVMutableForwardIndex; +import org.apache.pinot.core.realtime.impl.forward.FixedByteSVMutableForwardIndex; +import org.apache.pinot.core.segment.creator.impl.V1Constants; +import org.apache.pinot.core.segment.index.column.IntermediateIndexContainer; +import org.apache.pinot.core.segment.index.column.NumValuesInfo; +import org.apache.pinot.core.segment.index.loader.IndexLoadingConfig; +import org.apache.pinot.core.segment.index.metadata.SegmentMetadata; +import org.apache.pinot.core.segment.index.readers.MutableDictionary; +import org.apache.pinot.core.segment.index.readers.MutableForwardIndex; +import org.apache.pinot.core.segment.index.readers.ValidDocIndexReader; +import org.apache.pinot.core.startree.v2.StarTreeV2; +import org.apache.pinot.spi.config.table.ColumnPartitionConfig; +import org.apache.pinot.spi.config.table.SegmentPartitionConfig; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.data.FieldSpec; +import org.apache.pinot.spi.data.Schema; +import org.apache.pinot.spi.data.readers.GenericRow; +import org.apache.pinot.spi.stream.RowMetadata; +import org.apache.pinot.spi.utils.ByteArray; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * Intermediate segment format to store the collected data so far. This segment format will be used to generate the final + * offline segment in SegmentIndexCreationDriver. + */ +public class IntermediateSegment implements MutableSegment { + private static final Logger LOGGER = LoggerFactory.getLogger(IntermediateSegment.class); + + private static final int MAX_MULTI_VALUES_PER_ROW = 1000; + private static final int DEFAULT_CAPACITY = 100_000; + private static final int DEFAULT_EST_AVG_COL_SIZE = 32; + private static final int DEFAULT_EST_CARDINALITY = 5000; + + private final SegmentGeneratorConfig _segmentGeneratorConfig; + private final Schema _schema; + private final TableConfig _tableConfig; + private final String _segmentName; + private final PartitionFunction _partitionFunction; + private final String _partitionColumn; + private final Map<String, IntermediateIndexContainer> _indexContainerMap = new HashMap<>(); + private final PinotDataBufferMemoryManager _memoryManager; + + private final int _capacity = DEFAULT_CAPACITY; + private volatile int _numDocsIndexed = 0; + + public IntermediateSegment(SegmentGeneratorConfig segmentGeneratorConfig) { + _segmentGeneratorConfig = segmentGeneratorConfig; + _schema = segmentGeneratorConfig.getSchema(); + _tableConfig = segmentGeneratorConfig.getTableConfig(); + _segmentName = _segmentGeneratorConfig.getSegmentName(); + + Collection<FieldSpec> allFieldSpecs = _schema.getAllFieldSpecs(); Review comment: Updated. -- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org