Compute the shard ID from the snowflake.
@param int  $shardCount
@return int
14851
function getShardID(int $shardCount) {
        if(\PHP_INT_SIZE === 4) {
            $time = \base_convert(\substr($this->binary, 0, 42), 2, 10);
            $shard = (int) \bcmod($time, ((string) $shardCount));
            
            return $shard;
        } else {
            $time = $this->value >> 22;
            return ($time % $shardCount);
        }
    }
472143
public function getId()
    {
        if (!$this->id) {
            $this->setId(sha1($this->getDomain() . $this->getKey()));
        }

        return $this->id;
    }
699066
public function isValid($intCount = null)
    {
        $blnReturn = false;
        $intDynamicCount = ($this->isDynamicCounter()) ? $this->__validator->getValue() : 0;

        for ($intCount = 0; $intCount <= $intDynamicCount; $intCount ++) {
            $blnReturn = $this->__validator->validate($intCount);

            if (! $blnReturn) {
                break;
            }
        }

        return $blnReturn;
    }
904970
def get_shard_stats(self):
        
        return requests.get(self._stats_url, params={'include_stats': True},
                            headers={'X-Auth-Token': self._client.auth._token}
                            ).json()['data']['stats']
995097
protected function getColorScore($color, $count, $colorsCount)
	    {
	        $sRGBComponents = $this->getSRGBComponents($this->getRGBComponents($color));
	        $max 			= max($sRGBComponents);
	        $min 			= min($sRGBComponents);
	        $diff 			= $max - $min;
	        $sum 			= $max + $min;
	        $saturation 	= $diff ? ($sum / 2 > .5 ? $diff / (2 - $diff) : $diff / $sum) : 0;
	        $luminosity 	= ($sum / 2 + .2126 * $sRGBComponents[0] + .7152 * $sRGBComponents[1] + .0722 * $sRGBComponents[2]) / 2;

	        return $saturation < .5 ?
	            (1 - $luminosity) * $count / $colorsCount :
	            $count * ($saturation) * $luminosity;
	    }
803642
public function setRowCount(bool $runRowCount): ?int
    {
        if ($runRowCount === true) {
            return $this->sqlQuery->rowCount();
        }

        return null;
    }
477029
def get_canonical_key_id(self, key_id):
        
        shard_num = self.get_shard_num_by_key_id(key_id)
        return self._canonical_keys[shard_num]
113369
def get_shard_by_num(self, shard_num):
        
        if shard_num < 0 or shard_num >= self.num_shards():
            raise ValueError("requested invalid shard# {0}".format(shard_num))

        return self._shards[shard_num]
196515
public function getHlblockId($hlblockName) {
        $item = $this->getHlblock($hlblockName);
        return ($item && isset($item['ID'])) ? $item['ID'] : 0;
    }
658931
def _compute(self, feed_dict, shard):
        

        try:
            descriptor, enq = self._tfrun(self._tf_expr[shard], feed_dict=feed_dict)
            self._inputs_waiting.decrement(shard)

        except Exception as e:
            montblanc.log.exception("Compute Exception")
            raise
1235960
def calculate_keys_by_mapreduce_state(cls, mapreduce_state):
    
    if mapreduce_state is None:
      return []

    keys = []
    for i in range(mapreduce_state.mapreduce_spec.mapper.shard_count):
      shard_id = cls.shard_id_from_number(mapreduce_state.key().name(), i)
      keys.append(cls.get_key_by_shard_id(shard_id))
    return keys
1027958
public function getLastVersionNumber($con = null)
    {
        $v = ChildDealerBrandVersionQuery::create()
            ->filterByDealerBrand($this)
            ->orderByVersion('desc')
            ->findOne($con);
        if (!$v) {
            return 0;
        }

        return $v->getVersion();
    }
1035444
public ShardInformation getShardInformation(String shard) {
    ShardInformation shardInformation = shardIndex.get(Objects.requireNonNull(shard, "shard required"));
    if (shardInformation == null) {
      shardInformation = createShardInformation(shard);
    }
    return shardInformation;
  }
801380
@VisibleForTesting
	static String constructCounterShardIdentifier(final String counterName, final int shardNumber)
	{
		Preconditions.checkNotNull(counterName);
		Preconditions.checkArgument(!StringUtils.isBlank(counterName),
			"CounterData Names may not be null, blank, or empty!");
		Preconditions.checkArgument(shardNumber >= 0, "shardNumber must be greater than or equal to 0!");

		return counterName + COUNTER_SHARD_KEY_SEPARATOR + shardNumber;
	}
129668
function getAccountInfoByUid($uid)
    {
        $response = $this->call( new Command\AccountInfo($uid, Command\AccountInfo::TYPE_UID) );
        if ( $ex = $response->hasException() )
            throw $ex;

        $r = $response->expected();
        $r = ($r instanceof iDataEntity) ? $r->get('result') : $r;
        return $r;
    }
1175768
def _split_one_shard_to_multiple(client, project, logstore, shard_info, count, current_shard_count):
    
    distance = shard_info['length'] // count
    if distance <= 0 or count <= 1:
        return [shard_info['info']], 0

    rw_shards, increased_shard_count = {shard_info['id']: shard_info['info']}, 0
    for x in range(1, count):
        new_hash = shard_info['start'] + distance * x
        new_hash = hex(new_hash)[2:].strip('lL')
        new_hash = '0' * (TOTAL_HASH_LENGTH - len(new_hash)) + new_hash
        try:
            if x == 1:
                res = client.split_shard(project, logstore, shard_info['id'], new_hash)
            else:
                res = client.split_shard(project, logstore, current_shard_count - 1, new_hash)

            # new rw_shards
            for shard in res.shards:
                if shard['status'] == 'readonly':
                    del rw_shards[shard['shardID']]
                else:
                    rw_shards[shard['shardID']] = shard

            current_shard_count += res.count - 1
            increased_shard_count += res.count - 1
            logger.info("split shard: project={0}, logstore={1}, shard_info={2}, count={3}, current_shard_count={4}".format(project, logstore, shard_info, count, current_shard_count))
        except Exception as ex:
            print(ex)
            print(x, project, logstore, shard_info, count, current_shard_count)
            raise

    return rw_shards.values(), increased_shard_count
1339495
protected function getInitialShardIterator($shard_id, $starting_sequence_number = NULL)
    {

        $args = [
            'ShardId' => $shard_id,
            'StreamName' => $this->getStreamName(),
            'ShardIteratorType' => $this->initialShardIteratorType,
        ];

        // If we have the starting sequence number update also the ShardIteratorType
        // to start reading just after it.
        if (!empty($starting_sequence_number)) {
            $args['ShardIteratorType'] = self::ITERATOR_TYPE_AFTER_SEQUENCE_NUMBER;
            $args['StartingSequenceNumber'] = $starting_sequence_number;
        }

        $res = $this->getClient()->getShardIterator($args);

        return $res->get('ShardIterator');
    }