mirror of https://github.com/apache/druid.git
undo unrelated
This commit is contained in:
parent
436ba18815
commit
929e68c11a
|
@ -22,24 +22,26 @@ 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 LazilyDecoratedRowsAndColumns rac;
|
||||
private final LinkedHashMap<String, Column> colCache = new LinkedHashMap<>();
|
||||
|
||||
public RowBasedFrameRowsAndColumns(Frame frame, RowSignature signature)
|
||||
{
|
||||
|
@ -63,10 +65,19 @@ public class RowBasedFrameRowsAndColumns implements RowsAndColumns, AutoCloseabl
|
|||
@Override
|
||||
public Column findColumn(String name)
|
||||
{
|
||||
if( rac == null) {
|
||||
LazilyDecoratedRowsAndColumns rac = new LazilyDecoratedRowsAndColumns(this, null, null, null, OffsetLimit.limit(Integer.MAX_VALUE), null, null);
|
||||
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));
|
||||
}
|
||||
}
|
||||
return rac.findColumn(name);
|
||||
return colCache.get(name);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -23,13 +23,10 @@ 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;
|
||||
|
@ -97,14 +94,4 @@ 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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue