[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Script to populate a bloom filter with a BloomFilter* class 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 * http://www.gnu.org/copyleft/gpl.html 19 * 20 * @file 21 * @ingroup Maintenance 22 */ 23 24 require_once __DIR__ . '/Maintenance.php'; 25 26 /** 27 * Script to populate a bloom filter with a BloomFilter* class 28 * 29 * @ingroup Maintenance 30 */ 31 class PopulateBloomFilter extends Maintenance { 32 public function __construct() { 33 parent::__construct(); 34 $this->addOption( 'cache', 'Bloom cache store name', true, true ); 35 $this->addOption( 'filter', 'Bloom filter name', true, true ); 36 $this->addOption( 'domain', 'Bloom filter domain', true, true ); 37 $this->addOption( 'delay', 'Sleep delay between batches (us)', false, true ); 38 $this->mDescription = "Populate the specified bloom filter"; 39 } 40 41 public function execute() { 42 $type = $this->getOption( 'filter' ); 43 $domain = $this->getOption( 'domain' ); 44 $bcache = BloomCache::get( $this->getOption( 'cache' ) ); 45 $delay = $this->getOption( 'delay', 1e5 ); 46 47 if ( !method_exists( "BloomFilter{$type}", 'merge' ) ) { 48 $this->error( "No \"BloomFilter{$type}::merge\" method found.", 1 ); 49 } 50 51 $virtualKey = "$domain:$type"; 52 $status = $bcache->getStatus( $virtualKey ); 53 if ( $status == false ) { 54 $this->error( "Could not query virtual bloom filter '$virtualKey'.", 1 ); 55 } 56 57 $startTime = microtime( true ); 58 $this->output( "Current timestamp is '$startTime'.\n" ); 59 $this->output( "Current filter timestamp is '{$status['asOfTime']}'.\n" ); 60 61 do { 62 $status = call_user_func_array( 63 array( "BloomFilter{$type}", 'merge' ), 64 array( $bcache, $domain, $virtualKey, $status ) 65 ); 66 if ( $status == false ) { 67 $this->error( "Could not query virtual bloom filter '$virtualKey'.", 1 ); 68 } 69 $this->output( "Filter updated to timestamp '{$status['asOfTime']}'.\n" ); 70 usleep( $delay ); 71 } while ( $status['asOfTime'] && $status['asOfTime'] < $startTime ); 72 73 $this->output( "Done, filter $type of domain $domain reached time '$startTime'.\n" ); 74 } 75 } 76 77 $maintClass = "PopulateBloomFilter"; 78 require_once RUN_MAINTENANCE_IF_MAIN;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |