alex-plekhanov commented on code in PR #12189: URL: https://github.com/apache/ignite/pull/12189#discussion_r2228363827
########## modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/agg/GroupKey.java: ########## @@ -17,86 +17,98 @@ package org.apache.ignite.internal.processors.query.calcite.exec.exp.agg; -import java.util.Arrays; -import org.apache.ignite.internal.util.typedef.X; +import java.util.Objects; +import org.apache.ignite.binary.BinaryObjectException; +import org.apache.ignite.binary.BinaryRawReader; +import org.apache.ignite.binary.BinaryRawWriter; +import org.apache.ignite.binary.BinaryReader; +import org.apache.ignite.binary.BinaryWriter; +import org.apache.ignite.binary.Binarylizable; +import org.apache.ignite.internal.processors.query.calcite.exec.ArrayRowHandler; +import org.apache.ignite.internal.processors.query.calcite.exec.RowHandler; /** * */ -public class GroupKey { +public class GroupKey<Row> implements Binarylizable { /** */ - public static final GroupKey EMPTY_GRP_KEY = new GroupKey(X.EMPTY_OBJECT_ARRAY); + private Row row; /** */ - private final Object[] fields; + private RowHandler<Row> hnd; /** */ - public GroupKey(Object[] fields) { - this.fields = fields; + public GroupKey(Row row, RowHandler<Row> hnd) { + this.row = row; + this.hnd = hnd; } /** */ - public Object[] fields() { - return fields; + public Row row() { + return row; + } + + /** */ + public RowHandler<Row> rowHandler() { + return hnd; } /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; + @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException { + BinaryRawWriter rawWriter = writer.rawWriter(); - GroupKey grpKey = (GroupKey)o; + int colCnt = hnd.columnCount(row); - return Arrays.equals(fields, grpKey.fields); + rawWriter.writeInt(colCnt); + + for (int i = 0; i < colCnt; i++) + rawWriter.writeObject(hnd.get(i, row)); } /** {@inheritDoc} */ - @Override public int hashCode() { - return Arrays.hashCode(fields); - } + @Override public void readBinary(BinaryReader reader) throws BinaryObjectException { + BinaryRawReader rawReader = reader.rawReader(); - /** */ - public static Builder builder(int rowLen) { - return new Builder(rowLen); - } + int colCnt = rawReader.readInt(); - /** */ - public static class Builder { - /** */ - private final Object[] fields; + Object[] row0 = new Object[colCnt]; - /** */ - private int idx; + for (int i = 0; i < colCnt; i++) + row0[i] = rawReader.readObject(); - /** */ - private Builder(int rowLen) { - fields = new Object[rowLen]; - } + row = (Row)row0; + hnd = (RowHandler<Row>)ArrayRowHandler.INSTANCE; Review Comment: We use different row handlers in constructor. To optimaze serialization we store only required columns in GroupKey own format. After deserialization we have new row (as array) and not binded to the old row handler anymore, and can use array row handler. -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org