Tweaked generated paths for ExternalStoreMwstore
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 13 Feb 2014 18:15:13 +0000 (10:15 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 13 Feb 2014 18:15:13 +0000 (10:15 -0800)
* This improve the object store case (with B-Tree container listings
  and 2-level sharding set up).

Change-Id: If75f51fb07cd5df0da455d4e6eafe06d69e8b941

includes/externalstore/ExternalStoreMwstore.php

index f329b73..89ac734 100644 (file)
@@ -84,8 +84,10 @@ class ExternalStoreMwstore extends ExternalStoreMedium {
                        // Segregate items by wiki ID for the sake of bookkeeping
                        $wiki = isset( $this->params['wiki'] ) ? $this->params['wiki'] : wfWikiID();
 
-                       $url = $be->getContainerStoragePath( 'data' ) . '/' .
-                               rawurlencode( $wiki ) . "/{$rand[0]}/{$rand[1]}/{$rand[2]}/{$id}";
+                       $url = $be->getContainerStoragePath( 'data' ) . '/' . rawurlencode( $wiki );
+                       $url .= ( $be instanceof FSFileBackend )
+                               ? "/{$rand[0]}/{$rand[1]}/{$rand[2]}/{$id}" // keep directories small
+                               : "/{$rand[0]}/{$rand[1]}/{$id}"; // container sharding is only 2-levels
 
                        $be->prepare( array( 'dir' => dirname( $url ), 'noAccess' => 1, 'noListing' => 1 ) );
                        if ( $be->create( array( 'dst' => $url, 'content' => $data ) )->isOK() ) {