IGNITE-9171: SQL: redesigned lazy mode. This closes #5473. master
authortledkov-gridgain <tledkov@gridgain.com>
Sun, 17 Feb 2019 15:50:10 +0000 (18:50 +0300)
committerdevozerov <ppozerov@gmail.com>
Sun, 17 Feb 2019 15:50:10 +0000 (18:50 +0300)
tests/SqlFieldsQueryTest.php

index 3e74ca04f49f45ca7da23f9d6242a7e686549969..802f738f3ac3f5b9f8f497f0d3535f10e6557839 100644 (file)
@@ -64,10 +64,22 @@ final class SqlFieldsQueryTestCase extends TestCase
         $this->assertEquals($set->count(), self::ELEMENTS_NUMBER);
     }
 
-    public function testGetAllWithPageSize(): void
+    public function testGetAllWithPageSizeLazyTrue(): void
     {
         $cache = self::$cache;
-        $cursor = $cache->query((new SqlFieldsQuery(self::$selectFromTable))->setPageSize(1));
+        $cursor = $cache->query((new SqlFieldsQuery(self::$selectFromTable))->setPageSize(1)->setLazy(true));
+        $set = new Set();
+        foreach ($cursor->getAll() as $fields) {
+            $this->checkCursorResult($fields);
+            $set->add($fields[0]);
+        }
+        $this->assertEquals($set->count(), self::ELEMENTS_NUMBER);
+    }
+
+    public function testGetAllWithPageSizeLazyFalse(): void
+    {
+        $cache = self::$cache;
+        $cursor = $cache->query((new SqlFieldsQuery(self::$selectFromTable))->setPageSize(1)->setLazy(false));
         $set = new Set();
         foreach ($cursor->getAll() as $fields) {
             $this->checkCursorResult($fields);
@@ -88,10 +100,22 @@ final class SqlFieldsQueryTestCase extends TestCase
         $this->assertEquals($set->count(), self::ELEMENTS_NUMBER);
     }
 
-    public function testIterateCursorWithPageSize(): void
+    public function testIterateCursorWithPageSizeLazyTrue(): void
+    {
+        $cache = self::$cache;
+        $cursor = $cache->query((new SqlFieldsQuery(self::$selectFromTable))->setPageSize(2)->setLazy(true));
+        $set = new Set();
+        foreach ($cursor as $fields) {
+            $this->checkCursorResult($fields);
+            $set->add($fields[0]);
+        }
+        $this->assertEquals($set->count(), self::ELEMENTS_NUMBER);
+    }
+
+    public function testIterateCursorWithPageSizeLazyFalse(): void
     {
         $cache = self::$cache;
-        $cursor = $cache->query((new SqlFieldsQuery(self::$selectFromTable))->setPageSize(2));
+        $cursor = $cache->query((new SqlFieldsQuery(self::$selectFromTable))->setPageSize(2)->setLazy(false));
         $set = new Set();
         foreach ($cursor as $fields) {
             $this->checkCursorResult($fields);