Vladsz83 commented on code in PR #12600: URL: https://github.com/apache/ignite/pull/12600#discussion_r2657894322
########## modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/TableRowIterable.java: ########## @@ -0,0 +1,43 @@ +/* + * 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.ignite.internal.processors.query.calcite.exec; + +import java.util.Iterator; + +/** + * Interface to iterate over raw table data and convert this data to relational node rows. + * + * @param <TableRow>> Raw table row type. Review Comment: `>>` -> `>` . Two times, one below. Maybe single-line. ########## modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/AbstractCacheColumnsScan.java: ########## @@ -34,8 +36,8 @@ public abstract class AbstractCacheColumnsScan<Row> extends AbstractCacheScan<Ro /** */ protected final RelDataType rowType; - /** Participating columns. */ - protected final ImmutableBitSet requiredColumns; + /** Row field to column mapping. */ + protected final int[] fieldColMapping; Review Comment: Suggestion: it looks bit confusing. Let's rename pameters and fields like this everywhere to something like: `rawToRelColMapping` and/or `relToRawColMapping` ########## modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/TableRowIterable.java: ########## @@ -0,0 +1,43 @@ +/* + * 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.ignite.internal.processors.query.calcite.exec; + +import java.util.Iterator; + +/** + * Interface to iterate over raw table data and convert this data to relational node rows. + * + * @param <TableRow>> Raw table row type. + * @param <Row>> Relational node row type. + */ +public interface TableRowIterable<TableRow, Row> extends Iterable<Row> { + /** + * @return Table row iterator. + * */ Review Comment: `* */` -> `*/` ########## modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/IndexScan.java: ########## @@ -153,14 +153,11 @@ private int[] fieldToInlinedKeysMapping(int srcFieldsCnt) { return null; } - ImmutableBitSet reqCols = requiredColumns == null ? ImmutableBitSet.range(0, srcFieldsCnt) : - requiredColumns; - int[] fieldIdxMapping = new int[rowType.getFieldCount()]; - for (int i = 0, j = reqCols.nextSetBit(0); j != -1; j = reqCols.nextSetBit(j + 1), i++) { + for (int i = 0; i < fieldColMapping.length; i++) { // j = source field index, i = target field index. - int keyIdx = idxFieldMapping.indexOf(j); + int keyIdx = idxFieldMapping.indexOf(fieldColMapping[i]); Review Comment: What is 'j' now in the comment above? ########## modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/TableRowIterable.java: ########## @@ -0,0 +1,43 @@ +/* + * 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.ignite.internal.processors.query.calcite.exec; + +import java.util.Iterator; + +/** + * Interface to iterate over raw table data and convert this data to relational node rows. + * + * @param <TableRow>> Raw table row type. + * @param <Row>> Relational node row type. + */ +public interface TableRowIterable<TableRow, Row> extends Iterable<Row> { + /** + * @return Table row iterator. + * */ + public Iterator<TableRow> tableRowIterator(); + + /** + * Enriches {@code nodeRow} with columns from {@code tableRow} * Review Comment: `from {@code tableRow} *` -> `from {@code tableRow}.` ########## modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/AbstractCacheColumnsScan.java: ########## @@ -47,9 +49,30 @@ public abstract class AbstractCacheColumnsScan<Row> extends AbstractCacheScan<Ro super(ectx, desc.cacheContext(), parts); this.desc = desc; - this.requiredColumns = requiredColumns; rowType = desc.rowType(ectx.getTypeFactory(), requiredColumns); factory = ectx.rowHandler().factory(ectx.getTypeFactory(), rowType); + + ImmutableBitSet reqCols = requiredColumns == null ? ImmutableBitSet.range(0, rowType.getFieldCount()) Review Comment: Minor codestyle. I would prefer: ``` ImmutableBitSet reqCols = requiredColumns == null ? ImmutableBitSet.range(0, rowType.getFieldCount()) : requiredColumns; ########## modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/TableRowIterable.java: ########## @@ -0,0 +1,43 @@ +/* + * 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.ignite.internal.processors.query.calcite.exec; + +import java.util.Iterator; + +/** + * Interface to iterate over raw table data and convert this data to relational node rows. + * + * @param <TableRow>> Raw table row type. + * @param <Row>> Relational node row type. + */ +public interface TableRowIterable<TableRow, Row> extends Iterable<Row> { + /** + * @return Table row iterator. + * */ + public Iterator<TableRow> tableRowIterator(); + + /** + * Enriches {@code nodeRow} with columns from {@code tableRow} * + * + * @param tableRow Table row. + * @param nodeRow Relational node row. + * @param fieldColMapping Mapping from node row fields to table row columns. If column is not requried + * corresponding field has -1 mapped value. + * @return Enriched relational node row. Review Comment: If we return a relational row, why the mapping above is `from node row to table row`. The suggested renaming of `fieldColMapping` should also help with this. ########## modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/TableRowIterable.java: ########## @@ -0,0 +1,43 @@ +/* + * 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.ignite.internal.processors.query.calcite.exec; + +import java.util.Iterator; + +/** + * Interface to iterate over raw table data and convert this data to relational node rows. + * + * @param <TableRow>> Raw table row type. + * @param <Row>> Relational node row type. + */ +public interface TableRowIterable<TableRow, Row> extends Iterable<Row> { Review Comment: Do we need this new extra interface? Looks like we already have a bunch of scan interfaces and abstract classes. Can it be inside `AbstractCacheColumnsScan`? ########## modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/TableRowIterable.java: ########## @@ -0,0 +1,43 @@ +/* + * 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.ignite.internal.processors.query.calcite.exec; + +import java.util.Iterator; + +/** + * Interface to iterate over raw table data and convert this data to relational node rows. + * + * @param <TableRow>> Raw table row type. + * @param <Row>> Relational node row type. + */ +public interface TableRowIterable<TableRow, Row> extends Iterable<Row> { Review Comment: Naming. If we convert, the name might be smth. like `TableRawIterableConverter` or `TableRowFilterableIterable` -- 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]
