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:
@@ -25,7 +25,7 @@ final class ConduitResultSearchEngineExtension
|
|||||||
return $object->getFieldSpecificationsForConduit();
|
return $object->getFieldSpecificationsForConduit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldValuesForConduit($object) {
|
public function getFieldValuesForConduit($object, $data) {
|
||||||
return $object->getFieldValuesForConduit();
|
return $object->getFieldValuesForConduit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ final class PhabricatorPolicySearchEngineExtension
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldValuesForConduit($object) {
|
public function getFieldValuesForConduit($object, $data) {
|
||||||
$capabilities = $object->getCapabilities();
|
$capabilities = $object->getCapabilities();
|
||||||
|
|
||||||
$map = array();
|
$map = array();
|
||||||
|
|||||||
@@ -1138,6 +1138,11 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject {
|
|||||||
if ($objects) {
|
if ($objects) {
|
||||||
$field_extensions = $this->getConduitFieldExtensions();
|
$field_extensions = $this->getConduitFieldExtensions();
|
||||||
|
|
||||||
|
$extension_data = array();
|
||||||
|
foreach ($field_extensions as $key => $extension) {
|
||||||
|
$extension_data[$key] = $extension->loadExtensionConduitData($objects);
|
||||||
|
}
|
||||||
|
|
||||||
$attachment_data = array();
|
$attachment_data = array();
|
||||||
foreach ($attachments as $key => $attachment) {
|
foreach ($attachments as $key => $attachment) {
|
||||||
$attachment_data[$key] = $attachment->loadAttachmentData(
|
$attachment_data[$key] = $attachment->loadAttachmentData(
|
||||||
@@ -1148,7 +1153,8 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject {
|
|||||||
foreach ($objects as $object) {
|
foreach ($objects as $object) {
|
||||||
$field_map = $this->getObjectWireFieldsForConduit(
|
$field_map = $this->getObjectWireFieldsForConduit(
|
||||||
$object,
|
$object,
|
||||||
$field_extensions);
|
$field_extensions,
|
||||||
|
$extension_data);
|
||||||
|
|
||||||
$attachment_map = array();
|
$attachment_map = array();
|
||||||
foreach ($attachments as $key => $attachment) {
|
foreach ($attachments as $key => $attachment) {
|
||||||
@@ -1312,11 +1318,13 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject {
|
|||||||
|
|
||||||
protected function getObjectWireFieldsForConduit(
|
protected function getObjectWireFieldsForConduit(
|
||||||
$object,
|
$object,
|
||||||
array $field_extensions) {
|
array $field_extensions,
|
||||||
|
array $extension_data) {
|
||||||
|
|
||||||
$fields = array();
|
$fields = array();
|
||||||
foreach ($field_extensions as $extension) {
|
foreach ($field_extensions as $key => $extension) {
|
||||||
$fields += $extension->getFieldValuesForConduit($object);
|
$data = idx($extension_data, $key, array());
|
||||||
|
$fields += $extension->getFieldValuesForConduit($object, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ final class PhabricatorLiskSearchEngineExtension
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldValuesForConduit($object) {
|
public function getFieldValuesForConduit($object, $data) {
|
||||||
return array(
|
return array(
|
||||||
'dateCreated' => (int)$object->getDateCreated(),
|
'dateCreated' => (int)$object->getDateCreated(),
|
||||||
'dateModified' => (int)$object->getDateModified(),
|
'dateModified' => (int)$object->getDateModified(),
|
||||||
|
|||||||
@@ -56,7 +56,11 @@ abstract class PhabricatorSearchEngineExtension extends Phobject {
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldValuesForConduit($object) {
|
public function loadExtensionConduitData(array $objects) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFieldValuesForConduit($object, $data) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ final class PhabricatorSpacesSearchEngineExtension
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldValuesForConduit($object) {
|
public function getFieldValuesForConduit($object, $data) {
|
||||||
return array(
|
return array(
|
||||||
'spacePHID' => $object->getSpacePHID(),
|
'spacePHID' => $object->getSpacePHID(),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ final class PhabricatorCustomFieldSearchEngineExtension
|
|||||||
return $map;
|
return $map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldValuesForConduit($object) {
|
public function getFieldValuesForConduit($object, $data) {
|
||||||
// TODO: This is currently very inefficient. We should bulk-load these
|
// TODO: This is currently very inefficient. We should bulk-load these
|
||||||
// field values instead.
|
// field values instead.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user