jenkins-bot has submitted this change and it was merged.
Change subject: Move query-to-index-key code out of findMulti
......................................................................
Move query-to-index-key code out of findMulti
Change-Id: I2c5c0ee8aefb4c688b552df3a4d8ad60a27fb917
---
M includes/Data/ObjectManager.php
1 file changed, 33 insertions(+), 15 deletions(-)
Approvals:
EBernhardson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/Data/ObjectManager.php b/includes/Data/ObjectManager.php
index 6749abc..831a70c 100644
--- a/includes/Data/ObjectManager.php
+++ b/includes/Data/ObjectManager.php
@@ -1099,23 +1099,18 @@
return array();
}
- // Build a map from cache key to its index in $queries
+ // get cache keys for all queries
+ $cacheKeys = $this->getCacheKeys( $queries );
+
$results = $keyToIdx = $keyToQuery = array();
- foreach ( $queries as $idx => $query ) {
- ksort( $query );
- if ( array_keys( $query ) !== $this->indexedOrdered ) {
- throw new DataModelException(
- 'Cannot answer query for columns: ' .
implode( ', ', array_keys( $queries[$idx] ) ), 'process-data'
- );
- }
- $key = $this->cacheKey( $query );
+ foreach ( $cacheKeys as $i => $key ) {
// allow for duplicate queries
- $keyToIdx[$key][] = $idx;
- $idxToKey[$idx] = $key;
+ $keyToIdx[$key][] = $i;
+
+ // These results will be merged into the query results,
and as such need binary
+ // uuid's as would be received from storage
if ( !isset( $keyToQuery[$key] ) ) {
- // These results will be merged into the query
results, and as such need binary
- // uuid's as would be received from storage
- $keyToQuery[$key] = UUID::convertUUIDs( $query
);
+ $keyToQuery[$key] = UUID::convertUUIDs(
$queries[$i] );
}
}
@@ -1137,7 +1132,30 @@
return $results;
}
- return $this->backingStoreFindMulti( $queries, $idxToKey,
$results );
+ return $this->backingStoreFindMulti( $queries, $cacheKeys,
$results );
+ }
+
+ /**
+ * Build a map from cache key to its index in $queries.
+ *
+ * @param array $queries
+ * @return array Array of [query index => cache key]
+ */
+ protected function getCacheKeys( $queries ) {
+ $idxToKey = array();
+
+ foreach ( $queries as $idx => $query ) {
+ ksort( $query );
+ if ( array_keys( $query ) !== $this->indexedOrdered ) {
+ throw new DataModelException(
+ 'Cannot answer query for columns: ' .
implode( ', ', array_keys( $queries[$idx] ) ), 'process-data'
+ );
+ }
+ $key = $this->cacheKey( $query );
+ $idxToKey[$idx] = $key;
+ }
+
+ return $idxToKey;
}
protected function backingStoreFindMulti( array $queries, array
$idxToKey, array $results = array() ) {
--
To view, visit https://gerrit.wikimedia.org/r/111360
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2c5c0ee8aefb4c688b552df3a4d8ad60a27fb917
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits