You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "ygerzhedovich (via GitHub)" <gi...@apache.org> on 2023/12/01 12:38:06 UTC
[PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
ygerzhedovich opened a new pull request, #2912:
URL: https://github.com/apache/ignite-3/pull/2912
Thank you for submitting the pull request.
To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:
### The Review Checklist
- [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:
\- There is a single JIRA ticket related to the pull request.
\- The web-link to the pull request is attached to the JIRA ticket.
\- The JIRA ticket has the Patch Available state.
\- The description of the JIRA ticket explains WHAT was made, WHY and HOW.
\- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
- [ ] **Design:** new code conforms with the design principles of the components it is added to.
- [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
- [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
- [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
### Notes
- [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1418953059
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/InternalSqlRowSingleString.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder;
+import org.apache.ignite.internal.schema.BinaryTuple;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Realization of {@code InternalSqlRow} allowing to represent a SQL row with a single string column.
+ */
+public class InternalSqlRowSingleString implements InternalSqlRow {
+ private final String val;
+ private BinaryTuple row;
+
+ /**
+ * Constructor.
+ *
+ * @param string Value for single column row.
+ */
+ public InternalSqlRowSingleString(@Nullable String string) {
+ this.val = string;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @Nullable
Review Comment:
done
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1413472180
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ExecutionServiceImpl.java:
##########
@@ -578,19 +586,12 @@ private CompletableFuture<Void> executeFragment(IgniteRel treeRoot, ResolvedDepe
if (!(node instanceof Outbox)) {
Function<RowT, RowT> internalTypeConverter = TypeUtils.resultTypeConverter(ectx, treeRoot.getRowType());
- AsyncRootNode<RowT, List<Object>> rootNode = new AsyncRootNode<>(node, inRow -> {
- inRow = internalTypeConverter.apply(inRow);
-
- int rowSize = ectx.rowHandler().columnCount(inRow);
-
- List<Object> res = new ArrayList<>(rowSize);
-
- for (int i = 0; i < rowSize; i++) {
- res.add(ectx.rowHandler().get(i, inRow));
- }
-
- return res;
- });
+ AsyncRootNode<RowT, InternalSqlRow> rootNode = new AsyncRootNode<>(
+ node,
+ inRow -> {
+ inRow = internalTypeConverter.apply(inRow);
Review Comment:
why do we still need this conversion?
##########
modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/engine/util/InternalSqlRowForList.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.time.Duration;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.Period;
+import java.util.BitSet;
+import java.util.List;
+import java.util.UUID;
+import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder;
+import org.apache.ignite.internal.schema.BinaryTuple;
+import org.apache.ignite.internal.sql.engine.InternalSqlRow;
+import org.jetbrains.annotations.Nullable;
+
+/** InternalSqlRow implementation for test purposes only. */
+public class InternalSqlRowForList implements InternalSqlRow {
Review Comment:
```suggestion
public class ListToInternalSqlRowAdapter implements InternalSqlRow {
```
##########
modules/client-common/src/main/java/org/apache/ignite/internal/jdbc/JdbcConverterUtils.java:
##########
@@ -44,4 +45,78 @@ public static Class<?> columnTypeToJdbcClass(ColumnType type) {
return type.javaClass();
}
}
+
+ /**
+ * Derive value from BinaryTuple by given column number, column type and scale for decimal type.
+ *
+ * @param columnType Type of column in binaryTuple by index idx.
+ * @param binaryTuple BinaryTuple to extract value.
+ * @param idx Index of column in binaryTuple.
+ * @param decimalScale Scale for decimal column. If the column is of a different type, then the specific value does not matter.
+ * @return Derived value. The value can be {@code null}.
Review Comment:
```suggestion
* Derives value from {@link BinaryTuple} by given column index, column type, and scale for decimal type.
*
* @param columnType An expected type of the field.
* @param binaryTuple A tuple to derive value from.
* @param idx An index of a field of interest.
* @param decimalScale A scale for decimal column. If the column is of a different type, then the specific value does not matter.
* @return Derived value. The value can be {@code null}.
```
##########
modules/client-common/src/main/java/org/apache/ignite/internal/jdbc/proto/event/JdbcQueryFetchResult.java:
##########
@@ -95,10 +95,11 @@ public void writeBinary(ClientMessagePacker packer) {
packer.packBoolean(last);
- packer.packInt(items.size());
+ packer.packInt(rowTuples.size());
- for (List<Object> item : items) {
- packer.packObjectArrayAsBinaryTuple(item.toArray());
+ for (BinaryTuple item : rowTuples) {
+ packer.packInt(item.elementCount());
Review Comment:
why do we need to send this for every row in a page? I think, we can send it only once with very first page
##########
modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/engine/util/InternalSqlRowForList.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.time.Duration;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.Period;
+import java.util.BitSet;
+import java.util.List;
+import java.util.UUID;
+import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder;
+import org.apache.ignite.internal.schema.BinaryTuple;
+import org.apache.ignite.internal.sql.engine.InternalSqlRow;
+import org.jetbrains.annotations.Nullable;
+
+/** InternalSqlRow implementation for test purposes only. */
+public class InternalSqlRowForList implements InternalSqlRow {
+ List<Object> source;
+
+ public InternalSqlRowForList(List<Object> source) {
+ this.source = source;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public @Nullable Object get(int idx) {
+ return source.get(idx);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public int fieldCount() {
+ return source.size();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public BinaryTuple asBinaryTuple() {
+ BinaryTupleBuilder binaryTupleBuilder = new BinaryTupleBuilder(source.size());
+
+ source.forEach(o -> appendObject(binaryTupleBuilder, o));
+
+ return new BinaryTuple(source.size(), binaryTupleBuilder.build());
+ }
+
+ private void appendObject(BinaryTupleBuilder builder, Object obj) {
Review Comment:
```suggestion
private static void appendObject(BinaryTupleBuilder builder, @Nullable Object obj) {
```
##########
modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/engine/util/QueryCheckerImpl.java:
##########
@@ -322,7 +323,15 @@ public void check() {
assertEquals(metadataMatchers.size(), columnMetadata.size(), "Column metadata doesn't match");
}
- List<List<?>> res = Commons.cast(getAllFromCursor(cur));
+ List<InternalSqlRow> rows = Commons.cast(getAllFromCursor(cur));
+ List<List<?>> res = new ArrayList<>(rows.size());
+ rows.forEach(r -> {
Review Comment:
I believe forEach loop is more suitable here
##########
modules/api/src/main/java/org/apache/ignite/sql/ColumnType.java:
##########
@@ -26,86 +26,101 @@
import java.time.LocalTime;
import java.time.Period;
import java.util.BitSet;
+import java.util.HashMap;
+import java.util.Map;
import java.util.UUID;
/**
* Predefined column types.
*/
public enum ColumnType {
+ /** Null. */
+ NULL(Void.class, false, false, false, 0),
+
/** Boolean. */
- BOOLEAN(Boolean.class, false, false, false),
+ BOOLEAN(Boolean.class, false, false, false, 1),
/** 8-bit signed integer. */
- INT8(Byte.class, false, false, false),
+ INT8(Byte.class, false, false, false, 2),
/** 16-bit signed integer. */
- INT16(Short.class, false, false, false),
+ INT16(Short.class, false, false, false, 3),
/** 32-bit signed integer. */
- INT32(Integer.class, false, false, false),
+ INT32(Integer.class, false, false, false, 4),
/** 64-bit signed integer. */
- INT64(Long.class, false, false, false),
+ INT64(Long.class, false, false, false, 5),
/** 32-bit single-precision floating-point number. */
- FLOAT(Float.class, false, false, false),
+ FLOAT(Float.class, false, false, false, 6),
/**
* 64-bit double-precision floating-point number.
*
* <p>SQL`16 part 2 section 6.1 syntax rule 31, implementation-defined precision
*/
- DOUBLE(Double.class, false, false, false),
+ DOUBLE(Double.class, false, false, false, 7),
/** Arbitrary-precision signed decimal number. */
- DECIMAL(BigDecimal.class, true, true, false),
+ DECIMAL(BigDecimal.class, true, true, false, 8),
/** Timezone-free date. */
- DATE(LocalDate.class, false, false, false),
+ DATE(LocalDate.class, false, false, false, 9),
/** Timezone-free time with precision. */
- TIME(LocalTime.class, true, false, false),
+ TIME(LocalTime.class, true, false, false, 10),
/** Timezone-free datetime. */
- DATETIME(LocalDateTime.class, true, false, false),
+ DATETIME(LocalDateTime.class, true, false, false, 11),
/** Point on the time-line. Number of ticks since {@code 1970-01-01T00:00:00Z}. Tick unit depends on precision. */
- TIMESTAMP(Instant.class, true, false, false),
+ TIMESTAMP(Instant.class, true, false, false, 12),
/** 128-bit UUID. */
- UUID(UUID.class, false, false, false),
+ UUID(UUID.class, false, false, false, 13),
/** Bit mask. */
- BITMASK(BitSet.class, false, false, true),
+ BITMASK(BitSet.class, false, false, true, 14),
/** String. */
- STRING(String.class, false, false, true),
+ STRING(String.class, false, false, true, 15),
/** Binary data. */
- BYTE_ARRAY(byte[].class, false, false, true),
+ BYTE_ARRAY(byte[].class, false, false, true, 16),
/** Date interval. */
- PERIOD(Period.class, true, false, false),
+ PERIOD(Period.class, true, false, false, 17),
/** Time interval. */
- DURATION(Duration.class, true, false, false),
+ DURATION(Duration.class, true, false, false, 18),
/** Number. */
- NUMBER(BigInteger.class, true, false, false),
-
- /** Null. */
- NULL(Void.class, false, false, false);
+ NUMBER(BigInteger.class, true, false, false, 19);
private final Class<?> javaClass;
private final boolean precisionAllowed;
private final boolean scaleAllowed;
private final boolean lengthAllowed;
- ColumnType(Class<?> clazz, boolean precisionDefined, boolean scaleDefined, boolean lengthDefined) {
+ private final int id;
+
+ private static final Map<Integer, ColumnType> ENUM_ID_MAP = new HashMap<>();
+
+ static {
+ for (ColumnType columnType : values()) {
+ ColumnType prevValue = ENUM_ID_MAP.put(columnType.id, columnType);
+ assert prevValue == null : "Duplicate id of ColumnType " + prevValue.id;
+ }
+
+ }
+
+ ColumnType(Class<?> clazz, boolean precisionDefined, boolean scaleDefined, boolean lengthDefined, int id) {
Review Comment:
nitpicking: usually, an `id` is the first parameter in constructor
##########
modules/client-common/src/main/java/org/apache/ignite/internal/jdbc/JdbcConverterUtils.java:
##########
@@ -44,4 +45,78 @@ public static Class<?> columnTypeToJdbcClass(ColumnType type) {
return type.javaClass();
}
}
+
+ /**
+ * Derive value from BinaryTuple by given column number, column type and scale for decimal type.
+ *
+ * @param columnType Type of column in binaryTuple by index idx.
+ * @param binaryTuple BinaryTuple to extract value.
+ * @param idx Index of column in binaryTuple.
+ * @param decimalScale Scale for decimal column. If the column is of a different type, then the specific value does not matter.
+ * @return Derived value. The value can be {@code null}.
+ */
+ public static Object deriveValueFromBinaryTuple(ColumnType columnType, BinaryTuple binaryTuple, int idx, int decimalScale) {
Review Comment:
```suggestion
public static @Nullable Object deriveValueFromBinaryTuple(ColumnType columnType, BinaryTuple binaryTuple, int idx, int decimalScale) {
```
please check this everywhere in this patch: If certain parameter or return value may be null, then it should be marked as `@Nullable`
##########
modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/engine/util/InternalSqlRowForList.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.time.Duration;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.Period;
+import java.util.BitSet;
+import java.util.List;
+import java.util.UUID;
+import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder;
+import org.apache.ignite.internal.schema.BinaryTuple;
+import org.apache.ignite.internal.sql.engine.InternalSqlRow;
+import org.jetbrains.annotations.Nullable;
+
+/** InternalSqlRow implementation for test purposes only. */
+public class InternalSqlRowForList implements InternalSqlRow {
+ List<Object> source;
Review Comment:
```suggestion
private final List<Object> source;
```
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ptupitsyn (via GitHub)" <gi...@apache.org>.
ptupitsyn commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1412109366
##########
modules/api/src/main/java/org/apache/ignite/sql/ColumnType.java:
##########
@@ -26,86 +26,101 @@
import java.time.LocalTime;
import java.time.Period;
import java.util.BitSet;
+import java.util.HashMap;
+import java.util.Map;
import java.util.UUID;
/**
* Predefined column types.
*/
public enum ColumnType {
+ /** Null. */
+ NULL(Void.class, false, false, false, 0),
+
/** Boolean. */
- BOOLEAN(Boolean.class, false, false, false),
+ BOOLEAN(Boolean.class, false, false, false, 1),
/** 8-bit signed integer. */
- INT8(Byte.class, false, false, false),
+ INT8(Byte.class, false, false, false, 2),
/** 16-bit signed integer. */
- INT16(Short.class, false, false, false),
+ INT16(Short.class, false, false, false, 3),
/** 32-bit signed integer. */
- INT32(Integer.class, false, false, false),
+ INT32(Integer.class, false, false, false, 4),
/** 64-bit signed integer. */
- INT64(Long.class, false, false, false),
+ INT64(Long.class, false, false, false, 5),
/** 32-bit single-precision floating-point number. */
- FLOAT(Float.class, false, false, false),
+ FLOAT(Float.class, false, false, false, 6),
/**
* 64-bit double-precision floating-point number.
*
* <p>SQL`16 part 2 section 6.1 syntax rule 31, implementation-defined precision
*/
- DOUBLE(Double.class, false, false, false),
+ DOUBLE(Double.class, false, false, false, 7),
/** Arbitrary-precision signed decimal number. */
- DECIMAL(BigDecimal.class, true, true, false),
+ DECIMAL(BigDecimal.class, true, true, false, 8),
/** Timezone-free date. */
- DATE(LocalDate.class, false, false, false),
+ DATE(LocalDate.class, false, false, false, 9),
/** Timezone-free time with precision. */
- TIME(LocalTime.class, true, false, false),
+ TIME(LocalTime.class, true, false, false, 10),
/** Timezone-free datetime. */
- DATETIME(LocalDateTime.class, true, false, false),
+ DATETIME(LocalDateTime.class, true, false, false, 11),
/** Point on the time-line. Number of ticks since {@code 1970-01-01T00:00:00Z}. Tick unit depends on precision. */
- TIMESTAMP(Instant.class, true, false, false),
+ TIMESTAMP(Instant.class, true, false, false, 12),
/** 128-bit UUID. */
- UUID(UUID.class, false, false, false),
+ UUID(UUID.class, false, false, false, 13),
/** Bit mask. */
- BITMASK(BitSet.class, false, false, true),
+ BITMASK(BitSet.class, false, false, true, 14),
/** String. */
- STRING(String.class, false, false, true),
+ STRING(String.class, false, false, true, 15),
/** Binary data. */
- BYTE_ARRAY(byte[].class, false, false, true),
+ BYTE_ARRAY(byte[].class, false, false, true, 16),
/** Date interval. */
- PERIOD(Period.class, true, false, false),
+ PERIOD(Period.class, true, false, false, 17),
/** Time interval. */
- DURATION(Duration.class, true, false, false),
+ DURATION(Duration.class, true, false, false, 18),
/** Number. */
- NUMBER(BigInteger.class, true, false, false),
-
- /** Null. */
- NULL(Void.class, false, false, false);
+ NUMBER(BigInteger.class, true, false, false, 19);
private final Class<?> javaClass;
private final boolean precisionAllowed;
private final boolean scaleAllowed;
private final boolean lengthAllowed;
- ColumnType(Class<?> clazz, boolean precisionDefined, boolean scaleDefined, boolean lengthDefined) {
+ private final int id;
+
+ private static final Map<Integer, ColumnType> ENUM_ID_MAP = new HashMap<>();
Review Comment:
Array would be more efficient - ids are sequential.
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1413742376
##########
modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/engine/util/InternalSqlRowForList.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.time.Duration;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.Period;
+import java.util.BitSet;
+import java.util.List;
+import java.util.UUID;
+import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder;
+import org.apache.ignite.internal.schema.BinaryTuple;
+import org.apache.ignite.internal.sql.engine.InternalSqlRow;
+import org.jetbrains.annotations.Nullable;
+
+/** InternalSqlRow implementation for test purposes only. */
+public class InternalSqlRowForList implements InternalSqlRow {
Review Comment:
ok
##########
modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/engine/util/InternalSqlRowForList.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.time.Duration;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.Period;
+import java.util.BitSet;
+import java.util.List;
+import java.util.UUID;
+import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder;
+import org.apache.ignite.internal.schema.BinaryTuple;
+import org.apache.ignite.internal.sql.engine.InternalSqlRow;
+import org.jetbrains.annotations.Nullable;
+
+/** InternalSqlRow implementation for test purposes only. */
+public class InternalSqlRowForList implements InternalSqlRow {
+ List<Object> source;
+
+ public InternalSqlRowForList(List<Object> source) {
+ this.source = source;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public @Nullable Object get(int idx) {
+ return source.get(idx);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public int fieldCount() {
+ return source.size();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public BinaryTuple asBinaryTuple() {
+ BinaryTupleBuilder binaryTupleBuilder = new BinaryTupleBuilder(source.size());
+
+ source.forEach(o -> appendObject(binaryTupleBuilder, o));
+
+ return new BinaryTuple(source.size(), binaryTupleBuilder.build());
+ }
+
+ private void appendObject(BinaryTupleBuilder builder, Object obj) {
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1417650907
##########
modules/client-common/src/main/java/org/apache/ignite/internal/jdbc/JdbcConverterUtils.java:
##########
@@ -44,4 +46,79 @@ public static Class<?> columnTypeToJdbcClass(ColumnType type) {
return type.javaClass();
}
}
+
+ /**
+ * Derives value from {@link BinaryTuple} by given column index, column type, and scale for decimal type.
+ *
+ * @param columnType An expected type of the field.
+ * @param binaryTuple A tuple reader to derive value from.
+ * @param idx An index of a field of interest.
+ * @param decimalScale A scale for decimal field. If the field is of a different type, then the specific value does not matter.
+ * @return Derived value. The value can be {@code null}.
+ */
+ public static @Nullable Object deriveValueFromBinaryTuple(ColumnType columnType, BinaryTupleReader binaryTuple, int idx,
+ int decimalScale) {
+ switch (columnType) {
+ case INT8:
+ return binaryTuple.byteValue(idx);
Review Comment:
my mistake, thanks
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1413529455
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ExecutionServiceImpl.java:
##########
@@ -578,19 +586,12 @@ private CompletableFuture<Void> executeFragment(IgniteRel treeRoot, ResolvedDepe
if (!(node instanceof Outbox)) {
Function<RowT, RowT> internalTypeConverter = TypeUtils.resultTypeConverter(ectx, treeRoot.getRowType());
- AsyncRootNode<RowT, List<Object>> rootNode = new AsyncRootNode<>(node, inRow -> {
- inRow = internalTypeConverter.apply(inRow);
-
- int rowSize = ectx.rowHandler().columnCount(inRow);
-
- List<Object> res = new ArrayList<>(rowSize);
-
- for (int i = 0; i < rowSize; i++) {
- res.add(ectx.rowHandler().get(i, inRow));
- }
-
- return res;
- });
+ AsyncRootNode<RowT, InternalSqlRow> rootNode = new AsyncRootNode<>(
+ node,
+ inRow -> {
+ inRow = internalTypeConverter.apply(inRow);
Review Comment:
it still required for Date/Time types at least. Otherwise we have uncovered from internal representation values
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1417645612
##########
modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/engine/util/SqlTestUtils.java:
##########
@@ -213,4 +217,29 @@ public static Object generateValueByType(int base, ColumnType type) {
throw new IllegalArgumentException("unsupported type " + type);
}
}
+
+ /**
+ * Converts list of {@link InternalSqlRow} to list of list of objects, where internal list represent a row with fields.
+ *
+ * @param rows List
Review Comment:
thanks for your attention
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1417653862
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/InternalSqlRowSingleBoolean.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder;
+import org.apache.ignite.internal.schema.BinaryTuple;
+
+/**
+ * Realization of {@code InternalSqlRow} allowing to represent a SQL row with a single boolean column.
+ */
+public class InternalSqlRowSingleBoolean implements InternalSqlRow {
+ final boolean val;
+ BinaryTuple row;
+
+ /**
+ * Constructor.
+ *
+ * @param bool Value for single column row.
+ */
+ public InternalSqlRowSingleBoolean(boolean bool) {
+ this.val = bool;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Object get(int idx) {
+ assert idx == 0;
+ return val;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public int fieldCount() {
+ return 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public BinaryTuple asBinaryTuple() {
+ if (row == null) {
+ row = new BinaryTuple(1, new BinaryTupleBuilder(1).appendBoolean(val).build());
Review Comment:
shit..... thanks
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1412122396
##########
modules/client-common/src/main/java/org/apache/ignite/internal/jdbc/proto/event/JdbcQuerySingleResult.java:
##########
@@ -186,13 +228,21 @@ public void readBinary(ClientMessageUnpacker unpacker) {
updateCnt = unpacker.unpackLong();
last = unpacker.unpackBoolean();
- int size = unpacker.unpackInt();
+ decimalScales = unpacker.unpackIntArray();
+ int[] columnTypeIds = unpacker.unpackIntArray();
- items = new ArrayList<>(size);
+ columnTypes = new ArrayList<>(columnTypeIds.length);
+ for (int columnType : columnTypeIds) {
+ columnTypes.add(ColumnType.getById(columnType));
+ }
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ptupitsyn (via GitHub)" <gi...@apache.org>.
ptupitsyn commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1412095168
##########
modules/client-common/src/main/java/org/apache/ignite/internal/jdbc/proto/event/JdbcQuerySingleResult.java:
##########
@@ -161,10 +194,19 @@ public void writeBinary(ClientMessagePacker packer) {
packer.packLong(updateCnt);
packer.packBoolean(last);
- packer.packInt(items.size());
+ packer.packIntArray(decimalScales);
+
+ int[] columnTypes = new int[this.columnTypes.size()];
+ for (int i = 0; i < this.columnTypes.size(); i++) {
+ columnTypes[i] = this.columnTypes.get(i).id();
+ }
+
+ packer.packIntArray(columnTypes);
Review Comment:
Avoid array allocation:
```suggestion
packer.packInt(this.columnTypes.size());
for (int i = 0; i < this.columnTypes.size(); i++) {
packer.packInt(this.columnTypes.get(i).id());
}
```
##########
modules/client-common/src/main/java/org/apache/ignite/internal/jdbc/proto/event/JdbcQuerySingleResult.java:
##########
@@ -186,13 +228,21 @@ public void readBinary(ClientMessageUnpacker unpacker) {
updateCnt = unpacker.unpackLong();
last = unpacker.unpackBoolean();
- int size = unpacker.unpackInt();
+ decimalScales = unpacker.unpackIntArray();
+ int[] columnTypeIds = unpacker.unpackIntArray();
- items = new ArrayList<>(size);
+ columnTypes = new ArrayList<>(columnTypeIds.length);
+ for (int columnType : columnTypeIds) {
+ columnTypes.add(ColumnType.getById(columnType));
+ }
Review Comment:
Avoid array allocation:
```java
int count = unpacker.unpackInt();
columnTypes = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
columnTypes.add(ColumnType.getById(unpacker.unpackInt()));
}
```
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 merged PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1413742764
##########
modules/client-common/src/main/java/org/apache/ignite/internal/jdbc/JdbcConverterUtils.java:
##########
@@ -44,4 +45,78 @@ public static Class<?> columnTypeToJdbcClass(ColumnType type) {
return type.javaClass();
}
}
+
+ /**
+ * Derive value from BinaryTuple by given column number, column type and scale for decimal type.
+ *
+ * @param columnType Type of column in binaryTuple by index idx.
+ * @param binaryTuple BinaryTuple to extract value.
+ * @param idx Index of column in binaryTuple.
+ * @param decimalScale Scale for decimal column. If the column is of a different type, then the specific value does not matter.
+ * @return Derived value. The value can be {@code null}.
Review Comment:
thanks, 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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1417466839
##########
modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/engine/util/SqlTestUtils.java:
##########
@@ -213,4 +217,29 @@ public static Object generateValueByType(int base, ColumnType type) {
throw new IllegalArgumentException("unsupported type " + type);
}
}
+
+ /**
+ * Converts list of {@link InternalSqlRow} to list of list of objects, where internal list represent a row with fields.
+ *
+ * @param rows List
+ * @return List of converted rows.
+ */
+ public static List<List<?>> convertSqlRows(List<InternalSqlRow> rows) {
Review Comment:
```suggestion
public static List<List<Object>> convertSqlRows(List<InternalSqlRow> rows) {
```
##########
modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/engine/util/SqlTestUtils.java:
##########
@@ -213,4 +217,29 @@ public static Object generateValueByType(int base, ColumnType type) {
throw new IllegalArgumentException("unsupported type " + type);
}
}
+
+ /**
+ * Converts list of {@link InternalSqlRow} to list of list of objects, where internal list represent a row with fields.
+ *
+ * @param rows List
Review Comment:
this line looks incomplete
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/InternalSqlRowImpl.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.schema.BinaryTuple;
+import org.apache.ignite.internal.sql.engine.exec.RowHandler;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Realization of {@code InternalSqlRow} allowing to avoid earlier unnecessary row deserialization, for example when we need to pass it to
Review Comment:
```suggestion
* Implementation of {@code InternalSqlRow} allowing to avoid earlier unnecessary row deserialization, for example when we need to pass it to
```
##########
modules/client-common/src/main/java/org/apache/ignite/internal/jdbc/JdbcConverterUtils.java:
##########
@@ -44,4 +46,79 @@ public static Class<?> columnTypeToJdbcClass(ColumnType type) {
return type.javaClass();
}
}
+
+ /**
+ * Derives value from {@link BinaryTuple} by given column index, column type, and scale for decimal type.
+ *
+ * @param columnType An expected type of the field.
+ * @param binaryTuple A tuple reader to derive value from.
+ * @param idx An index of a field of interest.
+ * @param decimalScale A scale for decimal field. If the field is of a different type, then the specific value does not matter.
+ * @return Derived value. The value can be {@code null}.
+ */
+ public static @Nullable Object deriveValueFromBinaryTuple(ColumnType columnType, BinaryTupleReader binaryTuple, int idx,
+ int decimalScale) {
+ switch (columnType) {
+ case INT8:
+ return binaryTuple.byteValue(idx);
Review Comment:
you either should make sure that value not null or use *Boxed version of the getter for every primitive
##########
modules/jdbc/src/main/java/org/apache/ignite/internal/jdbc/JdbcStatement.java:
##########
@@ -164,9 +167,26 @@ protected void execute0(JdbcStatementType stmtType, String sql, Object[] args) t
JdbcQueryCursorHandler handler = new JdbcClientQueryCursorHandler(result.getChannel());
for (JdbcQuerySingleResult jdbcRes : executeResult.results()) {
+ int columnCount = jdbcRes.columnTypes().size();
+ Function<BinaryTupleReader, List<Object>> transformer = (tuple) -> {
+ List<ColumnType> columnTypes = jdbcRes.columnTypes();
+ int[] decimalScales = jdbcRes.decimalScales();
Review Comment:
better to do it outside of a lambda to let GC to collect the response object
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/InternalSqlRowSingleBoolean.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder;
+import org.apache.ignite.internal.schema.BinaryTuple;
+
+/**
+ * Realization of {@code InternalSqlRow} allowing to represent a SQL row with a single boolean column.
+ */
+public class InternalSqlRowSingleBoolean implements InternalSqlRow {
+ final boolean val;
+ BinaryTuple row;
+
+ /**
+ * Constructor.
+ *
+ * @param bool Value for single column row.
+ */
+ public InternalSqlRowSingleBoolean(boolean bool) {
+ this.val = bool;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Object get(int idx) {
+ assert idx == 0;
+ return val;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public int fieldCount() {
+ return 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public BinaryTuple asBinaryTuple() {
+ if (row == null) {
+ row = new BinaryTuple(1, new BinaryTupleBuilder(1).appendBoolean(val).build());
Review Comment:
I see you fall into the trap of BinaryTupleBuilder :)
if not specified explicitly, the buffer of size `org.apache.ignite.internal.binarytuple.BinaryTupleBuilder#DEFAULT_BUFFER_SIZE` (4k bytes) will be allocated
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/InternalSqlRowSingleBoolean.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder;
+import org.apache.ignite.internal.schema.BinaryTuple;
+
+/**
+ * Realization of {@code InternalSqlRow} allowing to represent a SQL row with a single boolean column.
+ */
+public class InternalSqlRowSingleBoolean implements InternalSqlRow {
+ final boolean val;
+ BinaryTuple row;
Review Comment:
private final ?
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/InternalSqlRowImpl.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.schema.BinaryTuple;
+import org.apache.ignite.internal.sql.engine.exec.RowHandler;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Realization of {@code InternalSqlRow} allowing to avoid earlier unnecessary row deserialization, for example when we need to pass it to
+ * wire.
+ *
+ * @param <RowT> Type of the sql row.
+ */
+public class InternalSqlRowImpl<RowT> implements InternalSqlRow {
+ private final RowT row;
+ private final RowHandler<RowT> rowHandler;
+
+ /**
+ * Constructor.
+ *
+ * @param row Sql row.
+ * @param rowHandler Handler to deserialize given row.
+ */
+ public InternalSqlRowImpl(RowT row, RowHandler<RowT> rowHandler) {
+ this.row = row;
+ this.rowHandler = rowHandler;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @Nullable
+ public Object get(int idx) {
Review Comment:
```suggestion
public @Nullable Object get(int idx) {
```
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1418392454
##########
modules/client-common/src/main/java/org/apache/ignite/internal/jdbc/JdbcConverterUtils.java:
##########
@@ -44,4 +46,79 @@ public static Class<?> columnTypeToJdbcClass(ColumnType type) {
return type.javaClass();
}
}
+
+ /**
+ * Derives value from {@link BinaryTuple} by given column index, column type, and scale for decimal type.
Review Comment:
plz fix javadoc, {@link BinaryTuple} is not resolved
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1412273773
##########
modules/client-common/src/main/java/org/apache/ignite/internal/jdbc/proto/event/JdbcQuerySingleResult.java:
##########
@@ -161,10 +194,19 @@ public void writeBinary(ClientMessagePacker packer) {
packer.packLong(updateCnt);
packer.packBoolean(last);
- packer.packInt(items.size());
+ packer.packIntArray(decimalScales);
+
+ int[] columnTypes = new int[this.columnTypes.size()];
+ for (int i = 0; i < this.columnTypes.size(); i++) {
+ columnTypes[i] = this.columnTypes.get(i).id();
+ }
+
+ packer.packIntArray(columnTypes);
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1412122606
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/InternalSqlRowImpl.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.schema.BinaryTuple;
+import org.apache.ignite.internal.sql.engine.exec.RowHandler;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Realization of {@code InternalSqlRow} allowing to avoid earlier unnecessary row deserialization, for example when we need to pass it to
+ * wire.
+ *
+ * @param <RowT> Type of the sql row.
+ */
+public class InternalSqlRowImpl<RowT> implements InternalSqlRow {
+ private RowT row;
+ private RowHandler<RowT> rowHandler;
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1417657029
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/InternalSqlRowSingleBoolean.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder;
+import org.apache.ignite.internal.schema.BinaryTuple;
+
+/**
+ * Realization of {@code InternalSqlRow} allowing to represent a SQL row with a single boolean column.
+ */
+public class InternalSqlRowSingleBoolean implements InternalSqlRow {
+ final boolean val;
+ BinaryTuple row;
Review Comment:
private - yes
final - no
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1418940114
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/InternalSqlRowSingleBoolean.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder;
+import org.apache.ignite.internal.schema.BinaryTuple;
+
+/**
+ * Realization of {@code InternalSqlRow} allowing to represent a SQL row with a single boolean column.
Review Comment:
ok
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1418744516
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/InternalSqlRowSingleString.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder;
+import org.apache.ignite.internal.schema.BinaryTuple;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Realization of {@code InternalSqlRow} allowing to represent a SQL row with a single string column.
+ */
+public class InternalSqlRowSingleString implements InternalSqlRow {
+ private final String val;
+ private BinaryTuple row;
+
+ /**
+ * Constructor.
+ *
+ * @param string Value for single column row.
+ */
+ public InternalSqlRowSingleString(@Nullable String string) {
+ this.val = string;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @Nullable
Review Comment:
according to [our guidelines](https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations), type-use annotations appear immediately before the annotated type
please check this everywhere in the patch
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/InternalSqlRowSingleBoolean.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder;
+import org.apache.ignite.internal.schema.BinaryTuple;
+
+/**
+ * Realization of {@code InternalSqlRow} allowing to represent a SQL row with a single boolean column.
Review Comment:
```suggestion
* Implementation of {@code InternalSqlRow} allowing to represent a SQL row with a single boolean column.
```
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/InternalSqlRowSingleString.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder;
+import org.apache.ignite.internal.schema.BinaryTuple;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Realization of {@code InternalSqlRow} allowing to represent a SQL row with a single string column.
Review Comment:
```suggestion
* Implementation of {@code InternalSqlRow} allowing to represent a SQL row with a single string column.
```
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/InternalSqlRowSingleString.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder;
+import org.apache.ignite.internal.schema.BinaryTuple;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Realization of {@code InternalSqlRow} allowing to represent a SQL row with a single string column.
+ */
+public class InternalSqlRowSingleString implements InternalSqlRow {
+ private final String val;
+ private BinaryTuple row;
+
+ /**
+ * Constructor.
+ *
+ * @param string Value for single column row.
+ */
+ public InternalSqlRowSingleString(@Nullable String string) {
+ this.val = string;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @Nullable
+ public String get(int idx) {
+ assert idx == 0;
+ return val;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public int fieldCount() {
+ return 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public BinaryTuple asBinaryTuple() {
+ if (row == null) {
+ row = new BinaryTuple(1, new BinaryTupleBuilder(1).appendString(val).build());
+ }
+ return row;
+ }
Review Comment:
```suggestion
public BinaryTuple asBinaryTuple() {
if (row == null) {
int estimatedSize = val == null ? 0 : val.length();
boolean exactEstimate = val == null;
row = new BinaryTuple(1, new BinaryTupleBuilder(1, estimatedSize, exactEstimate).appendString(val).build());
}
return row;
}
```
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ExecutionServiceImpl.java:
##########
@@ -578,19 +586,12 @@ private CompletableFuture<Void> executeFragment(IgniteRel treeRoot, ResolvedDepe
if (!(node instanceof Outbox)) {
Function<RowT, RowT> internalTypeConverter = TypeUtils.resultTypeConverter(ectx, treeRoot.getRowType());
- AsyncRootNode<RowT, List<Object>> rootNode = new AsyncRootNode<>(node, inRow -> {
- inRow = internalTypeConverter.apply(inRow);
-
- int rowSize = ectx.rowHandler().columnCount(inRow);
-
- List<Object> res = new ArrayList<>(rowSize);
-
- for (int i = 0; i < rowSize; i++) {
- res.add(ectx.rowHandler().get(i, inRow));
- }
-
- return res;
- });
+ AsyncRootNode<RowT, InternalSqlRow> rootNode = new AsyncRootNode<>(
+ node,
+ inRow -> {
+ inRow = internalTypeConverter.apply(inRow);
Review Comment:
still, this doesn't feel right. Rows created by RowFactory are supposed to work with internal format only. Everything is forking now is because we still have ObjectsArrayRowWrapper which can store arbitrary values regardless the types.
proper way is to have additional conversion in InternalSqlRowImpl. See usages of `org.apache.ignite.internal.sql.engine.util.TypeUtils#fromInternal` for example
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1417645912
##########
modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/engine/util/SqlTestUtils.java:
##########
@@ -213,4 +217,29 @@ public static Object generateValueByType(int base, ColumnType type) {
throw new IllegalArgumentException("unsupported type " + type);
}
}
+
+ /**
+ * Converts list of {@link InternalSqlRow} to list of list of objects, where internal list represent a row with fields.
+ *
+ * @param rows List
+ * @return List of converted rows.
+ */
+ public static List<List<?>> convertSqlRows(List<InternalSqlRow> rows) {
Review Comment:
ok
##########
modules/jdbc/src/main/java/org/apache/ignite/internal/jdbc/JdbcStatement.java:
##########
@@ -164,9 +167,26 @@ protected void execute0(JdbcStatementType stmtType, String sql, Object[] args) t
JdbcQueryCursorHandler handler = new JdbcClientQueryCursorHandler(result.getChannel());
for (JdbcQuerySingleResult jdbcRes : executeResult.results()) {
+ int columnCount = jdbcRes.columnTypes().size();
+ Function<BinaryTupleReader, List<Object>> transformer = (tuple) -> {
+ List<ColumnType> columnTypes = jdbcRes.columnTypes();
+ int[] decimalScales = jdbcRes.decimalScales();
Review Comment:
good catch!
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1413812890
##########
modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/engine/util/InternalSqlRowForList.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.time.Duration;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.Period;
+import java.util.BitSet;
+import java.util.List;
+import java.util.UUID;
+import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder;
+import org.apache.ignite.internal.schema.BinaryTuple;
+import org.apache.ignite.internal.sql.engine.InternalSqlRow;
+import org.jetbrains.annotations.Nullable;
+
+/** InternalSqlRow implementation for test purposes only. */
+public class InternalSqlRowForList implements InternalSqlRow {
+ List<Object> source;
Review Comment:
fixed
##########
modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/engine/util/QueryCheckerImpl.java:
##########
@@ -322,7 +323,15 @@ public void check() {
assertEquals(metadataMatchers.size(), columnMetadata.size(), "Column metadata doesn't match");
}
- List<List<?>> res = Commons.cast(getAllFromCursor(cur));
+ List<InternalSqlRow> rows = Commons.cast(getAllFromCursor(cur));
+ List<List<?>> res = new ArrayList<>(rows.size());
+ rows.forEach(r -> {
Review Comment:
agree
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ptupitsyn (via GitHub)" <gi...@apache.org>.
ptupitsyn commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1412099770
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/InternalSqlRowImpl.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.schema.BinaryTuple;
+import org.apache.ignite.internal.sql.engine.exec.RowHandler;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Realization of {@code InternalSqlRow} allowing to avoid earlier unnecessary row deserialization, for example when we need to pass it to
+ * wire.
+ *
+ * @param <RowT> Type of the sql row.
+ */
+public class InternalSqlRowImpl<RowT> implements InternalSqlRow {
+ private RowT row;
+ private RowHandler<RowT> rowHandler;
Review Comment:
```suggestion
private final RowT row;
private final RowHandler<RowT> rowHandler;
```
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1418941432
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/InternalSqlRowSingleString.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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;
+
+import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder;
+import org.apache.ignite.internal.schema.BinaryTuple;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Realization of {@code InternalSqlRow} allowing to represent a SQL row with a single string column.
+ */
+public class InternalSqlRowSingleString implements InternalSqlRow {
+ private final String val;
+ private BinaryTuple row;
+
+ /**
+ * Constructor.
+ *
+ * @param string Value for single column row.
+ */
+ public InternalSqlRowSingleString(@Nullable String string) {
+ this.val = string;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @Nullable
+ public String get(int idx) {
+ assert idx == 0;
+ return val;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public int fieldCount() {
+ return 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public BinaryTuple asBinaryTuple() {
+ if (row == null) {
+ row = new BinaryTuple(1, new BinaryTupleBuilder(1).appendString(val).build());
+ }
+ return row;
+ }
Review Comment:
agree
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1413813405
##########
modules/client-common/src/main/java/org/apache/ignite/internal/jdbc/JdbcConverterUtils.java:
##########
@@ -44,4 +45,78 @@ public static Class<?> columnTypeToJdbcClass(ColumnType type) {
return type.javaClass();
}
}
+
+ /**
+ * Derive value from BinaryTuple by given column number, column type and scale for decimal type.
+ *
+ * @param columnType Type of column in binaryTuple by index idx.
+ * @param binaryTuple BinaryTuple to extract value.
+ * @param idx Index of column in binaryTuple.
+ * @param decimalScale Scale for decimal column. If the column is of a different type, then the specific value does not matter.
+ * @return Derived value. The value can be {@code null}.
+ */
+ public static Object deriveValueFromBinaryTuple(ColumnType columnType, BinaryTuple binaryTuple, int idx, int decimalScale) {
Review Comment:
thanks
##########
modules/api/src/main/java/org/apache/ignite/sql/ColumnType.java:
##########
@@ -26,86 +26,101 @@
import java.time.LocalTime;
import java.time.Period;
import java.util.BitSet;
+import java.util.HashMap;
+import java.util.Map;
import java.util.UUID;
/**
* Predefined column types.
*/
public enum ColumnType {
+ /** Null. */
+ NULL(Void.class, false, false, false, 0),
+
/** Boolean. */
- BOOLEAN(Boolean.class, false, false, false),
+ BOOLEAN(Boolean.class, false, false, false, 1),
/** 8-bit signed integer. */
- INT8(Byte.class, false, false, false),
+ INT8(Byte.class, false, false, false, 2),
/** 16-bit signed integer. */
- INT16(Short.class, false, false, false),
+ INT16(Short.class, false, false, false, 3),
/** 32-bit signed integer. */
- INT32(Integer.class, false, false, false),
+ INT32(Integer.class, false, false, false, 4),
/** 64-bit signed integer. */
- INT64(Long.class, false, false, false),
+ INT64(Long.class, false, false, false, 5),
/** 32-bit single-precision floating-point number. */
- FLOAT(Float.class, false, false, false),
+ FLOAT(Float.class, false, false, false, 6),
/**
* 64-bit double-precision floating-point number.
*
* <p>SQL`16 part 2 section 6.1 syntax rule 31, implementation-defined precision
*/
- DOUBLE(Double.class, false, false, false),
+ DOUBLE(Double.class, false, false, false, 7),
/** Arbitrary-precision signed decimal number. */
- DECIMAL(BigDecimal.class, true, true, false),
+ DECIMAL(BigDecimal.class, true, true, false, 8),
/** Timezone-free date. */
- DATE(LocalDate.class, false, false, false),
+ DATE(LocalDate.class, false, false, false, 9),
/** Timezone-free time with precision. */
- TIME(LocalTime.class, true, false, false),
+ TIME(LocalTime.class, true, false, false, 10),
/** Timezone-free datetime. */
- DATETIME(LocalDateTime.class, true, false, false),
+ DATETIME(LocalDateTime.class, true, false, false, 11),
/** Point on the time-line. Number of ticks since {@code 1970-01-01T00:00:00Z}. Tick unit depends on precision. */
- TIMESTAMP(Instant.class, true, false, false),
+ TIMESTAMP(Instant.class, true, false, false, 12),
/** 128-bit UUID. */
- UUID(UUID.class, false, false, false),
+ UUID(UUID.class, false, false, false, 13),
/** Bit mask. */
- BITMASK(BitSet.class, false, false, true),
+ BITMASK(BitSet.class, false, false, true, 14),
/** String. */
- STRING(String.class, false, false, true),
+ STRING(String.class, false, false, true, 15),
/** Binary data. */
- BYTE_ARRAY(byte[].class, false, false, true),
+ BYTE_ARRAY(byte[].class, false, false, true, 16),
/** Date interval. */
- PERIOD(Period.class, true, false, false),
+ PERIOD(Period.class, true, false, false, 17),
/** Time interval. */
- DURATION(Duration.class, true, false, false),
+ DURATION(Duration.class, true, false, false, 18),
/** Number. */
- NUMBER(BigInteger.class, true, false, false),
-
- /** Null. */
- NULL(Void.class, false, false, false);
+ NUMBER(BigInteger.class, true, false, false, 19);
private final Class<?> javaClass;
private final boolean precisionAllowed;
private final boolean scaleAllowed;
private final boolean lengthAllowed;
- ColumnType(Class<?> clazz, boolean precisionDefined, boolean scaleDefined, boolean lengthDefined) {
+ private final int id;
+
+ private static final Map<Integer, ColumnType> ENUM_ID_MAP = new HashMap<>();
+
+ static {
+ for (ColumnType columnType : values()) {
+ ColumnType prevValue = ENUM_ID_MAP.put(columnType.id, columnType);
+ assert prevValue == null : "Duplicate id of ColumnType " + prevValue.id;
+ }
+
+ }
+
+ ColumnType(Class<?> clazz, boolean precisionDefined, boolean scaleDefined, boolean lengthDefined, int id) {
Review Comment:
agree
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1413867943
##########
modules/client-common/src/main/java/org/apache/ignite/internal/jdbc/proto/event/JdbcQueryFetchResult.java:
##########
@@ -95,10 +95,11 @@ public void writeBinary(ClientMessagePacker packer) {
packer.packBoolean(last);
- packer.packInt(items.size());
+ packer.packInt(rowTuples.size());
- for (List<Object> item : items) {
- packer.packObjectArrayAsBinaryTuple(item.toArray());
+ for (BinaryTuple item : rowTuples) {
+ packer.packInt(item.elementCount());
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1413498235
##########
modules/api/src/main/java/org/apache/ignite/sql/ColumnType.java:
##########
@@ -26,86 +26,101 @@
import java.time.LocalTime;
import java.time.Period;
import java.util.BitSet;
+import java.util.HashMap;
+import java.util.Map;
import java.util.UUID;
/**
* Predefined column types.
*/
public enum ColumnType {
+ /** Null. */
+ NULL(Void.class, false, false, false, 0),
+
/** Boolean. */
- BOOLEAN(Boolean.class, false, false, false),
+ BOOLEAN(Boolean.class, false, false, false, 1),
/** 8-bit signed integer. */
- INT8(Byte.class, false, false, false),
+ INT8(Byte.class, false, false, false, 2),
/** 16-bit signed integer. */
- INT16(Short.class, false, false, false),
+ INT16(Short.class, false, false, false, 3),
/** 32-bit signed integer. */
- INT32(Integer.class, false, false, false),
+ INT32(Integer.class, false, false, false, 4),
/** 64-bit signed integer. */
- INT64(Long.class, false, false, false),
+ INT64(Long.class, false, false, false, 5),
/** 32-bit single-precision floating-point number. */
- FLOAT(Float.class, false, false, false),
+ FLOAT(Float.class, false, false, false, 6),
/**
* 64-bit double-precision floating-point number.
*
* <p>SQL`16 part 2 section 6.1 syntax rule 31, implementation-defined precision
*/
- DOUBLE(Double.class, false, false, false),
+ DOUBLE(Double.class, false, false, false, 7),
/** Arbitrary-precision signed decimal number. */
- DECIMAL(BigDecimal.class, true, true, false),
+ DECIMAL(BigDecimal.class, true, true, false, 8),
/** Timezone-free date. */
- DATE(LocalDate.class, false, false, false),
+ DATE(LocalDate.class, false, false, false, 9),
/** Timezone-free time with precision. */
- TIME(LocalTime.class, true, false, false),
+ TIME(LocalTime.class, true, false, false, 10),
/** Timezone-free datetime. */
- DATETIME(LocalDateTime.class, true, false, false),
+ DATETIME(LocalDateTime.class, true, false, false, 11),
/** Point on the time-line. Number of ticks since {@code 1970-01-01T00:00:00Z}. Tick unit depends on precision. */
- TIMESTAMP(Instant.class, true, false, false),
+ TIMESTAMP(Instant.class, true, false, false, 12),
/** 128-bit UUID. */
- UUID(UUID.class, false, false, false),
+ UUID(UUID.class, false, false, false, 13),
/** Bit mask. */
- BITMASK(BitSet.class, false, false, true),
+ BITMASK(BitSet.class, false, false, true, 14),
/** String. */
- STRING(String.class, false, false, true),
+ STRING(String.class, false, false, true, 15),
/** Binary data. */
- BYTE_ARRAY(byte[].class, false, false, true),
+ BYTE_ARRAY(byte[].class, false, false, true, 16),
/** Date interval. */
- PERIOD(Period.class, true, false, false),
+ PERIOD(Period.class, true, false, false, 17),
/** Time interval. */
- DURATION(Duration.class, true, false, false),
+ DURATION(Duration.class, true, false, false, 18),
/** Number. */
- NUMBER(BigInteger.class, true, false, false),
-
- /** Null. */
- NULL(Void.class, false, false, false);
+ NUMBER(BigInteger.class, true, false, false, 19);
private final Class<?> javaClass;
private final boolean precisionAllowed;
private final boolean scaleAllowed;
private final boolean lengthAllowed;
- ColumnType(Class<?> clazz, boolean precisionDefined, boolean scaleDefined, boolean lengthDefined) {
+ private final int id;
+
+ private static final Map<Integer, ColumnType> ENUM_ID_MAP = new HashMap<>();
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20813: Introduce InternalSqlRow as resulting row of QueryProcessor [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #2912:
URL: https://github.com/apache/ignite-3/pull/2912#discussion_r1418676045
##########
modules/client-common/src/main/java/org/apache/ignite/internal/jdbc/JdbcConverterUtils.java:
##########
@@ -44,4 +46,79 @@ public static Class<?> columnTypeToJdbcClass(ColumnType type) {
return type.javaClass();
}
}
+
+ /**
+ * Derives value from {@link BinaryTuple} by given column index, column type, and scale for decimal type.
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org