Matthias Mullie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/111359
Change subject: Remove 'latest' indexes on posts & headers.
......................................................................
Remove 'latest' indexes on posts & headers.
Both have an index for the last 100 revisions already - the exact same index can
be used to fetch the most recent change.
I assume the reason this was not yet the case, is that the history-index returns
up to 100 ids, which are then all fetched. However, by passing along $options,
we can make sure rowCompacter doesn't go and fetch more than needed.
Advantage of deleting this separate index is that both history & latest-post
will now use the same index to fetch revisions. LocalBufferedStorage will save
that result, so that saves 1 memcached request where both history & most recent
revision are needed.
Change-Id: Idd2acf6896a335e652789a368b31fbf365892493
---
M container.php
M includes/Data/BoardHistoryStorage.php
M includes/Data/ObjectManager.php
3 files changed, 19 insertions(+), 25 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/59/111359/1
diff --git a/container.php b/container.php
index fc39922..9858ffe 100644
--- a/container.php
+++ b/container.php
@@ -227,11 +227,6 @@
'flow_header:workflow', array( 'header_workflow_id' ),
array( 'limit' => 100 ) + $workflowIndexOptions
),
- new TopKIndex(
- $cache, $storage,
- 'flow_header:latest', array( 'header_workflow_id' ),
- array( 'limit' => 1 ) + $workflowIndexOptions
- ),
);
$handlers = array(
@@ -298,18 +293,6 @@
'shallow' => $pk,
'create' => function( array $row ) {
// return true to create instead of
merge index
- return $row['rev_parent_id'] === null;
- },
- ) ),
- // most recent revision
- new TopKIndex( $cache, $storage, 'flow_revision:latest_post',
- array( 'tree_rev_descendant_id' ),
- array(
- 'limit' => 1,
- 'sort' => 'rev_id',
- 'order' => 'DESC',
- 'shallow' => $pk,
- 'create' => function( array $row ) {
return $row['rev_parent_id'] === null;
},
) ),
diff --git a/includes/Data/BoardHistoryStorage.php
b/includes/Data/BoardHistoryStorage.php
index 5b074a7..524d5a1 100644
--- a/includes/Data/BoardHistoryStorage.php
+++ b/includes/Data/BoardHistoryStorage.php
@@ -106,11 +106,11 @@
parent::__construct( $cache, $storage, $prefix, $indexed,
$options );
}
- public function findMulti( array $queries ) {
+ public function findMulti( array $queries, array $options = array() ) {
if ( count( $queries ) > 1 ) {
throw new DataModelException( __METHOD__ . ' expects
only one value in $queries', 'process-data' );
}
- return parent::findMulti( $queries );
+ return parent::findMulti( $queries, $options );
}
public function backingStoreFindMulti( array $queries, array $idxToKey,
array $retval = array() ) {
diff --git a/includes/Data/ObjectManager.php b/includes/Data/ObjectManager.php
index 6ee14fd..6749abc 100644
--- a/includes/Data/ObjectManager.php
+++ b/includes/Data/ObjectManager.php
@@ -89,18 +89,20 @@
* Find data models matching the provided equality condition.
*
* @param array $keys A map of k,v pairs to find via equality condition
+ * @param array[optional] $options Options to use
* @return array|false Cached subset of data model rows matching the
* equality conditions provided in $keys.
*/
- function find( array $keys );
+ function find( array $keys, array $options = array() );
/**
* Batch together multiple calls to self::find with minimal network
round trips.
*
* @param array $queries An array of arrays in the form of $keys
parameter of self::find
+ * @param array[optional] $options Options to use
* @return array|false Array of arrays in same order as $queries
representing batched result set.
*/
- function findMulti( array $queries );
+ function findMulti( array $queries, array $options = array() );
/**
* @return integer Maximum number of items in a single index value
@@ -240,7 +242,7 @@
try {
$index = $this->getIndexFor( $keys, $options );
- $res = $index->findMulti( $queries );
+ $res = $index->findMulti( $queries, $options );
} catch ( NoIndexException $e ) {
wfDebugLog( __CLASS__, __FUNCTION__ . ': ' .
$e->getMessage() );
$res = $this->storage->findMulti( $queries,
$this->convertToDbOptions( $options ) );
@@ -1087,12 +1089,12 @@
// nothing to do
}
- public function find( array $attributes ) {
- $results = $this->findMulti( array( $attributes ) );
+ public function find( array $attributes, array $options = array() ) {
+ $results = $this->findMulti( array( $attributes ), $options );
return reset( $results );
}
- public function findMulti( array $queries ) {
+ public function findMulti( array $queries, array $options = array() ) {
if ( !$queries ) {
return array();
}
@@ -1119,6 +1121,10 @@
// Retrieve from cache
$cached = $this->cache->getMulti( array_keys( $keyToIdx ) );
+ foreach ( $cached as $i => $result ) {
+ $limit = isset( $options['limit'] ) ? $options['limit']
: $this->getLimit();
+ $cached[$i] = array_splice( $result, 0, $limit );
+ }
// expand partial results and merge into result set
foreach( $this->rowCompactor->expandCacheResult( $cached,
$keyToQuery ) as $key => $rows ) {
foreach ( $keyToIdx[$key] as $idx ) {
@@ -1240,6 +1246,11 @@
* Holds the top k items with matching $indexed columns. List is sorted and
truncated to specified size.
*/
class TopKIndex extends FeatureIndex {
+ /**
+ * @var array
+ */
+ protected $options = array();
+
public function __construct( BufferedCache $cache, ObjectStorage
$storage, $prefix, array $indexed, array $options = array() ) {
if ( empty( $options['sort'] ) ) {
throw new InvalidInputException( 'TopKIndex must be
sorted', 'invalid-input' );
--
To view, visit https://gerrit.wikimedia.org/r/111359
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idd2acf6896a335e652789a368b31fbf365892493
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits