mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
Allow *.search
Conduit API methods to have data bulk-loaded by extensions
Summary: Ref T11404. Currently, SearchEngineAttachments can bulk-load data but SearchEngineExtensions can not. This leads to poor performance of custom fields. See T11404 for discussion. This changes the API to support a bulk load + format pattern like the one Attachments use. The next change will use it to bulk-load custom field data. Test Plan: - Ran `differential.query`, `differential.revision.search` as a sanity check. - No behavioral changes are expected - See next revision. Reviewers: yelirekim, chad Reviewed By: chad Maniphest Tasks: T11404 Differential Revision: https://secure.phabricator.com/D16350
This commit is contained in:
parent
33fca12816
commit
6e57582aff
7 changed files with 22 additions and 10 deletions
|
@ -25,7 +25,7 @@ final class ConduitResultSearchEngineExtension
|
|||
return $object->getFieldSpecificationsForConduit();
|
||||
}
|
||||
|
||||
public function getFieldValuesForConduit($object) {
|
||||
public function getFieldValuesForConduit($object, $data) {
|
||||
return $object->getFieldValuesForConduit();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ final class PhabricatorPolicySearchEngineExtension
|
|||
);
|
||||
}
|
||||
|
||||
public function getFieldValuesForConduit($object) {
|
||||
public function getFieldValuesForConduit($object, $data) {
|
||||
$capabilities = $object->getCapabilities();
|
||||
|
||||
$map = array();
|
||||
|
|
|
@ -1138,6 +1138,11 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject {
|
|||
if ($objects) {
|
||||
$field_extensions = $this->getConduitFieldExtensions();
|
||||
|
||||
$extension_data = array();
|
||||
foreach ($field_extensions as $key => $extension) {
|
||||
$extension_data[$key] = $extension->loadExtensionConduitData($objects);
|
||||
}
|
||||
|
||||
$attachment_data = array();
|
||||
foreach ($attachments as $key => $attachment) {
|
||||
$attachment_data[$key] = $attachment->loadAttachmentData(
|
||||
|
@ -1148,7 +1153,8 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject {
|
|||
foreach ($objects as $object) {
|
||||
$field_map = $this->getObjectWireFieldsForConduit(
|
||||
$object,
|
||||
$field_extensions);
|
||||
$field_extensions,
|
||||
$extension_data);
|
||||
|
||||
$attachment_map = array();
|
||||
foreach ($attachments as $key => $attachment) {
|
||||
|
@ -1312,11 +1318,13 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject {
|
|||
|
||||
protected function getObjectWireFieldsForConduit(
|
||||
$object,
|
||||
array $field_extensions) {
|
||||
array $field_extensions,
|
||||
array $extension_data) {
|
||||
|
||||
$fields = array();
|
||||
foreach ($field_extensions as $extension) {
|
||||
$fields += $extension->getFieldValuesForConduit($object);
|
||||
foreach ($field_extensions as $key => $extension) {
|
||||
$data = idx($extension_data, $key, array());
|
||||
$fields += $extension->getFieldValuesForConduit($object, $data);
|
||||
}
|
||||
|
||||
return $fields;
|
||||
|
|
|
@ -44,7 +44,7 @@ final class PhabricatorLiskSearchEngineExtension
|
|||
);
|
||||
}
|
||||
|
||||
public function getFieldValuesForConduit($object) {
|
||||
public function getFieldValuesForConduit($object, $data) {
|
||||
return array(
|
||||
'dateCreated' => (int)$object->getDateCreated(),
|
||||
'dateModified' => (int)$object->getDateModified(),
|
||||
|
|
|
@ -56,7 +56,11 @@ abstract class PhabricatorSearchEngineExtension extends Phobject {
|
|||
return array();
|
||||
}
|
||||
|
||||
public function getFieldValuesForConduit($object) {
|
||||
public function loadExtensionConduitData(array $objects) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getFieldValuesForConduit($object, $data) {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ final class PhabricatorSpacesSearchEngineExtension
|
|||
);
|
||||
}
|
||||
|
||||
public function getFieldValuesForConduit($object) {
|
||||
public function getFieldValuesForConduit($object, $data) {
|
||||
return array(
|
||||
'spacePHID' => $object->getSpacePHID(),
|
||||
);
|
||||
|
|
|
@ -80,7 +80,7 @@ final class PhabricatorCustomFieldSearchEngineExtension
|
|||
return $map;
|
||||
}
|
||||
|
||||
public function getFieldValuesForConduit($object) {
|
||||
public function getFieldValuesForConduit($object, $data) {
|
||||
// TODO: This is currently very inefficient. We should bulk-load these
|
||||
// field values instead.
|
||||
|
||||
|
|
Loading…
Reference in a new issue