mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-03 19:31:02 +01:00
Add LiskRawMigrationIterator
Summary: Ref T2222. I need this to migrate the Differential comment tables, because they are large. We have the similar `LiskMigrationIterator` already, but it won't work here because I intend to destroy the original objects after migrating them. Test Plan: Wrote a script to iterate over the `differential_comment` table, got reasonable output: {P869} Reviewers: btrahan Reviewed By: btrahan CC: chad, aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D6264
This commit is contained in:
parent
6a2ae07791
commit
8e8057c6fe
2 changed files with 41 additions and 0 deletions
|
@ -626,6 +626,7 @@ phutil_register_library_map(array(
|
||||||
'LiskIsolationTestDAO' => 'infrastructure/storage/lisk/__tests__/LiskIsolationTestDAO.php',
|
'LiskIsolationTestDAO' => 'infrastructure/storage/lisk/__tests__/LiskIsolationTestDAO.php',
|
||||||
'LiskIsolationTestDAOException' => 'infrastructure/storage/lisk/__tests__/LiskIsolationTestDAOException.php',
|
'LiskIsolationTestDAOException' => 'infrastructure/storage/lisk/__tests__/LiskIsolationTestDAOException.php',
|
||||||
'LiskMigrationIterator' => 'infrastructure/storage/lisk/LiskMigrationIterator.php',
|
'LiskMigrationIterator' => 'infrastructure/storage/lisk/LiskMigrationIterator.php',
|
||||||
|
'LiskRawMigrationIterator' => 'infrastructure/storage/lisk/LiskRawMigrationIterator.php',
|
||||||
'ManiphestAction' => 'applications/maniphest/constants/ManiphestAction.php',
|
'ManiphestAction' => 'applications/maniphest/constants/ManiphestAction.php',
|
||||||
'ManiphestAuxiliaryFieldDefaultSpecification' => 'applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldDefaultSpecification.php',
|
'ManiphestAuxiliaryFieldDefaultSpecification' => 'applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldDefaultSpecification.php',
|
||||||
'ManiphestAuxiliaryFieldSpecification' => 'applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldSpecification.php',
|
'ManiphestAuxiliaryFieldSpecification' => 'applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldSpecification.php',
|
||||||
|
@ -2476,6 +2477,7 @@ phutil_register_library_map(array(
|
||||||
'LiskIsolationTestDAO' => 'LiskDAO',
|
'LiskIsolationTestDAO' => 'LiskDAO',
|
||||||
'LiskIsolationTestDAOException' => 'Exception',
|
'LiskIsolationTestDAOException' => 'Exception',
|
||||||
'LiskMigrationIterator' => 'PhutilBufferedIterator',
|
'LiskMigrationIterator' => 'PhutilBufferedIterator',
|
||||||
|
'LiskRawMigrationIterator' => 'PhutilBufferedIterator',
|
||||||
'ManiphestAction' => 'ManiphestConstants',
|
'ManiphestAction' => 'ManiphestConstants',
|
||||||
'ManiphestAuxiliaryFieldDefaultSpecification' => 'ManiphestAuxiliaryFieldSpecification',
|
'ManiphestAuxiliaryFieldDefaultSpecification' => 'ManiphestAuxiliaryFieldSpecification',
|
||||||
'ManiphestAuxiliaryFieldSpecification' => 'PhabricatorMarkupInterface',
|
'ManiphestAuxiliaryFieldSpecification' => 'PhabricatorMarkupInterface',
|
||||||
|
|
39
src/infrastructure/storage/lisk/LiskRawMigrationIterator.php
Normal file
39
src/infrastructure/storage/lisk/LiskRawMigrationIterator.php
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class LiskRawMigrationIterator extends PhutilBufferedIterator {
|
||||||
|
|
||||||
|
private $conn;
|
||||||
|
private $table;
|
||||||
|
private $cursor;
|
||||||
|
private $column = 'id';
|
||||||
|
|
||||||
|
public function __construct(AphrontDatabaseConnection $conn, $table) {
|
||||||
|
$this->conn = $conn;
|
||||||
|
$this->table = $table;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function didRewind() {
|
||||||
|
$this->cursor = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function key() {
|
||||||
|
return idx($this->current(), $this->column);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function loadPage() {
|
||||||
|
$page = queryfx_all(
|
||||||
|
$this->conn,
|
||||||
|
'SELECT * FROM %T WHERE %C > %d ORDER BY ID ASC LIMIT %d',
|
||||||
|
$this->table,
|
||||||
|
$this->column,
|
||||||
|
$this->cursor,
|
||||||
|
$this->getPageSize());
|
||||||
|
|
||||||
|
if ($page) {
|
||||||
|
$this->cursor = idx(last($page), $this->column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $page;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue