You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2022/05/30 12:01:00 UTC

[ignite-3] branch ignite-14972 updated: Add AsyncResultSetImpl.currentPageSize

This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a commit to branch ignite-14972
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/ignite-14972 by this push:
     new 9f847ff07 Add AsyncResultSetImpl.currentPageSize
9f847ff07 is described below

commit 9f847ff076a97662f76eb2f3233bd228e5a1b0ea
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Mon May 30 15:00:54 2022 +0300

    Add AsyncResultSetImpl.currentPageSize
---
 .../ignite/internal/sql/api/AsyncResultSetImpl.java     | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/api/AsyncResultSetImpl.java b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/api/AsyncResultSetImpl.java
index 726a865fb..c5ef52bf6 100644
--- a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/api/AsyncResultSetImpl.java
+++ b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/api/AsyncResultSetImpl.java
@@ -119,9 +119,7 @@ public class AsyncResultSetImpl implements AsyncResultSet {
     /** {@inheritDoc} */
     @Override
     public Iterable<SqlRow> currentPage() {
-        if (!hasRowSet()) {
-            throw new NoRowSetExpectedException("Query hasn't result set: [type=" + cur.queryType() + ']');
-        }
+        requireResultSet();
 
         return () -> new TransformingIterator<>(batchPage.items().iterator(), SqlRowImpl::new);
     }
@@ -129,9 +127,7 @@ public class AsyncResultSetImpl implements AsyncResultSet {
     /** {@inheritDoc} */
     @Override
     public int currentPageSize() {
-        if (!hasRowSet()) {
-            throw new NoRowSetExpectedException("Query hasn't result set: [type=" + cur.queryType() + ']');
-        }
+        requireResultSet();
 
         return batchPage.items().size();
     }
@@ -167,6 +163,12 @@ public class AsyncResultSetImpl implements AsyncResultSet {
         return cur.closeAsync().thenRun(closeRun);
     }
 
+    private void requireResultSet() {
+        if (!hasRowSet()) {
+            throw new NoRowSetExpectedException("Query has no result set: [type=" + cur.queryType() + ']');
+        }
+    }
+
     private class SqlRowImpl implements SqlRow {
         private final List<Object> row;
 
@@ -209,7 +211,6 @@ public class AsyncResultSetImpl implements AsyncResultSet {
         }
 
         /** {@inheritDoc} */
-        @SuppressWarnings("unchecked")
         @Override
         public <T> T valueOrDefault(@NotNull String columnName, T defaultValue) {
             T ret = (T) row.get(columnIndexChecked(columnName));
@@ -224,14 +225,12 @@ public class AsyncResultSetImpl implements AsyncResultSet {
         }
 
         /** {@inheritDoc} */
-        @SuppressWarnings("unchecked")
         @Override
         public <T> T value(@NotNull String columnName) throws IllegalArgumentException {
             return (T) row.get(columnIndexChecked(columnName));
         }
 
         /** {@inheritDoc} */
-        @SuppressWarnings("unchecked")
         @Override
         public <T> T value(int columnIndex) {
             return (T) row.get(columnIndex);