walterddr commented on code in PR #9726: URL: https://github.com/apache/pinot/pull/9726#discussion_r1015567143
########## pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/operator/OperatorTestUtil.java: ########## @@ -18,33 +18,43 @@ */ package org.apache.pinot.query.runtime.operator; +import java.util.Arrays; import java.util.List; -import org.apache.pinot.common.datablock.BaseDataBlock; -import org.apache.pinot.common.datablock.DataBlockUtils; import org.apache.pinot.common.utils.DataSchema; +import org.apache.pinot.core.operator.BaseOperator; import org.apache.pinot.query.runtime.blocks.TransferableBlock; +import org.apache.pinot.query.testutils.MockDataBlockOperatorFactory; public class OperatorTestUtil { - private OperatorTestUtil() { - } + // simple key-value collision schema/data test set: "Aa" and "BB" have same hash code in java. + private static final List<List<Object[]>> SIMPLE_KV_DATA_ROWS = Arrays.asList( + Arrays.asList(new Object[]{1, "Aa"}, new Object[]{2, "BB"}, new Object[]{3, "BB"}), + Arrays.asList(new Object[]{1, "AA"}, new Object[]{2, "Aa"})); + private static final MockDataBlockOperatorFactory MOCK_OPERATOR_FACTORY; - public static final DataSchema TEST_DATA_SCHEMA = new DataSchema(new String[]{"foo", "bar"}, + public static final DataSchema SIMPLE_KV_DATA_SCHEMA = new DataSchema(new String[]{"foo", "bar"}, new DataSchema.ColumnDataType[]{DataSchema.ColumnDataType.INT, DataSchema.ColumnDataType.STRING}); - public static TransferableBlock getEndOfStreamRowBlock() { - return getEndOfStreamRowBlockWithSchema(); + public static final String OP_1 = "op1"; + public static final String OP_2 = "op2"; + + static { + MOCK_OPERATOR_FACTORY = new MockDataBlockOperatorFactory() + .registerOperator(OP_1, SIMPLE_KV_DATA_SCHEMA) + .registerOperator(OP_2, SIMPLE_KV_DATA_SCHEMA) + .addRows(OP_1, SIMPLE_KV_DATA_ROWS.get(0)) + .addRows(OP_2, SIMPLE_KV_DATA_ROWS.get(1)); Review Comment: also a sidenote. i think this static block should be in each test files (since they can register different data schema / rows) ########## pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/QueryRunnerTestBase.java: ########## @@ -127,29 +128,44 @@ protected void addDataToH2(Map<String, List<GenericRow>> rowsMap) public void setUp() throws Exception { DataTableBuilderFactory.setDataTableVersion(DataTableFactory.VERSION_4); - QueryServerEnclosure server1 = new QueryServerEnclosure( - ImmutableMap.of("a", INDEX_DIR_S1_A, "b", INDEX_DIR_S1_B, "c", INDEX_DIR_S1_C, "d_O", INDEX_DIR_S1_D), - QueryEnvironmentTestUtils.SERVER1_SEGMENTS); - QueryServerEnclosure server2 = new QueryServerEnclosure( - ImmutableMap.of("a", INDEX_DIR_S2_A, "c", INDEX_DIR_S2_C, "d_R", INDEX_DIR_S2_D, "d_O", INDEX_DIR_S1_D), - QueryEnvironmentTestUtils.SERVER2_SEGMENTS); + MockInstanceDataManagerFactory factory1 = new MockInstanceDataManagerFactory("server1") Review Comment: at the current moment this is stil manually registering using static code/member variable. I was thinking we should actually load data schema / test data (csv or other format) from file. thoughts? -- 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