Bumped RING_SIZE to use 28 bits to improve weight accuracy a bit.
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 22 Apr 2013 20:47:52 +0000 (13:47 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Mon, 22 Apr 2013 20:47:52 +0000 (13:47 -0700)
Change-Id: I4dbecd292fd404e43ed296dd37892db113fa1026

includes/HashRing.php

index 10a3c9c..227a287 100644 (file)
@@ -30,7 +30,7 @@ class HashRing {
        /** @var Array (location => (start, end)) */
        protected $ring = array();
 
-       const RING_SIZE = 16777216; // 2^24
+       const RING_SIZE = 268435456; // 2^28
 
        /**
         * @param array $map (location => weight)
@@ -86,7 +86,7 @@ class HashRing {
        public function getLocations( $item, $limit ) {
                $locations = array();
                $primaryLocation = null;
-               $spot = hexdec( substr( sha1( $item ), 0, 6 ) ); // first 24 bits
+               $spot = hexdec( substr( sha1( $item ), 0, 7 ) ); // first 28 bits
                foreach ( $this->ring as $location => $range ) {
                        if ( count( $locations ) >= $limit ) {
                                break;