Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15401858
D19450.id46521.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D19450.id46521.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -4032,6 +4032,7 @@
'PhabricatorPygmentSetupCheck' => 'applications/config/check/PhabricatorPygmentSetupCheck.php',
'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php',
'PhabricatorQueryConstraint' => 'infrastructure/query/constraint/PhabricatorQueryConstraint.php',
+ 'PhabricatorQueryIterator' => 'infrastructure/storage/lisk/PhabricatorQueryIterator.php',
'PhabricatorQueryOrderItem' => 'infrastructure/query/order/PhabricatorQueryOrderItem.php',
'PhabricatorQueryOrderTestCase' => 'infrastructure/query/order/__tests__/PhabricatorQueryOrderTestCase.php',
'PhabricatorQueryOrderVector' => 'infrastructure/query/order/PhabricatorQueryOrderVector.php',
@@ -9876,6 +9877,7 @@
'PhabricatorPygmentSetupCheck' => 'PhabricatorSetupCheck',
'PhabricatorQuery' => 'Phobject',
'PhabricatorQueryConstraint' => 'Phobject',
+ 'PhabricatorQueryIterator' => 'PhutilBufferedIterator',
'PhabricatorQueryOrderItem' => 'Phobject',
'PhabricatorQueryOrderTestCase' => 'PhabricatorTestCase',
'PhabricatorQueryOrderVector' => array(
diff --git a/src/infrastructure/storage/lisk/PhabricatorQueryIterator.php b/src/infrastructure/storage/lisk/PhabricatorQueryIterator.php
new file mode 100644
--- /dev/null
+++ b/src/infrastructure/storage/lisk/PhabricatorQueryIterator.php
@@ -0,0 +1,41 @@
+<?php
+
+final class PhabricatorQueryIterator extends PhutilBufferedIterator {
+
+ private $query;
+ private $pager;
+
+ public function __construct(PhabricatorCursorPagedPolicyAwareQuery $query) {
+ $this->query = $query;
+ }
+
+ protected function didRewind() {
+ $this->pager = new AphrontCursorPagerView();
+ }
+
+ public function key() {
+ return $this->current()->getID();
+ }
+
+ protected function loadPage() {
+ if (!$this->pager) {
+ return array();
+ }
+
+ $pager = clone $this->pager;
+ $query = clone $this->query;
+
+ $results = $query->executeWithCursorPager($pager);
+
+ // If we got less than a full page of results, this was the last set of
+ // results. Throw away the pager so we end iteration.
+ if (count($results) < $pager->getPageSize()) {
+ $this->pager = null;
+ } else {
+ $this->pager->setAfterID($pager->getNextPageID());
+ }
+
+ return $results;
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 18, 7:31 PM (2 d, 2 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7710297
Default Alt Text
D19450.id46521.diff (2 KB)
Attached To
Mode
D19450: Add PhabricatorQueryIterator, for buffered iteration over a CursorPagedPolicyAwareQuery
Attached
Detach File
Event Timeline
Log In to Comment