mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 05:50:55 +01:00
Reduce the amount of boilerplate that implementing FerretInterface requires
Summary: See brief discussion in D18554. All the index tables are the same for every application (and, at this point, seem unlikely to change) and we never actually pass these objects around (they're only used internally). In some other cases (like Transactions) not every application has the same tables (for example, Differential has extra field for inline comments), and/or we pass the objects around (lots of stuff uses `$xactions` directly). However, in this case, and in Edges, we don't interact with any representation of the database state directly in much of the code, and it doesn't change from application to application. Just automatically define document, field, and ngram tables for anything which implements `FerretInterface`. This makes the query and index logic a tiny bit messier but lets us delete a ton of boilerplate classes. Test Plan: Indexed objects, searched for objects. Same results as before with much less code. Ran `bin/storage upgrade`, got a clean bill of health. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12819 Differential Revision: https://secure.phabricator.com/D18559
This commit is contained in:
parent
2020c1e7bd
commit
2218caee0f
29 changed files with 207 additions and 455 deletions
|
@ -532,10 +532,7 @@ phutil_register_library_map(array(
|
||||||
'DifferentialRevisionEditConduitAPIMethod' => 'applications/differential/conduit/DifferentialRevisionEditConduitAPIMethod.php',
|
'DifferentialRevisionEditConduitAPIMethod' => 'applications/differential/conduit/DifferentialRevisionEditConduitAPIMethod.php',
|
||||||
'DifferentialRevisionEditController' => 'applications/differential/controller/DifferentialRevisionEditController.php',
|
'DifferentialRevisionEditController' => 'applications/differential/controller/DifferentialRevisionEditController.php',
|
||||||
'DifferentialRevisionEditEngine' => 'applications/differential/editor/DifferentialRevisionEditEngine.php',
|
'DifferentialRevisionEditEngine' => 'applications/differential/editor/DifferentialRevisionEditEngine.php',
|
||||||
'DifferentialRevisionFerretDocument' => 'applications/differential/storage/DifferentialRevisionFerretDocument.php',
|
|
||||||
'DifferentialRevisionFerretEngine' => 'applications/differential/search/DifferentialRevisionFerretEngine.php',
|
'DifferentialRevisionFerretEngine' => 'applications/differential/search/DifferentialRevisionFerretEngine.php',
|
||||||
'DifferentialRevisionFerretField' => 'applications/differential/storage/DifferentialRevisionFerretField.php',
|
|
||||||
'DifferentialRevisionFerretNgrams' => 'applications/differential/storage/DifferentialRevisionFerretNgrams.php',
|
|
||||||
'DifferentialRevisionFulltextEngine' => 'applications/differential/search/DifferentialRevisionFulltextEngine.php',
|
'DifferentialRevisionFulltextEngine' => 'applications/differential/search/DifferentialRevisionFulltextEngine.php',
|
||||||
'DifferentialRevisionGraph' => 'infrastructure/graph/DifferentialRevisionGraph.php',
|
'DifferentialRevisionGraph' => 'infrastructure/graph/DifferentialRevisionGraph.php',
|
||||||
'DifferentialRevisionHasChildRelationship' => 'applications/differential/relationships/DifferentialRevisionHasChildRelationship.php',
|
'DifferentialRevisionHasChildRelationship' => 'applications/differential/relationships/DifferentialRevisionHasChildRelationship.php',
|
||||||
|
@ -1153,10 +1150,7 @@ phutil_register_library_map(array(
|
||||||
'FundInitiativeEditController' => 'applications/fund/controller/FundInitiativeEditController.php',
|
'FundInitiativeEditController' => 'applications/fund/controller/FundInitiativeEditController.php',
|
||||||
'FundInitiativeEditEngine' => 'applications/fund/editor/FundInitiativeEditEngine.php',
|
'FundInitiativeEditEngine' => 'applications/fund/editor/FundInitiativeEditEngine.php',
|
||||||
'FundInitiativeEditor' => 'applications/fund/editor/FundInitiativeEditor.php',
|
'FundInitiativeEditor' => 'applications/fund/editor/FundInitiativeEditor.php',
|
||||||
'FundInitiativeFerretDocument' => 'applications/fund/storage/FundInitiativeFerretDocument.php',
|
|
||||||
'FundInitiativeFerretEngine' => 'applications/fund/search/FundInitiativeFerretEngine.php',
|
'FundInitiativeFerretEngine' => 'applications/fund/search/FundInitiativeFerretEngine.php',
|
||||||
'FundInitiativeFerretField' => 'applications/fund/storage/FundInitiativeFerretField.php',
|
|
||||||
'FundInitiativeFerretNgrams' => 'applications/fund/storage/FundInitiativeFerretNgrams.php',
|
|
||||||
'FundInitiativeFulltextEngine' => 'applications/fund/search/FundInitiativeFulltextEngine.php',
|
'FundInitiativeFulltextEngine' => 'applications/fund/search/FundInitiativeFulltextEngine.php',
|
||||||
'FundInitiativeListController' => 'applications/fund/controller/FundInitiativeListController.php',
|
'FundInitiativeListController' => 'applications/fund/controller/FundInitiativeListController.php',
|
||||||
'FundInitiativeMerchantTransaction' => 'applications/fund/xaction/FundInitiativeMerchantTransaction.php',
|
'FundInitiativeMerchantTransaction' => 'applications/fund/xaction/FundInitiativeMerchantTransaction.php',
|
||||||
|
@ -1539,10 +1533,7 @@ phutil_register_library_map(array(
|
||||||
'ManiphestTaskEditBulkJobType' => 'applications/maniphest/bulk/ManiphestTaskEditBulkJobType.php',
|
'ManiphestTaskEditBulkJobType' => 'applications/maniphest/bulk/ManiphestTaskEditBulkJobType.php',
|
||||||
'ManiphestTaskEditController' => 'applications/maniphest/controller/ManiphestTaskEditController.php',
|
'ManiphestTaskEditController' => 'applications/maniphest/controller/ManiphestTaskEditController.php',
|
||||||
'ManiphestTaskEditEngineLock' => 'applications/maniphest/editor/ManiphestTaskEditEngineLock.php',
|
'ManiphestTaskEditEngineLock' => 'applications/maniphest/editor/ManiphestTaskEditEngineLock.php',
|
||||||
'ManiphestTaskFerretDocument' => 'applications/maniphest/storage/ManiphestTaskFerretDocument.php',
|
|
||||||
'ManiphestTaskFerretEngine' => 'applications/maniphest/search/ManiphestTaskFerretEngine.php',
|
'ManiphestTaskFerretEngine' => 'applications/maniphest/search/ManiphestTaskFerretEngine.php',
|
||||||
'ManiphestTaskFerretField' => 'applications/maniphest/storage/ManiphestTaskFerretField.php',
|
|
||||||
'ManiphestTaskFerretNgrams' => 'applications/maniphest/storage/ManiphestTaskFerretNgrams.php',
|
|
||||||
'ManiphestTaskFulltextEngine' => 'applications/maniphest/search/ManiphestTaskFulltextEngine.php',
|
'ManiphestTaskFulltextEngine' => 'applications/maniphest/search/ManiphestTaskFulltextEngine.php',
|
||||||
'ManiphestTaskGraph' => 'infrastructure/graph/ManiphestTaskGraph.php',
|
'ManiphestTaskGraph' => 'infrastructure/graph/ManiphestTaskGraph.php',
|
||||||
'ManiphestTaskHasCommitEdgeType' => 'applications/maniphest/edge/ManiphestTaskHasCommitEdgeType.php',
|
'ManiphestTaskHasCommitEdgeType' => 'applications/maniphest/edge/ManiphestTaskHasCommitEdgeType.php',
|
||||||
|
@ -1840,10 +1831,7 @@ phutil_register_library_map(array(
|
||||||
'PassphraseCredentialDestroyController' => 'applications/passphrase/controller/PassphraseCredentialDestroyController.php',
|
'PassphraseCredentialDestroyController' => 'applications/passphrase/controller/PassphraseCredentialDestroyController.php',
|
||||||
'PassphraseCredentialDestroyTransaction' => 'applications/passphrase/xaction/PassphraseCredentialDestroyTransaction.php',
|
'PassphraseCredentialDestroyTransaction' => 'applications/passphrase/xaction/PassphraseCredentialDestroyTransaction.php',
|
||||||
'PassphraseCredentialEditController' => 'applications/passphrase/controller/PassphraseCredentialEditController.php',
|
'PassphraseCredentialEditController' => 'applications/passphrase/controller/PassphraseCredentialEditController.php',
|
||||||
'PassphraseCredentialFerretDocument' => 'applications/passphrase/storage/PassphraseCredentialFerretDocument.php',
|
|
||||||
'PassphraseCredentialFerretEngine' => 'applications/passphrase/search/PassphraseCredentialFerretEngine.php',
|
'PassphraseCredentialFerretEngine' => 'applications/passphrase/search/PassphraseCredentialFerretEngine.php',
|
||||||
'PassphraseCredentialFerretField' => 'applications/passphrase/storage/PassphraseCredentialFerretField.php',
|
|
||||||
'PassphraseCredentialFerretNgrams' => 'applications/passphrase/storage/PassphraseCredentialFerretNgrams.php',
|
|
||||||
'PassphraseCredentialFulltextEngine' => 'applications/passphrase/search/PassphraseCredentialFulltextEngine.php',
|
'PassphraseCredentialFulltextEngine' => 'applications/passphrase/search/PassphraseCredentialFulltextEngine.php',
|
||||||
'PassphraseCredentialListController' => 'applications/passphrase/controller/PassphraseCredentialListController.php',
|
'PassphraseCredentialListController' => 'applications/passphrase/controller/PassphraseCredentialListController.php',
|
||||||
'PassphraseCredentialLockController' => 'applications/passphrase/controller/PassphraseCredentialLockController.php',
|
'PassphraseCredentialLockController' => 'applications/passphrase/controller/PassphraseCredentialLockController.php',
|
||||||
|
@ -2841,15 +2829,12 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorFeedStoryNotification' => 'applications/notification/storage/PhabricatorFeedStoryNotification.php',
|
'PhabricatorFeedStoryNotification' => 'applications/notification/storage/PhabricatorFeedStoryNotification.php',
|
||||||
'PhabricatorFeedStoryPublisher' => 'applications/feed/PhabricatorFeedStoryPublisher.php',
|
'PhabricatorFeedStoryPublisher' => 'applications/feed/PhabricatorFeedStoryPublisher.php',
|
||||||
'PhabricatorFeedStoryReference' => 'applications/feed/storage/PhabricatorFeedStoryReference.php',
|
'PhabricatorFeedStoryReference' => 'applications/feed/storage/PhabricatorFeedStoryReference.php',
|
||||||
'PhabricatorFerretDocument' => 'applications/search/ferret/PhabricatorFerretDocument.php',
|
|
||||||
'PhabricatorFerretEngine' => 'applications/search/ferret/PhabricatorFerretEngine.php',
|
'PhabricatorFerretEngine' => 'applications/search/ferret/PhabricatorFerretEngine.php',
|
||||||
'PhabricatorFerretEngineTestCase' => 'applications/search/ferret/__tests__/PhabricatorFerretEngineTestCase.php',
|
'PhabricatorFerretEngineTestCase' => 'applications/search/ferret/__tests__/PhabricatorFerretEngineTestCase.php',
|
||||||
'PhabricatorFerretField' => 'applications/search/ferret/PhabricatorFerretField.php',
|
|
||||||
'PhabricatorFerretFulltextEngineExtension' => 'applications/search/engineextension/PhabricatorFerretFulltextEngineExtension.php',
|
'PhabricatorFerretFulltextEngineExtension' => 'applications/search/engineextension/PhabricatorFerretFulltextEngineExtension.php',
|
||||||
'PhabricatorFerretFulltextStorageEngine' => 'applications/search/fulltextstorage/PhabricatorFerretFulltextStorageEngine.php',
|
'PhabricatorFerretFulltextStorageEngine' => 'applications/search/fulltextstorage/PhabricatorFerretFulltextStorageEngine.php',
|
||||||
'PhabricatorFerretInterface' => 'applications/search/ferret/PhabricatorFerretInterface.php',
|
'PhabricatorFerretInterface' => 'applications/search/ferret/PhabricatorFerretInterface.php',
|
||||||
'PhabricatorFerretMetadata' => 'applications/search/ferret/PhabricatorFerretMetadata.php',
|
'PhabricatorFerretMetadata' => 'applications/search/ferret/PhabricatorFerretMetadata.php',
|
||||||
'PhabricatorFerretNgrams' => 'applications/search/ferret/PhabricatorFerretNgrams.php',
|
|
||||||
'PhabricatorFerretSearchEngineExtension' => 'applications/search/engineextension/PhabricatorFerretSearchEngineExtension.php',
|
'PhabricatorFerretSearchEngineExtension' => 'applications/search/engineextension/PhabricatorFerretSearchEngineExtension.php',
|
||||||
'PhabricatorFile' => 'applications/files/storage/PhabricatorFile.php',
|
'PhabricatorFile' => 'applications/files/storage/PhabricatorFile.php',
|
||||||
'PhabricatorFileAES256StorageFormat' => 'applications/files/format/PhabricatorFileAES256StorageFormat.php',
|
'PhabricatorFileAES256StorageFormat' => 'applications/files/format/PhabricatorFileAES256StorageFormat.php',
|
||||||
|
@ -4265,10 +4250,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorUserEditorTestCase' => 'applications/people/editor/__tests__/PhabricatorUserEditorTestCase.php',
|
'PhabricatorUserEditorTestCase' => 'applications/people/editor/__tests__/PhabricatorUserEditorTestCase.php',
|
||||||
'PhabricatorUserEmail' => 'applications/people/storage/PhabricatorUserEmail.php',
|
'PhabricatorUserEmail' => 'applications/people/storage/PhabricatorUserEmail.php',
|
||||||
'PhabricatorUserEmailTestCase' => 'applications/people/storage/__tests__/PhabricatorUserEmailTestCase.php',
|
'PhabricatorUserEmailTestCase' => 'applications/people/storage/__tests__/PhabricatorUserEmailTestCase.php',
|
||||||
'PhabricatorUserFerretDocument' => 'applications/people/storage/PhabricatorUserFerretDocument.php',
|
|
||||||
'PhabricatorUserFerretEngine' => 'applications/people/search/PhabricatorUserFerretEngine.php',
|
'PhabricatorUserFerretEngine' => 'applications/people/search/PhabricatorUserFerretEngine.php',
|
||||||
'PhabricatorUserFerretField' => 'applications/people/storage/PhabricatorUserFerretField.php',
|
|
||||||
'PhabricatorUserFerretNgrams' => 'applications/people/storage/PhabricatorUserFerretNgrams.php',
|
|
||||||
'PhabricatorUserFulltextEngine' => 'applications/people/search/PhabricatorUserFulltextEngine.php',
|
'PhabricatorUserFulltextEngine' => 'applications/people/search/PhabricatorUserFulltextEngine.php',
|
||||||
'PhabricatorUserIconField' => 'applications/people/customfield/PhabricatorUserIconField.php',
|
'PhabricatorUserIconField' => 'applications/people/customfield/PhabricatorUserIconField.php',
|
||||||
'PhabricatorUserLog' => 'applications/people/storage/PhabricatorUserLog.php',
|
'PhabricatorUserLog' => 'applications/people/storage/PhabricatorUserLog.php',
|
||||||
|
@ -5564,10 +5546,7 @@ phutil_register_library_map(array(
|
||||||
'DifferentialRevisionEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
|
'DifferentialRevisionEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
|
||||||
'DifferentialRevisionEditController' => 'DifferentialController',
|
'DifferentialRevisionEditController' => 'DifferentialController',
|
||||||
'DifferentialRevisionEditEngine' => 'PhabricatorEditEngine',
|
'DifferentialRevisionEditEngine' => 'PhabricatorEditEngine',
|
||||||
'DifferentialRevisionFerretDocument' => 'PhabricatorFerretDocument',
|
|
||||||
'DifferentialRevisionFerretEngine' => 'PhabricatorFerretEngine',
|
'DifferentialRevisionFerretEngine' => 'PhabricatorFerretEngine',
|
||||||
'DifferentialRevisionFerretField' => 'PhabricatorFerretField',
|
|
||||||
'DifferentialRevisionFerretNgrams' => 'PhabricatorFerretNgrams',
|
|
||||||
'DifferentialRevisionFulltextEngine' => 'PhabricatorFulltextEngine',
|
'DifferentialRevisionFulltextEngine' => 'PhabricatorFulltextEngine',
|
||||||
'DifferentialRevisionGraph' => 'PhabricatorObjectGraph',
|
'DifferentialRevisionGraph' => 'PhabricatorObjectGraph',
|
||||||
'DifferentialRevisionHasChildRelationship' => 'DifferentialRevisionRelationship',
|
'DifferentialRevisionHasChildRelationship' => 'DifferentialRevisionRelationship',
|
||||||
|
@ -6248,10 +6227,7 @@ phutil_register_library_map(array(
|
||||||
'FundInitiativeEditController' => 'FundController',
|
'FundInitiativeEditController' => 'FundController',
|
||||||
'FundInitiativeEditEngine' => 'PhabricatorEditEngine',
|
'FundInitiativeEditEngine' => 'PhabricatorEditEngine',
|
||||||
'FundInitiativeEditor' => 'PhabricatorApplicationTransactionEditor',
|
'FundInitiativeEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
'FundInitiativeFerretDocument' => 'PhabricatorFerretDocument',
|
|
||||||
'FundInitiativeFerretEngine' => 'PhabricatorFerretEngine',
|
'FundInitiativeFerretEngine' => 'PhabricatorFerretEngine',
|
||||||
'FundInitiativeFerretField' => 'PhabricatorFerretField',
|
|
||||||
'FundInitiativeFerretNgrams' => 'PhabricatorFerretNgrams',
|
|
||||||
'FundInitiativeFulltextEngine' => 'PhabricatorFulltextEngine',
|
'FundInitiativeFulltextEngine' => 'PhabricatorFulltextEngine',
|
||||||
'FundInitiativeListController' => 'FundController',
|
'FundInitiativeListController' => 'FundController',
|
||||||
'FundInitiativeMerchantTransaction' => 'FundInitiativeTransactionType',
|
'FundInitiativeMerchantTransaction' => 'FundInitiativeTransactionType',
|
||||||
|
@ -6719,10 +6695,7 @@ phutil_register_library_map(array(
|
||||||
'ManiphestTaskEditBulkJobType' => 'PhabricatorWorkerBulkJobType',
|
'ManiphestTaskEditBulkJobType' => 'PhabricatorWorkerBulkJobType',
|
||||||
'ManiphestTaskEditController' => 'ManiphestController',
|
'ManiphestTaskEditController' => 'ManiphestController',
|
||||||
'ManiphestTaskEditEngineLock' => 'PhabricatorEditEngineLock',
|
'ManiphestTaskEditEngineLock' => 'PhabricatorEditEngineLock',
|
||||||
'ManiphestTaskFerretDocument' => 'PhabricatorFerretDocument',
|
|
||||||
'ManiphestTaskFerretEngine' => 'PhabricatorFerretEngine',
|
'ManiphestTaskFerretEngine' => 'PhabricatorFerretEngine',
|
||||||
'ManiphestTaskFerretField' => 'PhabricatorFerretField',
|
|
||||||
'ManiphestTaskFerretNgrams' => 'PhabricatorFerretNgrams',
|
|
||||||
'ManiphestTaskFulltextEngine' => 'PhabricatorFulltextEngine',
|
'ManiphestTaskFulltextEngine' => 'PhabricatorFulltextEngine',
|
||||||
'ManiphestTaskGraph' => 'PhabricatorObjectGraph',
|
'ManiphestTaskGraph' => 'PhabricatorObjectGraph',
|
||||||
'ManiphestTaskHasCommitEdgeType' => 'PhabricatorEdgeType',
|
'ManiphestTaskHasCommitEdgeType' => 'PhabricatorEdgeType',
|
||||||
|
@ -7049,10 +7022,7 @@ phutil_register_library_map(array(
|
||||||
'PassphraseCredentialDestroyController' => 'PassphraseController',
|
'PassphraseCredentialDestroyController' => 'PassphraseController',
|
||||||
'PassphraseCredentialDestroyTransaction' => 'PassphraseCredentialTransactionType',
|
'PassphraseCredentialDestroyTransaction' => 'PassphraseCredentialTransactionType',
|
||||||
'PassphraseCredentialEditController' => 'PassphraseController',
|
'PassphraseCredentialEditController' => 'PassphraseController',
|
||||||
'PassphraseCredentialFerretDocument' => 'PhabricatorFerretDocument',
|
|
||||||
'PassphraseCredentialFerretEngine' => 'PhabricatorFerretEngine',
|
'PassphraseCredentialFerretEngine' => 'PhabricatorFerretEngine',
|
||||||
'PassphraseCredentialFerretField' => 'PhabricatorFerretField',
|
|
||||||
'PassphraseCredentialFerretNgrams' => 'PhabricatorFerretNgrams',
|
|
||||||
'PassphraseCredentialFulltextEngine' => 'PhabricatorFulltextEngine',
|
'PassphraseCredentialFulltextEngine' => 'PhabricatorFulltextEngine',
|
||||||
'PassphraseCredentialListController' => 'PassphraseController',
|
'PassphraseCredentialListController' => 'PassphraseController',
|
||||||
'PassphraseCredentialLockController' => 'PassphraseController',
|
'PassphraseCredentialLockController' => 'PassphraseController',
|
||||||
|
@ -8192,14 +8162,11 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorFeedStoryNotification' => 'PhabricatorFeedDAO',
|
'PhabricatorFeedStoryNotification' => 'PhabricatorFeedDAO',
|
||||||
'PhabricatorFeedStoryPublisher' => 'Phobject',
|
'PhabricatorFeedStoryPublisher' => 'Phobject',
|
||||||
'PhabricatorFeedStoryReference' => 'PhabricatorFeedDAO',
|
'PhabricatorFeedStoryReference' => 'PhabricatorFeedDAO',
|
||||||
'PhabricatorFerretDocument' => 'PhabricatorSearchDAO',
|
|
||||||
'PhabricatorFerretEngine' => 'Phobject',
|
'PhabricatorFerretEngine' => 'Phobject',
|
||||||
'PhabricatorFerretEngineTestCase' => 'PhabricatorTestCase',
|
'PhabricatorFerretEngineTestCase' => 'PhabricatorTestCase',
|
||||||
'PhabricatorFerretField' => 'PhabricatorSearchDAO',
|
|
||||||
'PhabricatorFerretFulltextEngineExtension' => 'PhabricatorFulltextEngineExtension',
|
'PhabricatorFerretFulltextEngineExtension' => 'PhabricatorFulltextEngineExtension',
|
||||||
'PhabricatorFerretFulltextStorageEngine' => 'PhabricatorFulltextStorageEngine',
|
'PhabricatorFerretFulltextStorageEngine' => 'PhabricatorFulltextStorageEngine',
|
||||||
'PhabricatorFerretMetadata' => 'Phobject',
|
'PhabricatorFerretMetadata' => 'Phobject',
|
||||||
'PhabricatorFerretNgrams' => 'PhabricatorSearchDAO',
|
|
||||||
'PhabricatorFerretSearchEngineExtension' => 'PhabricatorSearchEngineExtension',
|
'PhabricatorFerretSearchEngineExtension' => 'PhabricatorSearchEngineExtension',
|
||||||
'PhabricatorFile' => array(
|
'PhabricatorFile' => array(
|
||||||
'PhabricatorFileDAO',
|
'PhabricatorFileDAO',
|
||||||
|
@ -9885,10 +9852,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorUserEditorTestCase' => 'PhabricatorTestCase',
|
'PhabricatorUserEditorTestCase' => 'PhabricatorTestCase',
|
||||||
'PhabricatorUserEmail' => 'PhabricatorUserDAO',
|
'PhabricatorUserEmail' => 'PhabricatorUserDAO',
|
||||||
'PhabricatorUserEmailTestCase' => 'PhabricatorTestCase',
|
'PhabricatorUserEmailTestCase' => 'PhabricatorTestCase',
|
||||||
'PhabricatorUserFerretDocument' => 'PhabricatorFerretDocument',
|
|
||||||
'PhabricatorUserFerretEngine' => 'PhabricatorFerretEngine',
|
'PhabricatorUserFerretEngine' => 'PhabricatorFerretEngine',
|
||||||
'PhabricatorUserFerretField' => 'PhabricatorFerretField',
|
|
||||||
'PhabricatorUserFerretNgrams' => 'PhabricatorFerretNgrams',
|
|
||||||
'PhabricatorUserFulltextEngine' => 'PhabricatorFulltextEngine',
|
'PhabricatorUserFulltextEngine' => 'PhabricatorFulltextEngine',
|
||||||
'PhabricatorUserIconField' => 'PhabricatorUserCustomField',
|
'PhabricatorUserIconField' => 'PhabricatorUserCustomField',
|
||||||
'PhabricatorUserLog' => array(
|
'PhabricatorUserLog' => array(
|
||||||
|
|
|
@ -42,5 +42,13 @@ final class PhabricatorConfigCoreSchemaSpec
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ferret_objects = id(new PhutilClassMapQuery())
|
||||||
|
->setAncestorClass('PhabricatorFerretInterface')
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
foreach ($ferret_objects as $ferret_object) {
|
||||||
|
$engine = $ferret_object->newFerretEngine();
|
||||||
|
$this->buildFerretIndexSchema($engine);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,26 @@ abstract class PhabricatorConfigSchemaSpec extends Phobject {
|
||||||
$object->getSchemaKeys());
|
$object->getSchemaKeys());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function buildFerretIndexSchema(PhabricatorFerretEngine $engine) {
|
||||||
|
$this->buildRawSchema(
|
||||||
|
$engine->getApplicationName(),
|
||||||
|
$engine->getDocumentTableName(),
|
||||||
|
$engine->getDocumentSchemaColumns(),
|
||||||
|
$engine->getDocumentSchemaKeys());
|
||||||
|
|
||||||
|
$this->buildRawSchema(
|
||||||
|
$engine->getApplicationName(),
|
||||||
|
$engine->getFieldTableName(),
|
||||||
|
$engine->getFieldSchemaColumns(),
|
||||||
|
$engine->getFieldSchemaKeys());
|
||||||
|
|
||||||
|
$this->buildRawSchema(
|
||||||
|
$engine->getApplicationName(),
|
||||||
|
$engine->getNgramsTableName(),
|
||||||
|
$engine->getNgramsSchemaColumns(),
|
||||||
|
$engine->getNgramsSchemaKeys());
|
||||||
|
}
|
||||||
|
|
||||||
protected function buildRawSchema(
|
protected function buildRawSchema(
|
||||||
$database_name,
|
$database_name,
|
||||||
$table_name,
|
$table_name,
|
||||||
|
|
|
@ -3,16 +3,12 @@
|
||||||
final class DifferentialRevisionFerretEngine
|
final class DifferentialRevisionFerretEngine
|
||||||
extends PhabricatorFerretEngine {
|
extends PhabricatorFerretEngine {
|
||||||
|
|
||||||
public function newNgramsObject() {
|
public function getApplicationName() {
|
||||||
return new DifferentialRevisionFerretNgrams();
|
return 'differential';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newDocumentObject() {
|
public function getScopeName() {
|
||||||
return new DifferentialRevisionFerretDocument();
|
return 'revision';
|
||||||
}
|
|
||||||
|
|
||||||
public function newFieldObject() {
|
|
||||||
return new DifferentialRevisionFerretField();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newSearchEngine() {
|
public function newSearchEngine() {
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class DifferentialRevisionFerretDocument
|
|
||||||
extends PhabricatorFerretDocument {
|
|
||||||
|
|
||||||
public function getApplicationName() {
|
|
||||||
return 'differential';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIndexKey() {
|
|
||||||
return 'revision';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class DifferentialRevisionFerretField
|
|
||||||
extends PhabricatorFerretField {
|
|
||||||
|
|
||||||
public function getApplicationName() {
|
|
||||||
return 'differential';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIndexKey() {
|
|
||||||
return 'revision';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class DifferentialRevisionFerretNgrams
|
|
||||||
extends PhabricatorFerretNgrams {
|
|
||||||
|
|
||||||
public function getApplicationName() {
|
|
||||||
return 'differential';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIndexKey() {
|
|
||||||
return 'revision';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -3,16 +3,12 @@
|
||||||
final class FundInitiativeFerretEngine
|
final class FundInitiativeFerretEngine
|
||||||
extends PhabricatorFerretEngine {
|
extends PhabricatorFerretEngine {
|
||||||
|
|
||||||
public function newNgramsObject() {
|
public function getApplicationName() {
|
||||||
return new FundInitiativeFerretNgrams();
|
return 'fund';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newDocumentObject() {
|
public function getScopeName() {
|
||||||
return new FundInitiativeFerretDocument();
|
return 'initiative';
|
||||||
}
|
|
||||||
|
|
||||||
public function newFieldObject() {
|
|
||||||
return new FundInitiativeFerretField();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newSearchEngine() {
|
public function newSearchEngine() {
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class FundInitiativeFerretDocument
|
|
||||||
extends PhabricatorFerretDocument {
|
|
||||||
|
|
||||||
public function getApplicationName() {
|
|
||||||
return 'fund';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIndexKey() {
|
|
||||||
return 'initiative';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class FundInitiativeFerretField
|
|
||||||
extends PhabricatorFerretField {
|
|
||||||
|
|
||||||
public function getApplicationName() {
|
|
||||||
return 'fund';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIndexKey() {
|
|
||||||
return 'initiative';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class FundInitiativeFerretNgrams
|
|
||||||
extends PhabricatorFerretNgrams {
|
|
||||||
|
|
||||||
public function getApplicationName() {
|
|
||||||
return 'fund';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIndexKey() {
|
|
||||||
return 'initiative';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -3,16 +3,12 @@
|
||||||
final class ManiphestTaskFerretEngine
|
final class ManiphestTaskFerretEngine
|
||||||
extends PhabricatorFerretEngine {
|
extends PhabricatorFerretEngine {
|
||||||
|
|
||||||
public function newNgramsObject() {
|
public function getApplicationName() {
|
||||||
return new ManiphestTaskFerretNgrams();
|
return 'maniphest';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newDocumentObject() {
|
public function getScopeName() {
|
||||||
return new ManiphestTaskFerretDocument();
|
return 'task';
|
||||||
}
|
|
||||||
|
|
||||||
public function newFieldObject() {
|
|
||||||
return new ManiphestTaskFerretField();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newSearchEngine() {
|
public function newSearchEngine() {
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class ManiphestTaskFerretDocument
|
|
||||||
extends PhabricatorFerretDocument {
|
|
||||||
|
|
||||||
public function getApplicationName() {
|
|
||||||
return 'maniphest';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIndexKey() {
|
|
||||||
return 'task';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class ManiphestTaskFerretField
|
|
||||||
extends PhabricatorFerretField {
|
|
||||||
|
|
||||||
public function getApplicationName() {
|
|
||||||
return 'maniphest';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIndexKey() {
|
|
||||||
return 'task';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class ManiphestTaskFerretNgrams
|
|
||||||
extends PhabricatorFerretNgrams {
|
|
||||||
|
|
||||||
public function getApplicationName() {
|
|
||||||
return 'maniphest';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIndexKey() {
|
|
||||||
return 'task';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -3,16 +3,12 @@
|
||||||
final class PassphraseCredentialFerretEngine
|
final class PassphraseCredentialFerretEngine
|
||||||
extends PhabricatorFerretEngine {
|
extends PhabricatorFerretEngine {
|
||||||
|
|
||||||
public function newNgramsObject() {
|
public function getApplicationName() {
|
||||||
return new PassphraseCredentialFerretNgrams();
|
return 'passphrase';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newDocumentObject() {
|
public function getScopeName() {
|
||||||
return new PassphraseCredentialFerretDocument();
|
return 'credential';
|
||||||
}
|
|
||||||
|
|
||||||
public function newFieldObject() {
|
|
||||||
return new PassphraseCredentialFerretField();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newSearchEngine() {
|
public function newSearchEngine() {
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class PassphraseCredentialFerretDocument
|
|
||||||
extends PhabricatorFerretDocument {
|
|
||||||
|
|
||||||
public function getApplicationName() {
|
|
||||||
return 'passphrase';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIndexKey() {
|
|
||||||
return 'credential';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class PassphraseCredentialFerretField
|
|
||||||
extends PhabricatorFerretField {
|
|
||||||
|
|
||||||
public function getApplicationName() {
|
|
||||||
return 'passphrase';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIndexKey() {
|
|
||||||
return 'credential';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class PassphraseCredentialFerretNgrams
|
|
||||||
extends PhabricatorFerretNgrams {
|
|
||||||
|
|
||||||
public function getApplicationName() {
|
|
||||||
return 'passphrase';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIndexKey() {
|
|
||||||
return 'credential';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -3,16 +3,12 @@
|
||||||
final class PhabricatorUserFerretEngine
|
final class PhabricatorUserFerretEngine
|
||||||
extends PhabricatorFerretEngine {
|
extends PhabricatorFerretEngine {
|
||||||
|
|
||||||
public function newNgramsObject() {
|
public function getApplicationName() {
|
||||||
return new PhabricatorUserFerretNgrams();
|
return 'user';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newDocumentObject() {
|
public function getScopeName() {
|
||||||
return new PhabricatorUserFerretDocument();
|
return 'user';
|
||||||
}
|
|
||||||
|
|
||||||
public function newFieldObject() {
|
|
||||||
return new PhabricatorUserFerretField();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newSearchEngine() {
|
public function newSearchEngine() {
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class PhabricatorUserFerretDocument
|
|
||||||
extends PhabricatorFerretDocument {
|
|
||||||
|
|
||||||
public function getApplicationName() {
|
|
||||||
return 'user';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIndexKey() {
|
|
||||||
return 'user';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class PhabricatorUserFerretField
|
|
||||||
extends PhabricatorFerretField {
|
|
||||||
|
|
||||||
public function getApplicationName() {
|
|
||||||
return 'user';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIndexKey() {
|
|
||||||
return 'user';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class PhabricatorUserFerretNgrams
|
|
||||||
extends PhabricatorFerretNgrams {
|
|
||||||
|
|
||||||
public function getApplicationName() {
|
|
||||||
return 'user';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIndexKey() {
|
|
||||||
return 'user';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -47,14 +47,6 @@ final class PhabricatorFerretFulltextEngineExtension
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ferret_document = $engine->newDocumentObject()
|
|
||||||
->setObjectPHID($phid)
|
|
||||||
->setIsClosed($is_closed)
|
|
||||||
->setEpochCreated($document->getDocumentCreated())
|
|
||||||
->setEpochModified($document->getDocumentModified())
|
|
||||||
->setAuthorPHID($author_phid)
|
|
||||||
->setOwnerPHID($owner_phid);
|
|
||||||
|
|
||||||
$stemmer = $engine->newStemmer();
|
$stemmer = $engine->newStemmer();
|
||||||
|
|
||||||
// Copy all of the "title" and "body" fields to create new "core" fields.
|
// Copy all of the "title" and "body" fields to create new "core" fields.
|
||||||
|
@ -133,33 +125,49 @@ final class PhabricatorFerretFulltextEngineExtension
|
||||||
$ngrams_source[] = $term_corpus;
|
$ngrams_source[] = $term_corpus;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ferret_fields[] = $engine->newFieldObject()
|
$ferret_fields[] = array(
|
||||||
->setFieldKey($key)
|
'fieldKey' => $key,
|
||||||
->setRawCorpus($raw_corpus)
|
'rawCorpus' => $raw_corpus,
|
||||||
->setTermCorpus($term_corpus)
|
'termCorpus' => $term_corpus,
|
||||||
->setNormalCorpus($normal_corpus);
|
'normalCorpus' => $normal_corpus,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$ngrams_source = implode("\n", $ngrams_source);
|
$ngrams_source = implode("\n", $ngrams_source);
|
||||||
|
|
||||||
$ngrams = $engine->getTermNgramsFromString($ngrams_source);
|
$ngrams = $engine->getTermNgramsFromString($ngrams_source);
|
||||||
|
|
||||||
$ferret_document->openTransaction();
|
$object->openTransaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
$conn = $object->establishConnection('w');
|
||||||
$this->deleteOldDocument($engine, $object, $document);
|
$this->deleteOldDocument($engine, $object, $document);
|
||||||
|
|
||||||
$ferret_document->save();
|
queryfx(
|
||||||
|
$conn,
|
||||||
|
'INSERT INTO %T (objectPHID, isClosed, epochCreated, epochModified,
|
||||||
|
authorPHID, ownerPHID) VALUES (%s, %d, %d, %d, %ns, %ns)',
|
||||||
|
$engine->getDocumentTableName(),
|
||||||
|
$object->getPHID(),
|
||||||
|
$is_closed,
|
||||||
|
$document->getDocumentCreated(),
|
||||||
|
$document->getDocumentModified(),
|
||||||
|
$author_phid,
|
||||||
|
$owner_phid);
|
||||||
|
|
||||||
$document_id = $ferret_document->getID();
|
$document_id = $conn->getInsertID();
|
||||||
foreach ($ferret_fields as $ferret_field) {
|
foreach ($ferret_fields as $ferret_field) {
|
||||||
$ferret_field
|
queryfx(
|
||||||
->setDocumentID($document_id)
|
$conn,
|
||||||
->save();
|
'INSERT INTO %T (documentID, fieldKey, rawCorpus, termCorpus,
|
||||||
|
normalCorpus) VALUES (%d, %s, %s, %s, %s)',
|
||||||
|
$engine->getFieldTableName(),
|
||||||
|
$document_id,
|
||||||
|
$ferret_field['fieldKey'],
|
||||||
|
$ferret_field['rawCorpus'],
|
||||||
|
$ferret_field['termCorpus'],
|
||||||
|
$ferret_field['normalCorpus']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ferret_ngrams = $engine->newNgramsObject();
|
|
||||||
$conn = $ferret_ngrams->establishConnection('w');
|
|
||||||
|
|
||||||
$sql = array();
|
$sql = array();
|
||||||
foreach ($ngrams as $ngram) {
|
foreach ($ngrams as $ngram) {
|
||||||
$sql[] = qsprintf(
|
$sql[] = qsprintf(
|
||||||
|
@ -173,15 +181,15 @@ final class PhabricatorFerretFulltextEngineExtension
|
||||||
queryfx(
|
queryfx(
|
||||||
$conn,
|
$conn,
|
||||||
'INSERT INTO %T (documentID, ngram) VALUES %Q',
|
'INSERT INTO %T (documentID, ngram) VALUES %Q',
|
||||||
$ferret_ngrams->getTableName(),
|
$engine->getNgramsTableName(),
|
||||||
$chunk);
|
$chunk);
|
||||||
}
|
}
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
$ferret_document->killTransaction();
|
$object->killTransaction();
|
||||||
throw $ex;
|
throw $ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ferret_document->saveTransaction();
|
$object->saveTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -190,32 +198,35 @@ final class PhabricatorFerretFulltextEngineExtension
|
||||||
$object,
|
$object,
|
||||||
PhabricatorSearchAbstractDocument $document) {
|
PhabricatorSearchAbstractDocument $document) {
|
||||||
|
|
||||||
$old_document = $engine->newDocumentObject()->loadOneWhere(
|
$conn = $object->establishConnection('w');
|
||||||
'objectPHID = %s',
|
|
||||||
$document->getPHID());
|
$old_document = queryfx_one(
|
||||||
|
$conn,
|
||||||
|
'SELECT * FROM %T WHERE objectPHID = %s',
|
||||||
|
$engine->getDocumentTableName(),
|
||||||
|
$object->getPHID());
|
||||||
if (!$old_document) {
|
if (!$old_document) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$conn = $old_document->establishConnection('w');
|
$old_id = $old_document['id'];
|
||||||
$old_id = $old_document->getID();
|
|
||||||
|
|
||||||
queryfx(
|
queryfx(
|
||||||
$conn,
|
$conn,
|
||||||
'DELETE FROM %T WHERE id = %d',
|
'DELETE FROM %T WHERE id = %d',
|
||||||
$engine->newDocumentObject()->getTableName(),
|
$engine->getDocumentTableName(),
|
||||||
$old_id);
|
$old_id);
|
||||||
|
|
||||||
queryfx(
|
queryfx(
|
||||||
$conn,
|
$conn,
|
||||||
'DELETE FROM %T WHERE documentID = %d',
|
'DELETE FROM %T WHERE documentID = %d',
|
||||||
$engine->newFieldObject()->getTableName(),
|
$engine->getFieldTableName(),
|
||||||
$old_id);
|
$old_id);
|
||||||
|
|
||||||
queryfx(
|
queryfx(
|
||||||
$conn,
|
$conn,
|
||||||
'DELETE FROM %T WHERE documentID = %d',
|
'DELETE FROM %T WHERE documentID = %d',
|
||||||
$engine->newNgramsObject()->getTableName(),
|
$engine->getNgramsTableName(),
|
||||||
$old_id);
|
$old_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
abstract class PhabricatorFerretDocument
|
|
||||||
extends PhabricatorSearchDAO {
|
|
||||||
|
|
||||||
protected $objectPHID;
|
|
||||||
protected $isClosed;
|
|
||||||
protected $authorPHID;
|
|
||||||
protected $ownerPHID;
|
|
||||||
protected $epochCreated;
|
|
||||||
protected $epochModified;
|
|
||||||
|
|
||||||
abstract public function getIndexKey();
|
|
||||||
|
|
||||||
protected function getConfiguration() {
|
|
||||||
return array(
|
|
||||||
self::CONFIG_TIMESTAMPS => false,
|
|
||||||
self::CONFIG_COLUMN_SCHEMA => array(
|
|
||||||
'isClosed' => 'bool',
|
|
||||||
'authorPHID' => 'phid?',
|
|
||||||
'ownerPHID' => 'phid?',
|
|
||||||
'epochCreated' => 'epoch',
|
|
||||||
'epochModified' => 'epoch',
|
|
||||||
),
|
|
||||||
self::CONFIG_KEY_SCHEMA => array(
|
|
||||||
'key_object' => array(
|
|
||||||
'columns' => array('objectPHID'),
|
|
||||||
'unique' => true,
|
|
||||||
),
|
|
||||||
'key_author' => array(
|
|
||||||
'columns' => array('authorPHID'),
|
|
||||||
),
|
|
||||||
'key_owner' => array(
|
|
||||||
'columns' => array('ownerPHID'),
|
|
||||||
),
|
|
||||||
'key_created' => array(
|
|
||||||
'columns' => array('epochCreated'),
|
|
||||||
),
|
|
||||||
'key_modified' => array(
|
|
||||||
'columns' => array('epochModified'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
) + parent::getConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTableName() {
|
|
||||||
$application = $this->getApplicationName();
|
|
||||||
$key = $this->getIndexKey();
|
|
||||||
return "{$application}_{$key}_fdocument";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -2,9 +2,8 @@
|
||||||
|
|
||||||
abstract class PhabricatorFerretEngine extends Phobject {
|
abstract class PhabricatorFerretEngine extends Phobject {
|
||||||
|
|
||||||
abstract public function newNgramsObject();
|
abstract public function getApplicationName();
|
||||||
abstract public function newDocumentObject();
|
abstract public function getScopeName();
|
||||||
abstract public function newFieldObject();
|
|
||||||
abstract public function newSearchEngine();
|
abstract public function newSearchEngine();
|
||||||
|
|
||||||
public function getDefaultFunctionKey() {
|
public function getDefaultFunctionKey() {
|
||||||
|
@ -168,4 +167,111 @@ abstract class PhabricatorFerretEngine extends Phobject {
|
||||||
return $term_corpus;
|
return $term_corpus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -( Schema )------------------------------------------------------------- */
|
||||||
|
|
||||||
|
public function getDocumentTableName() {
|
||||||
|
$application = $this->getApplicationName();
|
||||||
|
$scope = $this->getScopeName();
|
||||||
|
|
||||||
|
return "{$application}_{$scope}_fdocument";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDocumentSchemaColumns() {
|
||||||
|
return array(
|
||||||
|
'id' => 'auto',
|
||||||
|
'objectPHID' => 'phid',
|
||||||
|
'isClosed' => 'bool',
|
||||||
|
'authorPHID' => 'phid?',
|
||||||
|
'ownerPHID' => 'phid?',
|
||||||
|
'epochCreated' => 'epoch',
|
||||||
|
'epochModified' => 'epoch',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDocumentSchemaKeys() {
|
||||||
|
return array(
|
||||||
|
'PRIMARY' => array(
|
||||||
|
'columns' => array('id'),
|
||||||
|
'unique' => true,
|
||||||
|
),
|
||||||
|
'key_object' => array(
|
||||||
|
'columns' => array('objectPHID'),
|
||||||
|
'unique' => true,
|
||||||
|
),
|
||||||
|
'key_author' => array(
|
||||||
|
'columns' => array('authorPHID'),
|
||||||
|
),
|
||||||
|
'key_owner' => array(
|
||||||
|
'columns' => array('ownerPHID'),
|
||||||
|
),
|
||||||
|
'key_created' => array(
|
||||||
|
'columns' => array('epochCreated'),
|
||||||
|
),
|
||||||
|
'key_modified' => array(
|
||||||
|
'columns' => array('epochModified'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFieldTableName() {
|
||||||
|
$application = $this->getApplicationName();
|
||||||
|
$scope = $this->getScopeName();
|
||||||
|
|
||||||
|
return "{$application}_{$scope}_ffield";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFieldSchemaColumns() {
|
||||||
|
return array(
|
||||||
|
'id' => 'auto',
|
||||||
|
'documentID' => 'uint32',
|
||||||
|
'fieldKey' => 'text4',
|
||||||
|
'rawCorpus' => 'sort',
|
||||||
|
'termCorpus' => 'sort',
|
||||||
|
'normalCorpus' => 'sort',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFieldSchemaKeys() {
|
||||||
|
return array(
|
||||||
|
'PRIMARY' => array(
|
||||||
|
'columns' => array('id'),
|
||||||
|
'unique' => true,
|
||||||
|
),
|
||||||
|
'key_documentfield' => array(
|
||||||
|
'columns' => array('documentID', 'fieldKey'),
|
||||||
|
'unique' => true,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNgramsTableName() {
|
||||||
|
$application = $this->getApplicationName();
|
||||||
|
$scope = $this->getScopeName();
|
||||||
|
|
||||||
|
return "{$application}_{$scope}_fngrams";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNgramsSchemaColumns() {
|
||||||
|
return array(
|
||||||
|
'id' => 'auto',
|
||||||
|
'documentID' => 'uint32',
|
||||||
|
'ngram' => 'char3',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNgramsSchemaKeys() {
|
||||||
|
return array(
|
||||||
|
'PRIMARY' => array(
|
||||||
|
'columns' => array('id'),
|
||||||
|
'unique' => true,
|
||||||
|
),
|
||||||
|
'key_ngram' => array(
|
||||||
|
'columns' => array('ngram', 'documentID'),
|
||||||
|
),
|
||||||
|
'key_object' => array(
|
||||||
|
'columns' => array('documentID'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
abstract class PhabricatorFerretField
|
|
||||||
extends PhabricatorSearchDAO {
|
|
||||||
|
|
||||||
protected $documentID;
|
|
||||||
protected $fieldKey;
|
|
||||||
protected $rawCorpus;
|
|
||||||
protected $termCorpus;
|
|
||||||
protected $normalCorpus;
|
|
||||||
|
|
||||||
abstract public function getIndexKey();
|
|
||||||
|
|
||||||
protected function getConfiguration() {
|
|
||||||
return array(
|
|
||||||
self::CONFIG_TIMESTAMPS => false,
|
|
||||||
self::CONFIG_COLUMN_SCHEMA => array(
|
|
||||||
'documentID' => 'uint32',
|
|
||||||
'fieldKey' => 'text4',
|
|
||||||
'rawCorpus' => 'sort',
|
|
||||||
'termCorpus' => 'sort',
|
|
||||||
'normalCorpus' => 'sort',
|
|
||||||
),
|
|
||||||
self::CONFIG_KEY_SCHEMA => array(
|
|
||||||
'key_documentfield' => array(
|
|
||||||
'columns' => array('documentID', 'fieldKey'),
|
|
||||||
'unique' => true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
) + parent::getConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTableName() {
|
|
||||||
$application = $this->getApplicationName();
|
|
||||||
$key = $this->getIndexKey();
|
|
||||||
return "{$application}_{$key}_ffield";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
abstract class PhabricatorFerretNgrams
|
|
||||||
extends PhabricatorSearchDAO {
|
|
||||||
|
|
||||||
protected $documentID;
|
|
||||||
protected $ngram;
|
|
||||||
|
|
||||||
abstract public function getIndexKey();
|
|
||||||
|
|
||||||
protected function getConfiguration() {
|
|
||||||
return array(
|
|
||||||
self::CONFIG_TIMESTAMPS => false,
|
|
||||||
self::CONFIG_COLUMN_SCHEMA => array(
|
|
||||||
'documentID' => 'uint32',
|
|
||||||
'ngram' => 'char3',
|
|
||||||
),
|
|
||||||
self::CONFIG_KEY_SCHEMA => array(
|
|
||||||
'key_ngram' => array(
|
|
||||||
'columns' => array('ngram', 'documentID'),
|
|
||||||
),
|
|
||||||
'key_object' => array(
|
|
||||||
'columns' => array('documentID'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
) + parent::getConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTableName() {
|
|
||||||
$application = $this->getApplicationName();
|
|
||||||
$key = $this->getIndexKey();
|
|
||||||
return "{$application}_{$key}_fngrams";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1623,8 +1623,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
|
||||||
$engine = $this->ferretEngine;
|
$engine = $this->ferretEngine;
|
||||||
$stemmer = $engine->newStemmer();
|
$stemmer = $engine->newStemmer();
|
||||||
|
|
||||||
$ngram_table = $engine->newNgramsObject();
|
$ngram_table = $engine->getNgramsTableName();
|
||||||
$ngram_table_name = $ngram_table->getTableName();
|
|
||||||
|
|
||||||
$flat = array();
|
$flat = array();
|
||||||
foreach ($this->ferretTokens as $fulltext_token) {
|
foreach ($this->ferretTokens as $fulltext_token) {
|
||||||
|
@ -1680,7 +1679,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
|
||||||
|
|
||||||
foreach ($ngrams as $ngram) {
|
foreach ($ngrams as $ngram) {
|
||||||
$flat[] = array(
|
$flat[] = array(
|
||||||
'table' => $ngram_table_name,
|
'table' => $ngram_table,
|
||||||
'ngram' => $ngram,
|
'ngram' => $ngram,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1702,14 +1701,14 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
|
||||||
$phid_column = qsprintf($conn, '%T', 'phid');
|
$phid_column = qsprintf($conn, '%T', 'phid');
|
||||||
}
|
}
|
||||||
|
|
||||||
$document_table = $engine->newDocumentObject();
|
$document_table = $engine->getDocumentTableName();
|
||||||
$field_table = $engine->newFieldObject();
|
$field_table = $engine->getFieldTableName();
|
||||||
|
|
||||||
$joins = array();
|
$joins = array();
|
||||||
$joins[] = qsprintf(
|
$joins[] = qsprintf(
|
||||||
$conn,
|
$conn,
|
||||||
'JOIN %T ft_doc ON ft_doc.objectPHID = %Q',
|
'JOIN %T ft_doc ON ft_doc.objectPHID = %Q',
|
||||||
$document_table->getTableName(),
|
$document_table,
|
||||||
$phid_column);
|
$phid_column);
|
||||||
|
|
||||||
$idx = 1;
|
$idx = 1;
|
||||||
|
@ -1736,7 +1735,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
|
||||||
$conn,
|
$conn,
|
||||||
'JOIN %T %T ON ft_doc.id = %T.documentID
|
'JOIN %T %T ON ft_doc.id = %T.documentID
|
||||||
AND %T.fieldKey = %s',
|
AND %T.fieldKey = %s',
|
||||||
$field_table->getTableName(),
|
$field_table,
|
||||||
$alias,
|
$alias,
|
||||||
$alias,
|
$alias,
|
||||||
$alias,
|
$alias,
|
||||||
|
|
Loading…
Reference in a new issue