<commit_before><?php

namespace Maghead\Sharding;

use Maghead\Sharding\Shard;
use Maghead\Schema\BaseSchema;

class ShardStatsCollector
{
    protected $shards;

    public function __construct(ShardCollection $shards)
    {
        $this->shards = $shards;
    }

    public function collect(BaseSchema $schema)
    {
        $stats = [];
        $repoClass = $schema->getRepoClass();
        foreach ($this->shards as $shard) {
            $repo = $shard->repo($repoClass);
            $startTime = microtime(true);
            $stats[$shard->id]['rows'] = count($repo);
            $stats[$shard->id]['queryTime'] = microtime(true) - $startTime;
            // TODO: query table/index stats
        }
        return $stats;
    }
}<commit_msg>fetch shard keys in ShardStatsCollector<commit_after><?php

namespace Maghead\Sharding;

use Maghead\Sharding\Shard;
use Maghead\Schema\BaseSchema;

class ShardStatsCollector
{
    protected $shards;

    public function __construct(ShardCollection $shards)
    {
        $this->shards = $shards;
    }

    public function collect(BaseSchema $schema)
    {
        $stats = [];
        $repoClass = $schema->getRepoClass();
        foreach ($this->shards as $shard) {
            $repo = $shard->repo($repoClass);
            $startTime = microtime(true);
            $stats[$shard->id]['rows'] = count($repo);
            $stats[$shard->id]['queryTime'] = microtime(true) - $startTime;
            $stats[$shard->id]['keys'] = $repo->fetchShardKeys();
            // TODO: query table/index stats
        }
        return $stats;
    }
}
{'fraction_non_alphanumeric': 0.14312736443883986, 'fraction_numerical': 0.0, 'mean_word_length': 2.495594713656388, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4722568', 'n_tokens_mistral': 487, 'n_tokens_neox': 485, 'n_words': 92}