alex-plekhanov commented on code in PR #12593:
URL: https://github.com/apache/ignite/pull/12593#discussion_r2648050105
##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/TestTable.java:
##########
@@ -314,4 +330,171 @@ public TestTable addIndex(String name, int... keys) {
@Override public void authorize(Operation op) {
// No-op.
}
+
+ /** {@inheritDoc} */
+ @Override public <C> C unwrap(Class<C> cls) {
+ if (cls.isInstance(this))
+ return cls.cast(this);
+
+ if (cls.isInstance(desc))
+ return cls.cast(desc);
+
+ return null;
+ }
+
+ /** */
+ static class TestTableDescriptor extends NullInitializerExpressionFactory
implements CacheTableDescriptor {
+ /** */
+ private final Supplier<IgniteDistribution> distributionSupp;
+
+ /** */
+ private final RelDataType rowType;
+
+ /** */
+ private final GridCacheContextInfo<?, ?> cacheInfo;
+
+ /** */
+ public TestTableDescriptor(Supplier<IgniteDistribution> distribution,
RelDataType rowType) {
+ distributionSupp = distribution;
+ this.rowType = rowType;
+ cacheInfo = Mockito.mock(GridCacheContextInfo.class);
+
+ CacheConfiguration cfg = Mockito.mock(CacheConfiguration.class);
+ Mockito.when(cfg.isEagerTtl()).thenReturn(true);
+
+ Mockito.when(cacheInfo.cacheId()).thenReturn(CU.cacheId("TEST"));
+ Mockito.when(cacheInfo.config()).thenReturn(cfg);
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridCacheContextInfo<?, ?> cacheInfo() {
+ return cacheInfo;
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridCacheContext<?, ?> cacheContext() {
+ throw new AssertionError();
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteDistribution distribution() {
+ return distributionSupp.get();
+ }
+
+ /** {@inheritDoc} */
+ @Override public ColocationGroup colocationGroup(MappingQueryContext
ctx) {
+ throw new AssertionError();
+ }
+
+ /** {@inheritDoc} */
+ @Override public RelDataType rowType(IgniteTypeFactory factory,
ImmutableBitSet usedColumns) {
+ if (usedColumns == null)
+ return rowType;
+ else {
+ RelDataTypeFactory.Builder b = new
RelDataTypeFactory.Builder(factory);
+
+ for (int i = usedColumns.nextSetBit(0); i != -1; i =
usedColumns.nextSetBit(i + 1))
+ b.add(rowType.getFieldList().get(i));
+
+ return b.build();
+ }
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isUpdateAllowed(RelOptTable tbl, int colIdx) {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean match(CacheDataRow row) {
+ throw new AssertionError();
+ }
+
+ /** {@inheritDoc} */
+ @Override public <Row> Row toRow(ExecutionContext<Row> ectx,
CacheDataRow row, RowHandler.RowFactory<Row> factory,
+ @Nullable ImmutableBitSet requiredColumns) {
+ throw new AssertionError();
+ }
+
+ /** {@inheritDoc} */
+ @Override public <Row> ModifyTuple toTuple(ExecutionContext<Row> ectx,
Row row, TableModify.Operation op,
+ @Nullable Object arg) {
+ throw new AssertionError();
+ }
+
+ /** {@inheritDoc} */
+ @Override public ColumnDescriptor columnDescriptor(String fieldName) {
+ RelDataTypeField field = rowType.getField(fieldName, false, false);
+ return new TestColumnDescriptor(field.getIndex(), fieldName);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<ColumnDescriptor> columnDescriptors() {
+ return Commons.transform(rowType.getFieldList(), f -> new
TestColumnDescriptor(f.getIndex(), f.getName()));
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridQueryTypeDescriptor typeDescription() {
+ throw new AssertionError();
+ }
+
+ /** {@inheritDoc} */
+ @Override public RelDataType insertRowType(IgniteTypeFactory factory) {
+ ImmutableBitSet.Builder bitSetBuilder = ImmutableBitSet.builder();
+ for (int i = 0; i < rowType.getFieldCount(); i++) {
Review Comment:
Fixed
##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/TestTable.java:
##########
@@ -314,4 +330,171 @@ public TestTable addIndex(String name, int... keys) {
@Override public void authorize(Operation op) {
// No-op.
}
+
+ /** {@inheritDoc} */
+ @Override public <C> C unwrap(Class<C> cls) {
+ if (cls.isInstance(this))
+ return cls.cast(this);
+
+ if (cls.isInstance(desc))
+ return cls.cast(desc);
+
+ return null;
+ }
+
+ /** */
+ static class TestTableDescriptor extends NullInitializerExpressionFactory
implements CacheTableDescriptor {
+ /** */
+ private final Supplier<IgniteDistribution> distributionSupp;
+
+ /** */
+ private final RelDataType rowType;
+
+ /** */
+ private final GridCacheContextInfo<?, ?> cacheInfo;
+
+ /** */
+ public TestTableDescriptor(Supplier<IgniteDistribution> distribution,
RelDataType rowType) {
+ distributionSupp = distribution;
+ this.rowType = rowType;
+ cacheInfo = Mockito.mock(GridCacheContextInfo.class);
+
+ CacheConfiguration cfg = Mockito.mock(CacheConfiguration.class);
+ Mockito.when(cfg.isEagerTtl()).thenReturn(true);
+
+ Mockito.when(cacheInfo.cacheId()).thenReturn(CU.cacheId("TEST"));
+ Mockito.when(cacheInfo.config()).thenReturn(cfg);
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridCacheContextInfo<?, ?> cacheInfo() {
+ return cacheInfo;
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridCacheContext<?, ?> cacheContext() {
+ throw new AssertionError();
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteDistribution distribution() {
+ return distributionSupp.get();
+ }
+
+ /** {@inheritDoc} */
+ @Override public ColocationGroup colocationGroup(MappingQueryContext
ctx) {
+ throw new AssertionError();
+ }
+
+ /** {@inheritDoc} */
+ @Override public RelDataType rowType(IgniteTypeFactory factory,
ImmutableBitSet usedColumns) {
Review Comment:
Fixed
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]