ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [4/8] ignite git commit: IGNITE-2495: Changed Cursor behaviour to match test.
Date Wed, 10 Feb 2016 14:21:45 GMT
IGNITE-2495: Changed Cursor behaviour to match test.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/27f438cf
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/27f438cf
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/27f438cf

Branch: refs/heads/ignite-1786
Commit: 27f438cf3802ac49f9e358e9de004f2235a2ef55
Parents: 0b26795
Author: isapego <isapego@gridgain.com>
Authored: Thu Jan 28 18:37:01 2016 +0300
Committer: isapego <isapego@gridgain.com>
Committed: Thu Jan 28 18:37:01 2016 +0300

----------------------------------------------------------------------
 modules/platforms/cpp/odbc-test/src/cursor_test.cpp | 10 ++++++----
 .../platforms/cpp/odbc/include/ignite/odbc/cursor.h | 15 +++++++++++----
 modules/platforms/cpp/odbc/src/cursor.cpp           | 16 ++++++++++------
 modules/platforms/cpp/odbc/src/query/data_query.cpp | 10 +++++-----
 4 files changed, 32 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/27f438cf/modules/platforms/cpp/odbc-test/src/cursor_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/cursor_test.cpp b/modules/platforms/cpp/odbc-test/src/cursor_test.cpp
index 1771657..2be2e23 100644
--- a/modules/platforms/cpp/odbc-test/src/cursor_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/cursor_test.cpp
@@ -76,16 +76,18 @@ void CheckCursorNeedUpdate(Cursor& cursor)
 {
     BOOST_REQUIRE(cursor.NeedDataUpdate());
 
-    BOOST_REQUIRE(cursor.HasNext());
+    BOOST_REQUIRE(cursor.HasData());
 
     BOOST_REQUIRE(!cursor.Increment());
+
+    BOOST_REQUIRE(!cursor.GetRow());
 }
 
 void CheckCursorReady(Cursor& cursor)
 {
     BOOST_REQUIRE(!cursor.NeedDataUpdate());
 
-    BOOST_REQUIRE(cursor.HasNext());
+    BOOST_REQUIRE(cursor.HasData());
 
     BOOST_REQUIRE(cursor.GetRow());
 }
@@ -94,11 +96,11 @@ void CheckCursorEnd(Cursor& cursor)
 {
     BOOST_REQUIRE(!cursor.NeedDataUpdate());
 
-    BOOST_REQUIRE(!cursor.HasNext());
+    BOOST_REQUIRE(!cursor.HasData());
 
     BOOST_REQUIRE(!cursor.Increment());
 
-    BOOST_REQUIRE(cursor.GetRow());
+    BOOST_REQUIRE(!cursor.GetRow());
 }
 
 BOOST_AUTO_TEST_SUITE(CursorTestSuite)

http://git-wip-us.apache.org/repos/asf/ignite/blob/27f438cf/modules/platforms/cpp/odbc/include/ignite/odbc/cursor.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/cursor.h b/modules/platforms/cpp/odbc/include/ignite/odbc/cursor.h
index 7d4c925..fcff839 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/cursor.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/cursor.h
@@ -50,24 +50,28 @@ namespace ignite
 
             /**
              * Move cursor to the next result row.
+             *
              * @return False if data update required or no more data.
              */
             bool Increment();
 
             /**
              * Check if the cursor needs data update.
+             *
              * @return True if the cursor needs data update.
              */
             bool NeedDataUpdate() const;
 
             /**
-             * Check if the cursor has next row row.
-             * @return True if the cursor has next row row.
+             * Check if the cursor has data.
+             *
+             * @return True if the cursor has data.
              */
-            bool HasNext() const;
+            bool HasData() const;
 
             /**
              * Get query ID.
+             *
              * @return Query ID.
              */
             int64_t GetQueryId() const
@@ -77,13 +81,16 @@ namespace ignite
 
             /**
              * Update current cursor page data.
+             *
              * @param newPage New result page.
              */
             void UpdateData(std::auto_ptr<ResultPage>& newPage);
 
             /**
              * Get current row.
-             * @return Current row.
+             *
+             * @return Current row. Returns zero if cursor needs data update or
+             *     has no more data.
              */
             Row* GetRow();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/27f438cf/modules/platforms/cpp/odbc/src/cursor.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/cursor.cpp b/modules/platforms/cpp/odbc/src/cursor.cpp
index edd1818..2648278 100644
--- a/modules/platforms/cpp/odbc/src/cursor.cpp
+++ b/modules/platforms/cpp/odbc/src/cursor.cpp
@@ -38,11 +38,15 @@ namespace ignite
             {
                 ++currentPagePos;
 
-                Row *row = currentRow.get();
-
-                if (row)
-                    row->MoveToNext();
+                if (currentPagePos == currentPage->GetSize())
+                    currentRow.reset();
+                else
+                {
+                    Row *row = currentRow.get();
 
+                    if (row)
+                        row->MoveToNext();
+                }
                 return true;
             }
             return false;
@@ -54,7 +58,7 @@ namespace ignite
                 currentPagePos == currentPage->GetSize());
         }
 
-        bool Cursor::HasNext() const
+        bool Cursor::HasData() const
         {
             return !currentPage.get() || !currentPage->IsLast() ||
                 currentPagePos < currentPage->GetSize();
@@ -64,7 +68,7 @@ namespace ignite
         {
             currentPage = newPage;
 
-            currentPagePos = 1;
+            currentPagePos = 0;
 
             currentRow.reset(new Row(currentPage->GetData()));
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/27f438cf/modules/platforms/cpp/odbc/src/query/data_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/query/data_query.cpp b/modules/platforms/cpp/odbc/src/query/data_query.cpp
index 4e9239b..0702088 100644
--- a/modules/platforms/cpp/odbc/src/query/data_query.cpp
+++ b/modules/platforms/cpp/odbc/src/query/data_query.cpp
@@ -67,7 +67,7 @@ namespace ignite
                     return SQL_RESULT_ERROR;
                 }
 
-                if (!cursor->HasNext())
+                if (!cursor->HasData())
                     return SQL_RESULT_NO_DATA;
 
                 if (cursor->NeedDataUpdate())
@@ -77,7 +77,7 @@ namespace ignite
                     if (result != SQL_RESULT_SUCCESS)
                         return result;
 
-                    if (!cursor->HasNext())
+                    if (!cursor->HasData())
                         return SQL_RESULT_NO_DATA;
                 }
                 else
@@ -157,13 +157,13 @@ namespace ignite
 
             bool DataQuery::DataAvailable() const
             {
-                return cursor.get() && cursor->HasNext();
+                return cursor.get() && cursor->HasData();
             }
 
             int64_t DataQuery::AffectedRows() const
             {
-                // We are only support SELECT statements so we should not
-                // return anything particullar.
+                // We are only support SELECT statements so we can not
+                // affect any row.
                 return 0;
             }
 


Mime
View raw message