You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "xtern (via GitHub)" <gi...@apache.org> on 2024/12/18 15:21:15 UTC

[PR] IGNITE-23604 [ignite-3]

xtern opened a new pull request, #4927:
URL: https://github.com/apache/ignite-3/pull/4927

   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-23604 Start a table driven implicit transaction for key-value plans [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4927:
URL: https://github.com/apache/ignite-3/pull/4927#discussion_r1896472878


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/KeyValueGetPlan.java:
##########
@@ -130,7 +130,7 @@ public IgniteKeyValueGet lookupNode() {
     @Override
     public <RowT> AsyncCursor<InternalSqlRow> execute(
             ExecutionContext<RowT> ctx,
-            @Nullable InternalTransaction tx,
+            InternalTransaction tx,

Review Comment:
   Key-value plan can be executed within an explicit (user-managed) transaction, in which case this assertion will fail



-- 
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-23604 Start a table driven implicit transaction for key-value plans [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4927:
URL: https://github.com/apache/ignite-3/pull/4927#discussion_r1896481345


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/KeyValueModifyPlan.java:
##########
@@ -115,7 +115,7 @@ public IgniteKeyValueModify modifyNode() {
     @Override
     public <RowT> AsyncCursor<InternalSqlRow> execute(
             ExecutionContext<RowT> ctx,
-            @Nullable InternalTransaction tx,
+            InternalTransaction tx,

Review Comment:
   I can put such assertion in `SelectCountPlan`, but, personally, I prefer to leave it as is, since this plan does not require transaction at all.



-- 
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-23604 Start a table driven implicit transaction for key-value plans [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4927:
URL: https://github.com/apache/ignite-3/pull/4927#discussion_r1896472728


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/KeyValueModifyPlan.java:
##########
@@ -115,7 +115,7 @@ public IgniteKeyValueModify modifyNode() {
     @Override
     public <RowT> AsyncCursor<InternalSqlRow> execute(
             ExecutionContext<RowT> ctx,
-            @Nullable InternalTransaction tx,
+            InternalTransaction tx,

Review Comment:
   Key-value plan can be executed within an explicit (user-managed) transaction, in which case this assertion will fail  :thinking:  



-- 
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-23604 Start a table driven implicit transaction for key-value plans [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4927:
URL: https://github.com/apache/ignite-3/pull/4927#discussion_r1895855677


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/tx/QueryTransactionContext.java:
##########
@@ -24,8 +24,15 @@
  * Context that allows to get explicit transaction provided by user or start implicit one.
  */
 public interface QueryTransactionContext {
-    /** Returns explicit transaction or start implicit one. */
-    QueryTransactionWrapper getOrStartImplicit(boolean readOnly);
+    /**
+     * Starts an implicit transaction if one has not been started previously
+     * and if there is no external (user-managed) transaction.
+     *
+     * @param readOnly Indicates whether the read-only transaction or read-write transaction should be started.
+     * @param tableDriven Indicates whether the implicit transaction will be managed by the table storage or the SQL engine.
+     * @return Transaction wrapper.
+     */
+    QueryTransactionWrapper getOrStartImplicit(boolean readOnly, boolean tableDriven);

Review Comment:
   Done, 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-23604 Start a table driven implicit transaction for key-value plans [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4927:
URL: https://github.com/apache/ignite-3/pull/4927#discussion_r1896472728


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/KeyValueModifyPlan.java:
##########
@@ -115,7 +115,7 @@ public IgniteKeyValueModify modifyNode() {
     @Override
     public <RowT> AsyncCursor<InternalSqlRow> execute(
             ExecutionContext<RowT> ctx,
-            @Nullable InternalTransaction tx,
+            InternalTransaction tx,

Review Comment:
   Key-value plan can be executed also within an explicit (user-managed) transaction, in which case this assertion will fail



-- 
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-23604 Start a table driven implicit transaction for key-value plans [ignite-3]

Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #4927:
URL: https://github.com/apache/ignite-3/pull/4927#discussion_r1896460421


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/KeyValueModifyPlan.java:
##########
@@ -115,7 +115,7 @@ public IgniteKeyValueModify modifyNode() {
     @Override
     public <RowT> AsyncCursor<InternalSqlRow> execute(
             ExecutionContext<RowT> ctx,
-            @Nullable InternalTransaction tx,
+            InternalTransaction tx,

Review Comment:
   seems additional assert will be useful ? 
   assert tx.implicit();



##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/KeyValueGetPlan.java:
##########
@@ -130,7 +130,7 @@ public IgniteKeyValueGet lookupNode() {
     @Override
     public <RowT> AsyncCursor<InternalSqlRow> execute(
             ExecutionContext<RowT> ctx,
-            @Nullable InternalTransaction tx,
+            InternalTransaction tx,

Review Comment:
   seems additional assert will be useful ? 
   assert tx.implicit();



-- 
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-23604 Start a table driven implicit transaction for key-value plans [ignite-3]

Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 commented on code in PR #4927:
URL: https://github.com/apache/ignite-3/pull/4927#discussion_r1895383601


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ScannableTableImpl.java:
##########
@@ -221,7 +221,7 @@ public <RowT> Publisher<RowT> indexLookup(
     @Override
     public <RowT> CompletableFuture<RowT> primaryKeyLookup(
             ExecutionContext<RowT> ctx,
-            @Nullable InternalTransaction explicitTx,
+            InternalTransaction tx,

Review Comment:
   I think, it worth to add assertion making sure no-one is passing `null` instead of transaction



##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/tx/QueryTransactionContext.java:
##########
@@ -24,8 +24,15 @@
  * Context that allows to get explicit transaction provided by user or start implicit one.
  */
 public interface QueryTransactionContext {
-    /** Returns explicit transaction or start implicit one. */
-    QueryTransactionWrapper getOrStartImplicit(boolean readOnly);
+    /**
+     * Starts an implicit transaction if one has not been started previously
+     * and if there is no external (user-managed) transaction.
+     *
+     * @param readOnly Indicates whether the read-only transaction or read-write transaction should be started.
+     * @param tableDriven Indicates whether the implicit transaction will be managed by the table storage or the SQL engine.
+     * @return Transaction wrapper.
+     */
+    QueryTransactionWrapper getOrStartImplicit(boolean readOnly, boolean tableDriven);

Review Comment:
   perhaps, it would be better to change names to `getOrStartSqlManaged(readOnly, implicit)`, WDYT? 



##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/KeyValueGetPlan.java:
##########
@@ -142,60 +148,65 @@ public <RowT> AsyncCursor<InternalSqlRow> execute(
         List<RexNode> projectionExpr = lookupNode.projects();
         List<RexNode> keyExpressions = lookupNode.keyExpressions();
 
-        RelDataType rowType = sqlTable.getRowType(Commons.typeFactory(), requiredColumns);
-
-        Supplier<RowT> keySupplier = ctx.expressionFactory()
-                .rowSource(keyExpressions);
-        Predicate<RowT> filter = filterExpr == null ? null : ctx.expressionFactory()
-                .predicate(filterExpr, rowType);
-        Function<RowT, RowT> projection = projectionExpr == null ? null : ctx.expressionFactory()
-                .project(projectionExpr, rowType);
-
-        RowHandler<RowT> rowHandler = ctx.rowHandler();
-        RowSchema rowSchema = TypeUtils.rowSchemaFromRelTypes(RelOptUtil.getFieldTypeList(rowType));
-        RowFactory<RowT> rowFactory = rowHandler.factory(rowSchema);
-
-        RelDataType resultType = lookupNode.getRowType();
-        BiFunction<Integer, Object, Object> internalTypeConverter = TypeUtils.resultTypeConverter(ctx, resultType);
-
-        ScannableTable scannableTable = execTable.scannableTable();
-        Function<RowT, Iterator<InternalSqlRow>> postProcess = row -> {
-            if (row == null) {
-                return Collections.emptyIterator();
-            }
-
-            if (filter != null && !filter.test(row)) {
-                return Collections.emptyIterator();
-            }
+        CompletableFuture<Iterator<InternalSqlRow>> result;
 
-            if (projection != null) {
-                row = projection.apply(row);
+        try {

Review Comment:
   does it make sense to move this `try-catch` on `ExecutionServiceImpl` level? This way we cover all the problem in a single place



##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ExecutionServiceImpl.java:
##########
@@ -442,9 +443,10 @@ private AsyncDataCursor<InternalSqlRow> executeExecutablePlan(
         QueryTransactionWrapper txWrapper = txContext.explicitTx();
 
         if (txWrapper == null) {
-            // underlying table will initiate transaction by itself, but we need stub to reuse
-            // TxAwareAsyncCursor
-            txWrapper = NoopTransactionWrapper.INSTANCE;
+            txWrapper = plan.transactional()

Review Comment:
   the only "non-transactional" plan is `SelectCountPlan` which is more like temporal solution. I would prefer not to introduce `transactional` property on `ExecutablePlan` interface, and get rid of `NoopTransactionWrapper` instead



-- 
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-23604 Start a table driven implicit transaction for key-value plans [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4927:
URL: https://github.com/apache/ignite-3/pull/4927#discussion_r1895854546


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ExecutionServiceImpl.java:
##########
@@ -442,9 +443,10 @@ private AsyncDataCursor<InternalSqlRow> executeExecutablePlan(
         QueryTransactionWrapper txWrapper = txContext.explicitTx();
 
         if (txWrapper == null) {
-            // underlying table will initiate transaction by itself, but we need stub to reuse
-            // TxAwareAsyncCursor
-            txWrapper = NoopTransactionWrapper.INSTANCE;
+            txWrapper = plan.transactional()

Review Comment:
   Done



##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ScannableTableImpl.java:
##########
@@ -221,7 +221,7 @@ public <RowT> Publisher<RowT> indexLookup(
     @Override
     public <RowT> CompletableFuture<RowT> primaryKeyLookup(
             ExecutionContext<RowT> ctx,
-            @Nullable InternalTransaction explicitTx,
+            InternalTransaction tx,

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-23604 Start a table driven implicit transaction for key-value plans [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4927:
URL: https://github.com/apache/ignite-3/pull/4927#discussion_r1896481345


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/KeyValueModifyPlan.java:
##########
@@ -115,7 +115,7 @@ public IgniteKeyValueModify modifyNode() {
     @Override
     public <RowT> AsyncCursor<InternalSqlRow> execute(
             ExecutionContext<RowT> ctx,
-            @Nullable InternalTransaction tx,
+            InternalTransaction tx,

Review Comment:
   I could put such assertion in `SelectCountPlan`, but I personally prefer to leave it as is since this plan does not require transaction at all.



-- 
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-23604 Start a table driven implicit transaction for key-value plans [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4927:
URL: https://github.com/apache/ignite-3/pull/4927#discussion_r1895855423


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/KeyValueGetPlan.java:
##########
@@ -142,60 +148,65 @@ public <RowT> AsyncCursor<InternalSqlRow> execute(
         List<RexNode> projectionExpr = lookupNode.projects();
         List<RexNode> keyExpressions = lookupNode.keyExpressions();
 
-        RelDataType rowType = sqlTable.getRowType(Commons.typeFactory(), requiredColumns);
-
-        Supplier<RowT> keySupplier = ctx.expressionFactory()
-                .rowSource(keyExpressions);
-        Predicate<RowT> filter = filterExpr == null ? null : ctx.expressionFactory()
-                .predicate(filterExpr, rowType);
-        Function<RowT, RowT> projection = projectionExpr == null ? null : ctx.expressionFactory()
-                .project(projectionExpr, rowType);
-
-        RowHandler<RowT> rowHandler = ctx.rowHandler();
-        RowSchema rowSchema = TypeUtils.rowSchemaFromRelTypes(RelOptUtil.getFieldTypeList(rowType));
-        RowFactory<RowT> rowFactory = rowHandler.factory(rowSchema);
-
-        RelDataType resultType = lookupNode.getRowType();
-        BiFunction<Integer, Object, Object> internalTypeConverter = TypeUtils.resultTypeConverter(ctx, resultType);
-
-        ScannableTable scannableTable = execTable.scannableTable();
-        Function<RowT, Iterator<InternalSqlRow>> postProcess = row -> {
-            if (row == null) {
-                return Collections.emptyIterator();
-            }
-
-            if (filter != null && !filter.test(row)) {
-                return Collections.emptyIterator();
-            }
+        CompletableFuture<Iterator<InternalSqlRow>> result;
 
-            if (projection != null) {
-                row = projection.apply(row);
+        try {

Review Comment:
   Thanks, try/catch moved to `ExecutionServiceImpl`



-- 
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-23604 Start a table driven implicit transaction for key-value plans [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4927:
URL: https://github.com/apache/ignite-3/pull/4927#discussion_r1895854546


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ExecutionServiceImpl.java:
##########
@@ -442,9 +443,10 @@ private AsyncDataCursor<InternalSqlRow> executeExecutablePlan(
         QueryTransactionWrapper txWrapper = txContext.explicitTx();
 
         if (txWrapper == null) {
-            // underlying table will initiate transaction by itself, but we need stub to reuse
-            // TxAwareAsyncCursor
-            txWrapper = NoopTransactionWrapper.INSTANCE;
+            txWrapper = plan.transactional()

Review Comment:
   Done, 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-23604 Start a table driven implicit transaction for key-value plans [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4927:
URL: https://github.com/apache/ignite-3/pull/4927#discussion_r1896481345


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/KeyValueModifyPlan.java:
##########
@@ -115,7 +115,7 @@ public IgniteKeyValueModify modifyNode() {
     @Override
     public <RowT> AsyncCursor<InternalSqlRow> execute(
             ExecutionContext<RowT> ctx,
-            @Nullable InternalTransaction tx,
+            InternalTransaction tx,

Review Comment:
   I can put such assertion in `SelectCountPlan`, but I personally prefer to leave it as is since this plan does not require transaction at all.



-- 
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-23604 Start a table driven implicit transaction for key-value plans [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern merged PR #4927:
URL: https://github.com/apache/ignite-3/pull/4927


-- 
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