Page MenuHomePhabricator

Add PhabricatorQueryIterator, for buffered iteration over a CursorPagedPolicyAwareQuery
ClosedPublic

Authored by epriestley on May 14 2018, 4:23 PM.
Tags
None
Referenced Files
F13293945: D19450.id46521.diff
Wed, Jun 5, 2:55 PM
F13286882: D19450.diff
Tue, Jun 4, 7:49 AM
F13273824: D19450.diff
Fri, May 31, 2:45 AM
F13263831: D19450.id46525.diff
Mon, May 27, 12:34 PM
F13259146: D19450.diff
Sun, May 26, 4:59 PM
F13237841: D19450.id46521.diff
Tue, May 21, 3:23 PM
F13235046: D19450.diff
Tue, May 21, 4:13 AM
F13212397: D19450.diff
Fri, May 17, 6:40 AM
Subscribers
None

Details

Summary

See D19446. This should make it easier to process larger, more complex result sets in constant memory.

Today, LiskMigrationIterator takes constant memory but can't apply needX() reqeusts or withY(...) constraints.

Using a raw Query can handle this stuff, but requires memory proportional to the size of the result set.

Offer the best of both worlds: constant memory and full access to the power of Query classes.

Test Plan

Used this script to iterate over every commit, saw sensible behavior:

list-commits.php
<?php

require_once 'scripts/init/init-script.php';

$viewer = PhabricatorUser::getOmnipotentUser();

$query = id(new DiffusionCommitQuery())
  ->setViewer($viewer);

$iterator = new PhabricatorQueryIterator($query);
foreach ($iterator as $commit) {
  echo $commit->getID()."\n";
}

Diff Detail

Repository
rP Phabricator
Branch
query1
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 20327
Build 27604: Run Core Tests
Build 27603: arc lint + arc unit