From 436ba18815edc639b402a378a9c9a6edec2668fe Mon Sep 17 00:00:00 2001 From: Zoltan Haindrich Date: Mon, 5 Aug 2024 12:59:19 +0000 Subject: [PATCH] x --- .../druid/msq/exec/TestMSQSqlModule.java | 14 +++++++++-- .../concrete/RowBasedFrameRowsAndColumns.java | 23 +++++-------------- .../druid/frame/read/FrameReaderTest.java | 13 +++++++++++ 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/exec/TestMSQSqlModule.java b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/exec/TestMSQSqlModule.java index 946f18e9db6..5e1edd554ad 100644 --- a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/exec/TestMSQSqlModule.java +++ b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/exec/TestMSQSqlModule.java @@ -63,9 +63,11 @@ class TestMSQSqlModule extends TestDruidModule { @Provides @LazySingleton - private MSQTestOverlordServiceClient extracted(ObjectMapper queryJsonMapper, Injector injector) + private MSQTestOverlordServiceClient makeOverlordServiceClient( + ObjectMapper queryJsonMapper, + Injector injector, + WorkerMemoryParameters workerMemoryParameters) { - final WorkerMemoryParameters workerMemoryParameters = MSQTestBase.makeTestWorkerMemoryParameters(); final MSQTestOverlordServiceClient indexingServiceClient = new MSQTestOverlordServiceClient( queryJsonMapper, injector, @@ -76,6 +78,14 @@ class TestMSQSqlModule extends TestDruidModule { return indexingServiceClient; } + @Provides + @LazySingleton + private WorkerMemoryParameters makeWorkerMemoryParameters() + { + final WorkerMemoryParameters workerMemoryParameters = MSQTestBase.makeTestWorkerMemoryParameters(); + return workerMemoryParameters; + } + @Provides @LazySingleton public DruidMeta createMeta( diff --git a/processing/src/main/java/org/apache/druid/query/rowsandcols/concrete/RowBasedFrameRowsAndColumns.java b/processing/src/main/java/org/apache/druid/query/rowsandcols/concrete/RowBasedFrameRowsAndColumns.java index 234410bc070..5afd3102ded 100644 --- a/processing/src/main/java/org/apache/druid/query/rowsandcols/concrete/RowBasedFrameRowsAndColumns.java +++ b/processing/src/main/java/org/apache/druid/query/rowsandcols/concrete/RowBasedFrameRowsAndColumns.java @@ -22,26 +22,24 @@ package org.apache.druid.query.rowsandcols.concrete; import org.apache.druid.frame.Frame; import org.apache.druid.frame.FrameType; import org.apache.druid.frame.read.FrameReader; -import org.apache.druid.frame.read.columnar.FrameColumnReaders; import org.apache.druid.frame.segment.FrameStorageAdapter; -import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.Intervals; +import org.apache.druid.query.operator.OffsetLimit; +import org.apache.druid.query.rowsandcols.LazilyDecoratedRowsAndColumns; import org.apache.druid.query.rowsandcols.RowsAndColumns; import org.apache.druid.query.rowsandcols.column.Column; import org.apache.druid.segment.CloseableShapeshifter; import org.apache.druid.segment.StorageAdapter; -import org.apache.druid.segment.column.ColumnType; import org.apache.druid.segment.column.RowSignature; import javax.annotation.Nullable; import java.util.Collection; -import java.util.LinkedHashMap; public class RowBasedFrameRowsAndColumns implements RowsAndColumns, AutoCloseable, CloseableShapeshifter { private final Frame frame; private final RowSignature signature; - private final LinkedHashMap colCache = new LinkedHashMap<>(); + private LazilyDecoratedRowsAndColumns rac; public RowBasedFrameRowsAndColumns(Frame frame, RowSignature signature) { @@ -65,19 +63,10 @@ public class RowBasedFrameRowsAndColumns implements RowsAndColumns, AutoCloseabl @Override public Column findColumn(String name) { - if (!colCache.containsKey(name)) { - final int columnIndex = signature.indexOf(name); - if (columnIndex < 0) { - colCache.put(name, null); - } else { - final ColumnType columnType = signature - .getColumnType(columnIndex) - .orElseThrow(() -> new ISE("just got the id, why is columnType not there?")); - - colCache.put(name, FrameColumnReaders.create(name, columnIndex, columnType).readRACColumn(frame)); - } + if( rac == null) { + LazilyDecoratedRowsAndColumns rac = new LazilyDecoratedRowsAndColumns(this, null, null, null, OffsetLimit.limit(Integer.MAX_VALUE), null, null); } - return colCache.get(name); + return rac.findColumn(name); } @SuppressWarnings("unchecked") diff --git a/processing/src/test/java/org/apache/druid/frame/read/FrameReaderTest.java b/processing/src/test/java/org/apache/druid/frame/read/FrameReaderTest.java index bf24b6cb5f0..23e480921f0 100644 --- a/processing/src/test/java/org/apache/druid/frame/read/FrameReaderTest.java +++ b/processing/src/test/java/org/apache/druid/frame/read/FrameReaderTest.java @@ -23,10 +23,13 @@ import com.google.common.collect.Iterables; import org.apache.druid.frame.Frame; import org.apache.druid.frame.FrameType; import org.apache.druid.frame.allocation.HeapMemoryAllocator; +import org.apache.druid.frame.read.columnar.FrameColumnReaders; import org.apache.druid.frame.testutil.FrameSequenceBuilder; import org.apache.druid.segment.QueryableIndexStorageAdapter; import org.apache.druid.segment.StorageAdapter; import org.apache.druid.segment.TestIndex; +import org.apache.druid.segment.column.ColumnType; +import org.apache.druid.segment.column.RowSignature; import org.apache.druid.testing.InitializedNullHandlingTest; import org.junit.Assert; import org.junit.Before; @@ -94,4 +97,14 @@ public class FrameReaderTest extends InitializedNullHandlingTest ); } } + + @Test + public void testReadRacColumn() + { + RowSignature rs = inputAdapter.getRowSignature(); + int colNo = 1; + String name = rs.getColumnName(colNo); + ColumnType type = rs.getColumnType(colNo).get(); + FrameColumnReaders.create(name, colNo, type).readRACColumn(frame); + } }