zstan commented on code in PR #2568: URL: https://github.com/apache/ignite-3/pull/2568#discussion_r1324056173
########## modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/ProjectedTuple.java: ########## @@ -0,0 +1,237 @@ +/* + * 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.sql.engine.util; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.nio.ByteBuffer; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.BitSet; +import java.util.UUID; +import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder; +import org.apache.ignite.internal.schema.BinaryRowConverter; +import org.apache.ignite.internal.schema.BinaryTuple; +import org.apache.ignite.internal.schema.BinaryTupleSchema; +import org.apache.ignite.internal.schema.BinaryTupleSchema.Element; +import org.apache.ignite.internal.schema.row.InternalTuple; + +/** + * A facade that creates projection of the given tuple. + * + * <p>Not thread safe! + * + * <p>This projection is used to change indexes of column in original tuple, or to trim + * few columns from original tuple. Here are a few examples:<pre> + * Having tuple ['foo', 'bar', 'baz'], we can + * + * - reorder fields with mapping [2, 1, 0] to get equivalent tuple ['baz', 'bar', 'foo'] + * - or trim certain fields with mapping [0, 2] to get equivalent tuple ['foo', 'baz'] + * - or even repeat some fields with mapping [0, 0, 0] to get equivalent tuple ['foo', 'foo', 'foo'] + * </pre> + */ +public class ProjectedTuple implements InternalTuple { + private final BinaryTupleSchema schema; + + private InternalTuple delegate; + private int[] projection; + + private boolean normalized = false; + + /** + * Constructor. + * + * @param schema A schema of the original tuple (represented by delegate). Used to read content of the delegate to build a + * proper byte buffer which content satisfying the schema with regard to given projection. + * @param delegate An original tuple to create projection from. + * @param projection A projection. That is, desired order of fields in original tuple. In that projection, index of the array is + * an index of field in resulting projection, and an element of the array at that index is an index of column in original + * tuple. + */ + public ProjectedTuple( + BinaryTupleSchema schema, + InternalTuple delegate, + int[] projection + ) { + this.schema = schema; + this.delegate = delegate; + this.projection = projection; + } + + @Override Review Comment: seems /** {@inheritDoc} */ are required here ? -- 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]
