siddharthteotia commented on code in PR #9726: URL: https://github.com/apache/pinot/pull/9726#discussion_r1015742201
########## pinot-query-runtime/src/test/java/org/apache/pinot/query/testutils/MockInstanceDataManagerFactory.java: ########## @@ -0,0 +1,168 @@ +/** + * 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.query.testutils; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; +import org.apache.commons.io.FileUtils; +import org.apache.pinot.core.data.manager.InstanceDataManager; +import org.apache.pinot.core.data.manager.offline.ImmutableSegmentDataManager; +import org.apache.pinot.segment.local.data.manager.SegmentDataManager; +import org.apache.pinot.segment.local.data.manager.TableDataManager; +import org.apache.pinot.segment.local.indexsegment.immutable.ImmutableSegmentLoader; +import org.apache.pinot.segment.local.segment.creator.impl.SegmentIndexCreationDriverImpl; +import org.apache.pinot.segment.local.segment.readers.GenericRowRecordReader; +import org.apache.pinot.segment.spi.ImmutableSegment; +import org.apache.pinot.segment.spi.creator.SegmentGeneratorConfig; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.config.table.TableType; +import org.apache.pinot.spi.data.Schema; +import org.apache.pinot.spi.data.readers.GenericRow; +import org.apache.pinot.spi.data.readers.RecordReader; +import org.apache.pinot.spi.utils.ReadMode; +import org.apache.pinot.spi.utils.builder.TableConfigBuilder; +import org.apache.pinot.spi.utils.builder.TableNameBuilder; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.matches; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + + +public class MockInstanceDataManagerFactory { + private static final String DATA_DIR_PREFIX = "MockInstanceDataDir"; + + private final Map<String, List<GenericRow>> _tableRowsMap; + private final Map<String, List<ImmutableSegment>> _tableSegmentMap; + private final Map<String, List<String>> _tableSegmentNameMap; + private final Map<String, File> _serverTableDataDirMap; + private final Map<String, Schema> _schemaMap; + private String _serverName; + + public MockInstanceDataManagerFactory(String serverName) { + _serverName = serverName; + _serverTableDataDirMap = new HashMap<>(); + _tableSegmentMap = new HashMap<>(); + _tableSegmentNameMap = new HashMap<>(); + _tableRowsMap = new HashMap<>(); + _schemaMap = new HashMap<>(); + } + + public MockInstanceDataManagerFactory registerTable(Schema schema, String tableName) { + TableType tableType = TableNameBuilder.getTableTypeFromTableName(tableName); + if (tableType == null) { + registerTableNameWithType(schema, TableNameBuilder.forType(TableType.OFFLINE).tableNameWithType(tableName)); + registerTableNameWithType(schema, TableNameBuilder.forType(TableType.REALTIME).tableNameWithType(tableName)); + } else { + registerTableNameWithType(schema, tableName); + } + return this; + } + + public MockInstanceDataManagerFactory addSegment(String tableNameWithType, List<GenericRow> rows) { Review Comment: I am not sure why is this needed. Segment level execution will anyway be done by leaf layers (current engine operators). For that we already have a pretty good framework for doing segment level (operator level) or inter segment / inter server type of testing. -- 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: commits-unsubscr...@pinot.apache.org 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