├── data ├── .gitignore └── list_of_expired_passports.50k.csv.bz2 ├── .gitignore ├── src ├── Storage │ ├── Pilosa │ │ ├── Proto │ │ │ ├── GPBMetadata │ │ │ │ └── PBPublic.php │ │ │ ├── TranslateKeysResponse.php │ │ │ ├── AttrMap.php │ │ │ ├── ValCount.php │ │ │ ├── ImportRoaringRequestView.php │ │ │ ├── GroupCount.php │ │ │ ├── RowIdentifiers.php │ │ │ ├── ImportRoaringRequest.php │ │ │ ├── Pair.php │ │ │ ├── FieldRow.php │ │ │ ├── TranslateKeysRequest.php │ │ │ ├── ColumnAttrSet.php │ │ │ ├── Row.php │ │ │ ├── QueryResponse.php │ │ │ ├── Attr.php │ │ │ ├── QueryRequest.php │ │ │ ├── ImportValueRequest.php │ │ │ ├── ImportRequest.php │ │ │ └── QueryResult.php │ │ └── public.proto │ ├── Item.php │ ├── ItemStorageInterface.php │ ├── Redis │ │ └── RedisFactory.php │ ├── FileItemStorage.php │ ├── RedisItemStorage.php │ └── PilosaItemStorage.php ├── Stream │ ├── ItemGeneratorInterface.php │ ├── LineGeneratorInterface.php │ ├── ItemLineGenerator.php │ ├── ValidateLineGenerator.php │ ├── DecompressStream.php │ └── StreamLineGenerator.php ├── Status │ ├── Status.php │ ├── StatusStorageInterface.php │ ├── DummyStatusStorage.php │ ├── FileStatusStorage.php │ └── RedisStatusStorage.php ├── Source │ ├── SourceInterface.php │ ├── FileSource.php │ └── HttpSource.php ├── Service │ ├── Server.php │ └── Updater.php └── bootstrap.php ├── .dockerignore ├── public └── index.php ├── bin ├── update.php └── start.php ├── psalm.xml.dist ├── docker-compose.yml ├── docker ├── haproxy │ └── haproxy.cfg └── php │ └── Dockerfile ├── phpunit.xml.dist ├── composer.json ├── LICENSE ├── README.md ├── config └── config.php ├── .php_cs └── tests └── integration └── UpdateTest.php /data/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | composer.phar 2 | var 3 | vendor 4 | .idea/ 5 | .data/ 6 | .php_cs.cache 7 | .phpunit.result.cache 8 | psalm.xml 9 | -------------------------------------------------------------------------------- /data/list_of_expired_passports.50k.csv.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maurokouti/passport-control/HEAD/data/list_of_expired_passports.50k.csv.bz2 -------------------------------------------------------------------------------- /src/Storage/Pilosa/Proto/GPBMetadata/PBPublic.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maurokouti/passport-control/HEAD/src/Storage/Pilosa/Proto/GPBMetadata/PBPublic.php -------------------------------------------------------------------------------- /src/Stream/ItemGeneratorInterface.php: -------------------------------------------------------------------------------- 1 | get(\App\Service\Server::class); 8 | $request = GuzzleHttp\Psr7\ServerRequest::fromGlobals(); 9 | $response = $server->handle($request); 10 | 11 | echo $response->getBody(); 12 | -------------------------------------------------------------------------------- /src/Storage/Item.php: -------------------------------------------------------------------------------- 1 | series, $this->number); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /bin/update.php: -------------------------------------------------------------------------------- 1 | start();; 12 | 13 | // run 14 | $container->get(Updater::class)->run(); 15 | 16 | $duration = $timer->stop(); 17 | $container->get(\Psr\Log\LoggerInterface::class) 18 | ->info(sprintf('Update finished. Time: %s', $duration->asString())); 19 | -------------------------------------------------------------------------------- /src/Status/StatusStorageInterface.php: -------------------------------------------------------------------------------- 1 | $items 11 | * @return int Number of stored items 12 | */ 13 | public function updateItems(iterable $items): int; 14 | 15 | /** 16 | * @param iterable|iterable $items 17 | * @return array 18 | */ 19 | public function getItems(iterable $items): array; 20 | } 21 | -------------------------------------------------------------------------------- /psalm.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Storage/Redis/RedisFactory.php: -------------------------------------------------------------------------------- 1 | connect($host, $port); 18 | 19 | if ($password) { 20 | $redis->auth($password); 21 | } 22 | 23 | return $redis; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /bin/start.php: -------------------------------------------------------------------------------- 1 | get(Server::class); 11 | 12 | Worker::$pidFile = '/dev/null'; 13 | Worker::$logFile = '/dev/null'; 14 | 15 | $httpWorker = new Worker(sprintf( 16 | 'http://%s:%d', 17 | $container->get('http.address'), 18 | $container->get('http.port'), 19 | )); 20 | $httpWorker->count = 8; 21 | $httpWorker->onMessage = [$server, 'onMessage']; 22 | 23 | Worker::runAll(); 24 | -------------------------------------------------------------------------------- /src/Source/SourceInterface.php: -------------------------------------------------------------------------------- 1 | 0]; 19 | 20 | foreach ($this->lines as $line) { 21 | [$series, $number] = explode(',', $line); 22 | yield new Item($series, $number); 23 | $result['processed']++; 24 | } 25 | 26 | return $result; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.7' 2 | 3 | services: 4 | redis: 5 | image: redis:latest 6 | networks: 7 | - redis_network 8 | app: 9 | build: 10 | context: . 11 | dockerfile: ./docker/php/Dockerfile 12 | depends_on: 13 | - redis 14 | # volumes: 15 | # - ./:/app 16 | environment: 17 | - REDIS_HOST=redis 18 | - REDIS_PORT=6379 19 | - SOURCE_HTTP_URL=http://guvm.mvd.ru/upload/expired-passports/list_of_expired_passports.csv.bz2 20 | networks: 21 | - redis_network 22 | - app_network 23 | 24 | haproxy: 25 | image: haproxy:2.3 26 | volumes: 27 | - ./docker/haproxy/:/usr/local/etc/haproxy:ro 28 | depends_on: 29 | - app 30 | networks: 31 | - app_network 32 | ports: 33 | - "8080:8080" 34 | 35 | networks: 36 | redis_network: 37 | app_network: 38 | -------------------------------------------------------------------------------- /src/Stream/ValidateLineGenerator.php: -------------------------------------------------------------------------------- 1 | 0, 20 | 'ignored' => 0, 21 | ]; 22 | 23 | foreach ($this->lines as $line) { 24 | $result['processed']++; 25 | 26 | if (!preg_match(self::VALID_LINE_REGEXP, $line)) { 27 | $result['ignored']++; 28 | 29 | continue; 30 | } 31 | 32 | yield $line; 33 | } 34 | 35 | return $result; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /docker/haproxy/haproxy.cfg: -------------------------------------------------------------------------------- 1 | global 2 | log 127.0.0.1 local0 debug 3 | user root 4 | group root 5 | 6 | defaults 7 | mode http 8 | log global 9 | option httplog 10 | option dontlognull 11 | option http-server-close 12 | option forwardfor except 127.0.0.0/8 13 | option redispatch 14 | retries 3 15 | timeout http-request 10s 16 | timeout queue 1m 17 | timeout connect 10s 18 | timeout client 1m 19 | timeout server 1m 20 | timeout http-keep-alive 10s 21 | timeout check 10s 22 | maxconn 3000 23 | 24 | frontend main 25 | bind *:8080 26 | 27 | default_backend app 28 | 29 | backend app 30 | server app app:8080 maxconn 8 31 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | tests/ 18 | 19 | 20 | 21 | 22 | 23 | ./src/ 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/Status/FileStatusStorage.php: -------------------------------------------------------------------------------- 1 | path)) { 17 | return new Status(); 18 | } 19 | 20 | $decodedStatus = \json_decode( 21 | file_get_contents($this->path), 22 | ); 23 | 24 | return new Status( 25 | lastUpdate: $decodedStatus->lastUpdate, 26 | items: $decodedStatus->items, 27 | ); 28 | } 29 | 30 | public function setStatus(Status $status): void 31 | { 32 | file_put_contents( 33 | $this->path, 34 | \json_encode($status), 35 | ); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "maurokouti/passport-control", 3 | "license": "MIT", 4 | "authors": [ 5 | { 6 | "name": "Mauro Kouti", 7 | "email": "maurokouti@protonmail.com" 8 | } 9 | ], 10 | "require": { 11 | "php": "^8.0", 12 | "guzzlehttp/guzzle": "^7.2", 13 | "guzzlehttp/psr7": "1.7.0", 14 | "google/protobuf": "~3.14", 15 | "ext-curl": "*", 16 | "ext-json": "*", 17 | "ext-bz2": "*", 18 | "ext-redis": "*", 19 | "psr/log": "^1.1", 20 | "monolog/monolog": "^2.2", 21 | "php-di/php-di": "^6.3", 22 | "phpunit/php-timer": "^5.0", 23 | "workerman/workerman": "^4.0" 24 | }, 25 | "require-dev": { 26 | "vimeo/psalm": "~4.4", 27 | "psalm/plugin-phpunit": "~0.15", 28 | "phpunit/phpunit": "^9.5", 29 | "friendsofphp/php-cs-fixer": "^2.18" 30 | }, 31 | "autoload": { 32 | "psr-4": { 33 | "App\\": "src/" 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /docker/php/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8-cli 2 | 3 | RUN apt-get update && apt-get install -y libbz2-dev libssl-dev libcurl4-openssl-dev libzip-dev libevent-dev \ 4 | && docker-php-ext-install sockets \ 5 | && sockets_ini=$(php -i | grep -m 1 -o -E '/.*sockets\.ini') && test -z "$sockets_ini" || mv -v "$sockets_ini" "$(echo "$sockets_ini" | sed -e 's/sockets.ini/0-sockets.ini/')" \ 6 | && pecl install event-3.0.2 \ 7 | && docker-php-ext-enable event \ 8 | && docker-php-ext-install bz2 pcntl zip \ 9 | && pecl install redis \ 10 | && docker-php-ext-enable redis \ 11 | && apt-get clean autoclean \ 12 | && apt-get autoremove --yes \ 13 | && rm -rf /var/lib/{apt,dpkg,cache,log}/ 14 | 15 | COPY --from=composer:2 /usr/bin/composer /usr/bin/composer 16 | 17 | WORKDIR /app 18 | 19 | COPY . . 20 | 21 | RUN mkdir -p var/cache && chmod -R 777 var/cache \ 22 | && composer install --prefer-dist --no-dev --no-progress --no-scripts --no-interaction \ 23 | && composer dump-autoload --classmap-authoritative --no-dev 24 | 25 | CMD php /app/bin/start.php start -------------------------------------------------------------------------------- /src/Status/RedisStatusStorage.php: -------------------------------------------------------------------------------- 1 | redis->select($this->statusDb); 22 | $status = $this->redis->hMGet(self::KEY_STATUS, ['lastUpdate', 'items']); 23 | 24 | return new Status( 25 | lastUpdate: (int) ($status['lastUpdate'] ?: 0), 26 | items: (int) ($status['items'] ?: 0), 27 | ); 28 | } 29 | 30 | public function setStatus(Status $status): void 31 | { 32 | $this->redis->select($this->statusDb); 33 | $this->redis->hMSet(self::KEY_STATUS, [ 34 | 'lastUpdate' => $status->lastUpdate, 35 | 'items' => $status->items, 36 | ]); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Mauro Kouti 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Passport control 2 | 3 | This service is to check a batch of passport series and numbers against a list of expired and non-valid passports. 4 | 5 | For more information see 6 | [http://сервисы.гувм.мвд.рф/info-service.htm?sid=2000](http://xn--b1afk4ade4e.xn--b1ab2a0a.xn--b1aew.xn--p1ai/info-service.htm?sid=2000). 7 | 8 | ## Usage 9 | 10 | ```shell 11 | git clone https://github.com/maurokouti/passport-control.git 12 | cd ./passport-control 13 | docker-compose up -d 14 | ``` 15 | 16 | ### Update a dataset 17 | ```shell 18 | docker-compose exec app php bin/update.php 19 | ``` 20 | 21 | ### Make a request 22 | 23 | The service accepts HTTP requests with the body in CSV format: 24 | ```shell 25 | curl -iv http://127.0.0.1:8080/ --data-binary @- << END 26 | 1234,123456 27 | 5411,222110 28 | 4321,654321 29 | 3211,053785 30 | END 31 | ``` 32 | 33 | ### Response format 34 | 35 | The service replies with the series and number found in the list. 36 | 37 | ``` 38 | 5411,222110 39 | 3211,053785 40 | ``` 41 | 42 | `204 No Content` code is returned when nothing was found. 43 | 44 | ## License 45 | 46 | The MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information. -------------------------------------------------------------------------------- /src/Stream/DecompressStream.php: -------------------------------------------------------------------------------- 1 | false]); 30 | $this->stream = $stream->isSeekable() ? new Stream($resource) : new NoSeekStream(new Stream($resource)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Source/FileSource.php: -------------------------------------------------------------------------------- 1 | path)) { 17 | throw new \Exception('File not found ' . $this->path); 18 | } 19 | } 20 | 21 | /** 22 | * @inheritdoc 23 | * @throws \Exception 24 | */ 25 | public function getStream(): StreamInterface 26 | { 27 | $fileHandler = fopen($this->path, 'rb'); 28 | $fileStream = Utils::streamFor($fileHandler); 29 | 30 | return new DecompressStream($fileStream); 31 | } 32 | 33 | /** 34 | * @inheritdoc 35 | */ 36 | public function getDescription(): string 37 | { 38 | return sprintf('File source %s', $this->path); 39 | } 40 | 41 | /** 42 | * @inheritdoc 43 | * @throws \Exception 44 | */ 45 | public function getLastUpdate(): int 46 | { 47 | return filemtime($this->path); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /config/config.php: -------------------------------------------------------------------------------- 1 | \DI\env('REDIS_HOST', 'redis'), 8 | 'redis.port' => \DI\env('REDIS_PORT', 6379), 9 | 'redis.password' => \DI\env('REDIS_PASSWORD', null), 10 | // status 11 | 'status.type' => 'redis', // dummy|file|redis 12 | 'status.file.path' => \DI\env('STATUS_FILE_PATH', __DIR__ . '/../var/status.json'), 13 | 'status.redis.db' => \DI\env('STATUS_REDIS_DB', 0), 14 | // source 15 | 'source.type' => 'http', // file|http 16 | 'source.file.path' => \DI\env('SOURCE_FILE_PATH', __DIR__ . '/../data/list_of_expired_passports.50k.csv.bz2'), 17 | 'source.http.url' => \DI\env('SOURCE_HTTP_URL', 'http://guvm.mvd.ru/upload/expired-passports/list_of_expired_passports.csv.bz2'), 18 | // storage 19 | 'storage.type' => 'redis', // redis|file|pilosa 20 | 'storage.redis.primary_db' => \DI\env('STORAGE_REDIS_PRIMARY_DB', 1), 21 | 'storage.redis.temporary_db' => \DI\env('STORAGE_REDIS_TEMPORARY_DB', 2), 22 | 'storage.redis.bath_size' => \DI\env('STORAGE_REDIS_BATCH_SIZE', 50000), 23 | // http server 24 | 'http.address' => \DI\env('HTTP_ADDRESS', '0.0.0.0'), 25 | 'http.port' => \DI\env('HTTP_PORT', 8080), 26 | ]; 27 | -------------------------------------------------------------------------------- /src/Stream/StreamLineGenerator.php: -------------------------------------------------------------------------------- 1 | 0, 21 | 'ignored' => 0, 22 | ]; 23 | 24 | $buffer = ''; 25 | while (!$this->stream->eof()) { 26 | $buffer .= $this->stream->read($this->bufferSize); 27 | $chunks = preg_split('~\r?\n~', $buffer); 28 | 29 | // last chunk may have incomplete line 30 | for ($i = 0; $i < count($chunks) - 1; $i++) { 31 | $result['processed']++; 32 | yield $chunks[$i]; 33 | } 34 | $buffer = $chunks[array_key_last($chunks)]; 35 | } 36 | 37 | // yield the buffer with the last chunk 38 | if (!empty($buffer)) { 39 | $result['processed']++; 40 | yield $buffer; 41 | } 42 | 43 | return $result; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Source/HttpSource.php: -------------------------------------------------------------------------------- 1 | request('GET', $this->url, [ 23 | 'verify' => false, 24 | 'stream' => true, 25 | ]); 26 | 27 | $statusCode = $response->getStatusCode(); 28 | if ($statusCode != 200) { 29 | throw new \Exception('Bad HTTP status code ' . $statusCode); 30 | } 31 | 32 | return new DecompressStream($response->getBody()); 33 | } 34 | 35 | /** 36 | * @inheritdoc 37 | */ 38 | public function getDescription(): string 39 | { 40 | return sprintf('HTTP source %s', $this->url); 41 | } 42 | 43 | public function getLastUpdate(): int 44 | { 45 | $client = new Client(); 46 | $response = $client->request('HEAD', $this->url, [ 47 | 'verify' => false, 48 | ]); 49 | $lastModifiedHeader = $response->getHeader('Last-Modified')[0] ?? '0'; 50 | 51 | return strtotime($lastModifiedHeader); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Storage/FileItemStorage.php: -------------------------------------------------------------------------------- 1 | filename . '.new'; 23 | $fileHandler = fopen($tempFilename, 'w'); 24 | /** @var Item $item */ 25 | foreach ($items as $item) { 26 | $line = implode(',', [$item->series, $item->number]); 27 | $res = fputs($fileHandler, $line . PHP_EOL); 28 | if ($res === false) { 29 | throw new \Exception('Failed to write file ' . $tempFilename); 30 | } 31 | $counter++; 32 | } 33 | fclose($fileHandler); 34 | rename($tempFilename, $this->filename); 35 | 36 | return $counter; 37 | } 38 | 39 | public function getItems(iterable $items): array 40 | { 41 | if (!file_exists($this->filename)) { 42 | throw new \Exception('Failed to init file items storage. File not found. ' . $this->filename); 43 | } 44 | 45 | throw new \Exception('Method getItems is not implemented for File storage'); 46 | 47 | return []; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /.php_cs: -------------------------------------------------------------------------------- 1 | exclude('vendor') 4 | ->exclude('var') 5 | ->exclude('src/Storage/Pilosa/Proto') 6 | ->in(__DIR__); 7 | 8 | return PhpCsFixer\Config::create() 9 | ->setRules([ 10 | 'concat_space' => ['spacing' => 'one'], 11 | 'declare_equal_normalize' => ['space' => 'none'], 12 | 'is_null' => true, 13 | 'modernize_types_casting' => true, 14 | 'php_unit_construct' => true, 15 | 'single_line_comment_style' => true, 16 | 'yoda_style' => false, 17 | '@PSR2' => true, 18 | 'array_syntax' => ['syntax' => 'short'], 19 | 'blank_line_after_opening_tag' => true, 20 | 'blank_line_before_return' => true, 21 | 'blank_line_before_statement' => true, 22 | 'cast_spaces' => true, 23 | 'declare_strict_types' => true, 24 | 'function_typehint_space' => true, 25 | 'include' => true, 26 | 'lowercase_cast' => true, 27 | 'new_with_braces' => true, 28 | 'no_extra_consecutive_blank_lines' => true, 29 | 'no_leading_import_slash' => true, 30 | 'no_short_echo_tag' => true, 31 | 'no_unused_imports' => true, 32 | 'no_useless_else' => true, 33 | 'no_useless_return' => true, 34 | 'ordered_imports' => true, 35 | 'phpdoc_order' => true, 36 | 'phpdoc_scalar' => true, 37 | 'phpdoc_types' => true, 38 | 'short_scalar_cast' => true, 39 | 'single_blank_line_before_namespace' => true, 40 | 'single_quote' => true, 41 | 'trailing_comma_in_multiline_array' => true, 42 | ]) 43 | ->setRiskyAllowed(true) 44 | ->setFinder($finder); 45 | -------------------------------------------------------------------------------- /src/Storage/Pilosa/Proto/TranslateKeysResponse.php: -------------------------------------------------------------------------------- 1 | TranslateKeysResponse 13 | */ 14 | class TranslateKeysResponse extends \Google\Protobuf\Internal\Message 15 | { 16 | /** 17 | * Generated from protobuf field repeated uint64 IDs = 3; 18 | */ 19 | private $IDs; 20 | 21 | /** 22 | * Constructor. 23 | * 24 | * @param array $data { 25 | * Optional. Data for populating the Message object. 26 | * 27 | * @type int[]|string[]|\Google\Protobuf\Internal\RepeatedField $IDs 28 | * } 29 | */ 30 | public function __construct($data = NULL) { 31 | \App\Storage\Pilosa\Proto\GPBMetadata\PBPublic::initOnce(); 32 | parent::__construct($data); 33 | } 34 | 35 | /** 36 | * Generated from protobuf field repeated uint64 IDs = 3; 37 | * @return \Google\Protobuf\Internal\RepeatedField 38 | */ 39 | public function getIDs() 40 | { 41 | return $this->IDs; 42 | } 43 | 44 | /** 45 | * Generated from protobuf field repeated uint64 IDs = 3; 46 | * @param int[]|string[]|\Google\Protobuf\Internal\RepeatedField $var 47 | * @return $this 48 | */ 49 | public function setIDs($var) 50 | { 51 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::UINT64); 52 | $this->IDs = $arr; 53 | 54 | return $this; 55 | } 56 | 57 | } 58 | 59 | -------------------------------------------------------------------------------- /src/Storage/Pilosa/Proto/AttrMap.php: -------------------------------------------------------------------------------- 1 | AttrMap 13 | */ 14 | class AttrMap extends \Google\Protobuf\Internal\Message 15 | { 16 | /** 17 | * Generated from protobuf field repeated .Attr Attrs = 1; 18 | */ 19 | private $Attrs; 20 | 21 | /** 22 | * Constructor. 23 | * 24 | * @param array $data { 25 | * Optional. Data for populating the Message object. 26 | * 27 | * @type \App\Storage\Pilosa\Proto\Attr[]|\Google\Protobuf\Internal\RepeatedField $Attrs 28 | * } 29 | */ 30 | public function __construct($data = NULL) { 31 | \App\Storage\Pilosa\Proto\GPBMetadata\PBPublic::initOnce(); 32 | parent::__construct($data); 33 | } 34 | 35 | /** 36 | * Generated from protobuf field repeated .Attr Attrs = 1; 37 | * @return \Google\Protobuf\Internal\RepeatedField 38 | */ 39 | public function getAttrs() 40 | { 41 | return $this->Attrs; 42 | } 43 | 44 | /** 45 | * Generated from protobuf field repeated .Attr Attrs = 1; 46 | * @param \App\Storage\Pilosa\Proto\Attr[]|\Google\Protobuf\Internal\RepeatedField $var 47 | * @return $this 48 | */ 49 | public function setAttrs($var) 50 | { 51 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \App\Storage\Pilosa\Proto\Attr::class); 52 | $this->Attrs = $arr; 53 | 54 | return $this; 55 | } 56 | 57 | } 58 | 59 | -------------------------------------------------------------------------------- /src/Service/Server.php: -------------------------------------------------------------------------------- 1 | handle($request); 29 | } catch (\Exception) { 30 | $response = new Response(500); 31 | } finally { 32 | $connection->send($response); 33 | $connection->close(); 34 | } 35 | } 36 | 37 | private function handle(Request $request): Response 38 | { 39 | $body = $request->rawBody(); 40 | $lines = preg_split('~\r?\n~', $body); 41 | 42 | if (count($lines) > $this->maxInputSize) { 43 | return new Response(413, [], sprintf('Max input size %d', $this->maxInputSize)); 44 | } 45 | 46 | // read source stream and extract single lines 47 | $parsedLines = (new StreamLineGenerator(Utils::streamFor($body)))->getLines(); 48 | // validate lines 49 | $validLines = (new ValidateLineGenerator($parsedLines))->getLines(); 50 | // extract series, number values from the string line 51 | $items = (new ItemLineGenerator($validLines))->getItems(); 52 | 53 | // get items from storage 54 | $result = $this->storage->getItems($items); 55 | 56 | if (count($result) == 0) { 57 | return new Response(204); 58 | } 59 | 60 | $responseBody = implode("\r\n", array_map(fn (Item $r) => sprintf('%s,%s', $r->series, $r->number), $result)); 61 | 62 | return new Response(200, [], $responseBody); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/Storage/RedisItemStorage.php: -------------------------------------------------------------------------------- 1 | redis->select($this->temporaryDb); 25 | $this->redis->multi(Redis::PIPELINE); 26 | 27 | $counter = 0; 28 | $bufferCounter = 0; 29 | foreach ($items as $item) { 30 | $this->redis->setBit($item->series, (int) $item->number, true); 31 | $bufferCounter++; 32 | $counter++; 33 | 34 | if ($bufferCounter > $this->batchSize) { 35 | $this->redis->exec(); 36 | $this->redis->multi(Redis::PIPELINE); 37 | $bufferCounter = 0; 38 | } 39 | } 40 | // flush the rest 41 | $this->redis->exec(); 42 | 43 | // rotate DBs 44 | if ($this->redis->swapdb($this->primaryDb, $this->temporaryDb)) { 45 | $this->redis->select($this->temporaryDb); // explicitly select temporary DB 46 | $this->redis->flushDb(); 47 | } 48 | 49 | return $counter; 50 | } 51 | 52 | /** 53 | * @inheritdoc 54 | */ 55 | public function getItems(iterable $items): array 56 | { 57 | $buffer = []; 58 | $this->redis->select($this->primaryDb); 59 | $this->redis->multi(Redis::PIPELINE); 60 | 61 | foreach ($items as $item) { 62 | $buffer[] = $item; 63 | $this->redis->getBit($item->series, (int) $item->number); 64 | } 65 | 66 | $response = $this->redis->exec(); 67 | $result = []; 68 | foreach ($response as $index => $bitSet) { 69 | if ($bitSet === 1) { 70 | $result[] = $buffer[$index]; 71 | } 72 | } 73 | 74 | return $result; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/Storage/Pilosa/Proto/ValCount.php: -------------------------------------------------------------------------------- 1 | ValCount 13 | */ 14 | class ValCount extends \Google\Protobuf\Internal\Message 15 | { 16 | /** 17 | * Generated from protobuf field int64 Val = 1; 18 | */ 19 | protected $Val = 0; 20 | /** 21 | * Generated from protobuf field int64 Count = 2; 22 | */ 23 | protected $Count = 0; 24 | 25 | /** 26 | * Constructor. 27 | * 28 | * @param array $data { 29 | * Optional. Data for populating the Message object. 30 | * 31 | * @type int|string $Val 32 | * @type int|string $Count 33 | * } 34 | */ 35 | public function __construct($data = NULL) { 36 | \App\Storage\Pilosa\Proto\GPBMetadata\PBPublic::initOnce(); 37 | parent::__construct($data); 38 | } 39 | 40 | /** 41 | * Generated from protobuf field int64 Val = 1; 42 | * @return int|string 43 | */ 44 | public function getVal() 45 | { 46 | return $this->Val; 47 | } 48 | 49 | /** 50 | * Generated from protobuf field int64 Val = 1; 51 | * @param int|string $var 52 | * @return $this 53 | */ 54 | public function setVal($var) 55 | { 56 | GPBUtil::checkInt64($var); 57 | $this->Val = $var; 58 | 59 | return $this; 60 | } 61 | 62 | /** 63 | * Generated from protobuf field int64 Count = 2; 64 | * @return int|string 65 | */ 66 | public function getCount() 67 | { 68 | return $this->Count; 69 | } 70 | 71 | /** 72 | * Generated from protobuf field int64 Count = 2; 73 | * @param int|string $var 74 | * @return $this 75 | */ 76 | public function setCount($var) 77 | { 78 | GPBUtil::checkInt64($var); 79 | $this->Count = $var; 80 | 81 | return $this; 82 | } 83 | 84 | } 85 | 86 | -------------------------------------------------------------------------------- /src/Storage/Pilosa/Proto/ImportRoaringRequestView.php: -------------------------------------------------------------------------------- 1 | ImportRoaringRequestView 13 | */ 14 | class ImportRoaringRequestView extends \Google\Protobuf\Internal\Message 15 | { 16 | /** 17 | * Generated from protobuf field string Name = 1; 18 | */ 19 | protected $Name = ''; 20 | /** 21 | * Generated from protobuf field bytes Data = 2; 22 | */ 23 | protected $Data = ''; 24 | 25 | /** 26 | * Constructor. 27 | * 28 | * @param array $data { 29 | * Optional. Data for populating the Message object. 30 | * 31 | * @type string $Name 32 | * @type string $Data 33 | * } 34 | */ 35 | public function __construct($data = NULL) { 36 | \App\Storage\Pilosa\Proto\GPBMetadata\PBPublic::initOnce(); 37 | parent::__construct($data); 38 | } 39 | 40 | /** 41 | * Generated from protobuf field string Name = 1; 42 | * @return string 43 | */ 44 | public function getName() 45 | { 46 | return $this->Name; 47 | } 48 | 49 | /** 50 | * Generated from protobuf field string Name = 1; 51 | * @param string $var 52 | * @return $this 53 | */ 54 | public function setName($var) 55 | { 56 | GPBUtil::checkString($var, True); 57 | $this->Name = $var; 58 | 59 | return $this; 60 | } 61 | 62 | /** 63 | * Generated from protobuf field bytes Data = 2; 64 | * @return string 65 | */ 66 | public function getData() 67 | { 68 | return $this->Data; 69 | } 70 | 71 | /** 72 | * Generated from protobuf field bytes Data = 2; 73 | * @param string $var 74 | * @return $this 75 | */ 76 | public function setData($var) 77 | { 78 | GPBUtil::checkString($var, False); 79 | $this->Data = $var; 80 | 81 | return $this; 82 | } 83 | 84 | } 85 | 86 | -------------------------------------------------------------------------------- /src/Storage/Pilosa/Proto/GroupCount.php: -------------------------------------------------------------------------------- 1 | GroupCount 13 | */ 14 | class GroupCount extends \Google\Protobuf\Internal\Message 15 | { 16 | /** 17 | * Generated from protobuf field repeated .FieldRow Group = 1; 18 | */ 19 | private $Group; 20 | /** 21 | * Generated from protobuf field uint64 Count = 2; 22 | */ 23 | protected $Count = 0; 24 | 25 | /** 26 | * Constructor. 27 | * 28 | * @param array $data { 29 | * Optional. Data for populating the Message object. 30 | * 31 | * @type \App\Storage\Pilosa\Proto\FieldRow[]|\Google\Protobuf\Internal\RepeatedField $Group 32 | * @type int|string $Count 33 | * } 34 | */ 35 | public function __construct($data = NULL) { 36 | \App\Storage\Pilosa\Proto\GPBMetadata\PBPublic::initOnce(); 37 | parent::__construct($data); 38 | } 39 | 40 | /** 41 | * Generated from protobuf field repeated .FieldRow Group = 1; 42 | * @return \Google\Protobuf\Internal\RepeatedField 43 | */ 44 | public function getGroup() 45 | { 46 | return $this->Group; 47 | } 48 | 49 | /** 50 | * Generated from protobuf field repeated .FieldRow Group = 1; 51 | * @param \App\Storage\Pilosa\Proto\FieldRow[]|\Google\Protobuf\Internal\RepeatedField $var 52 | * @return $this 53 | */ 54 | public function setGroup($var) 55 | { 56 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \App\Storage\Pilosa\Proto\FieldRow::class); 57 | $this->Group = $arr; 58 | 59 | return $this; 60 | } 61 | 62 | /** 63 | * Generated from protobuf field uint64 Count = 2; 64 | * @return int|string 65 | */ 66 | public function getCount() 67 | { 68 | return $this->Count; 69 | } 70 | 71 | /** 72 | * Generated from protobuf field uint64 Count = 2; 73 | * @param int|string $var 74 | * @return $this 75 | */ 76 | public function setCount($var) 77 | { 78 | GPBUtil::checkUint64($var); 79 | $this->Count = $var; 80 | 81 | return $this; 82 | } 83 | 84 | } 85 | 86 | -------------------------------------------------------------------------------- /src/Storage/Pilosa/Proto/RowIdentifiers.php: -------------------------------------------------------------------------------- 1 | RowIdentifiers 13 | */ 14 | class RowIdentifiers extends \Google\Protobuf\Internal\Message 15 | { 16 | /** 17 | * Generated from protobuf field repeated uint64 Rows = 1; 18 | */ 19 | private $Rows; 20 | /** 21 | * Generated from protobuf field repeated string Keys = 2; 22 | */ 23 | private $Keys; 24 | 25 | /** 26 | * Constructor. 27 | * 28 | * @param array $data { 29 | * Optional. Data for populating the Message object. 30 | * 31 | * @type int[]|string[]|\Google\Protobuf\Internal\RepeatedField $Rows 32 | * @type string[]|\Google\Protobuf\Internal\RepeatedField $Keys 33 | * } 34 | */ 35 | public function __construct($data = NULL) { 36 | \App\Storage\Pilosa\Proto\GPBMetadata\PBPublic::initOnce(); 37 | parent::__construct($data); 38 | } 39 | 40 | /** 41 | * Generated from protobuf field repeated uint64 Rows = 1; 42 | * @return \Google\Protobuf\Internal\RepeatedField 43 | */ 44 | public function getRows() 45 | { 46 | return $this->Rows; 47 | } 48 | 49 | /** 50 | * Generated from protobuf field repeated uint64 Rows = 1; 51 | * @param int[]|string[]|\Google\Protobuf\Internal\RepeatedField $var 52 | * @return $this 53 | */ 54 | public function setRows($var) 55 | { 56 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::UINT64); 57 | $this->Rows = $arr; 58 | 59 | return $this; 60 | } 61 | 62 | /** 63 | * Generated from protobuf field repeated string Keys = 2; 64 | * @return \Google\Protobuf\Internal\RepeatedField 65 | */ 66 | public function getKeys() 67 | { 68 | return $this->Keys; 69 | } 70 | 71 | /** 72 | * Generated from protobuf field repeated string Keys = 2; 73 | * @param string[]|\Google\Protobuf\Internal\RepeatedField $var 74 | * @return $this 75 | */ 76 | public function setKeys($var) 77 | { 78 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); 79 | $this->Keys = $arr; 80 | 81 | return $this; 82 | } 83 | 84 | } 85 | 86 | -------------------------------------------------------------------------------- /src/Storage/Pilosa/Proto/ImportRoaringRequest.php: -------------------------------------------------------------------------------- 1 | ImportRoaringRequest 13 | */ 14 | class ImportRoaringRequest extends \Google\Protobuf\Internal\Message 15 | { 16 | /** 17 | * Generated from protobuf field bool Clear = 1; 18 | */ 19 | protected $Clear = false; 20 | /** 21 | * Generated from protobuf field repeated .ImportRoaringRequestView views = 2; 22 | */ 23 | private $views; 24 | 25 | /** 26 | * Constructor. 27 | * 28 | * @param array $data { 29 | * Optional. Data for populating the Message object. 30 | * 31 | * @type bool $Clear 32 | * @type \App\Storage\Pilosa\Proto\ImportRoaringRequestView[]|\Google\Protobuf\Internal\RepeatedField $views 33 | * } 34 | */ 35 | public function __construct($data = NULL) { 36 | \App\Storage\Pilosa\Proto\GPBMetadata\PBPublic::initOnce(); 37 | parent::__construct($data); 38 | } 39 | 40 | /** 41 | * Generated from protobuf field bool Clear = 1; 42 | * @return bool 43 | */ 44 | public function getClear() 45 | { 46 | return $this->Clear; 47 | } 48 | 49 | /** 50 | * Generated from protobuf field bool Clear = 1; 51 | * @param bool $var 52 | * @return $this 53 | */ 54 | public function setClear($var) 55 | { 56 | GPBUtil::checkBool($var); 57 | $this->Clear = $var; 58 | 59 | return $this; 60 | } 61 | 62 | /** 63 | * Generated from protobuf field repeated .ImportRoaringRequestView views = 2; 64 | * @return \Google\Protobuf\Internal\RepeatedField 65 | */ 66 | public function getViews() 67 | { 68 | return $this->views; 69 | } 70 | 71 | /** 72 | * Generated from protobuf field repeated .ImportRoaringRequestView views = 2; 73 | * @param \App\Storage\Pilosa\Proto\ImportRoaringRequestView[]|\Google\Protobuf\Internal\RepeatedField $var 74 | * @return $this 75 | */ 76 | public function setViews($var) 77 | { 78 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \App\Storage\Pilosa\Proto\ImportRoaringRequestView::class); 79 | $this->views = $arr; 80 | 81 | return $this; 82 | } 83 | 84 | } 85 | 86 | -------------------------------------------------------------------------------- /src/Storage/Pilosa/public.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option php_namespace = "App\\Storage\\Pilosa\\Proto"; 4 | option php_metadata_namespace = "App\\Storage\\Pilosa\\Proto\\GPBMetadata"; 5 | 6 | message Row { 7 | repeated uint64 Columns = 1; 8 | repeated string Keys = 3; 9 | repeated Attr Attrs = 2; 10 | } 11 | 12 | message RowIdentifiers { 13 | repeated uint64 Rows = 1; 14 | repeated string Keys = 2; 15 | } 16 | 17 | message Pair { 18 | uint64 ID = 1; 19 | string Key = 3; 20 | uint64 Count = 2; 21 | } 22 | 23 | message FieldRow{ 24 | string Field = 1; 25 | uint64 RowID = 2; 26 | string RowKey = 3; 27 | } 28 | 29 | message GroupCount{ 30 | repeated FieldRow Group = 1; 31 | uint64 Count = 2; 32 | } 33 | 34 | message ValCount { 35 | int64 Val = 1; 36 | int64 Count = 2; 37 | } 38 | 39 | message ColumnAttrSet { 40 | uint64 ID = 1; 41 | string Key = 3; 42 | repeated Attr Attrs = 2; 43 | } 44 | 45 | message Attr { 46 | string Key = 1; 47 | uint64 Type = 2; 48 | string StringValue = 3; 49 | int64 IntValue = 4; 50 | bool BoolValue = 5; 51 | double FloatValue = 6; 52 | } 53 | 54 | message AttrMap { 55 | repeated Attr Attrs = 1; 56 | } 57 | 58 | message QueryRequest { 59 | string Query = 1; 60 | repeated uint64 Shards = 2; 61 | bool ColumnAttrs = 3; 62 | bool Remote = 5; 63 | bool ExcludeRowAttrs = 6; 64 | bool ExcludeColumns = 7; 65 | } 66 | 67 | message QueryResponse { 68 | string Err = 1; 69 | repeated QueryResult Results = 2; 70 | repeated ColumnAttrSet ColumnAttrSets = 3; 71 | } 72 | 73 | message QueryResult { 74 | uint32 Type = 6; 75 | Row Row = 1; 76 | uint64 N = 2; 77 | repeated Pair Pairs = 3; 78 | bool Changed = 4; 79 | ValCount ValCount = 5; 80 | repeated uint64 RowIDs = 7; 81 | repeated GroupCount GroupCounts = 8; 82 | RowIdentifiers RowIdentifiers = 9; 83 | } 84 | 85 | message ImportRequest { 86 | string Index = 1; 87 | string Field = 2; 88 | uint64 Shard = 3; 89 | repeated uint64 RowIDs = 4; 90 | repeated uint64 ColumnIDs = 5; 91 | repeated string RowKeys = 7; 92 | repeated string ColumnKeys = 8; 93 | repeated int64 Timestamps = 6; 94 | } 95 | 96 | message ImportValueRequest { 97 | string Index = 1; 98 | string Field = 2; 99 | uint64 Shard = 3; 100 | repeated uint64 ColumnIDs = 5; 101 | repeated string ColumnKeys = 7; 102 | repeated int64 Values = 6; 103 | } 104 | 105 | message TranslateKeysRequest { 106 | string Index = 1; 107 | string Field = 2; 108 | repeated string Keys = 3; 109 | } 110 | 111 | message TranslateKeysResponse { 112 | repeated uint64 IDs = 3; 113 | } 114 | 115 | message ImportRoaringRequestView { 116 | string Name = 1; 117 | bytes Data = 2; 118 | } 119 | 120 | message ImportRoaringRequest { 121 | bool Clear = 1; 122 | repeated ImportRoaringRequestView views = 2; 123 | } 124 | -------------------------------------------------------------------------------- /src/Service/Updater.php: -------------------------------------------------------------------------------- 1 | logger?->info($this->source->getDescription()); 30 | 31 | // check the source's last update time 32 | $sourceLastUpdate = $this->source->getLastUpdate(); 33 | $this->logger?->info(sprintf('Source last update time %s', date('r', $sourceLastUpdate))); 34 | 35 | $currentStatus = $this->statusStorage->getStatus(); 36 | if ($this->source->getLastUpdate() <= $currentStatus->lastUpdate) { 37 | $this->logger?->warning(sprintf( 38 | 'Selected source has had no updates since %s', 39 | date('r', $currentStatus->lastUpdate) 40 | )); 41 | 42 | return; 43 | } 44 | 45 | $this->logger?->info('Update process has been started'); 46 | 47 | $sourceStream = $this->source->getStream(); 48 | // read source stream and extract single lines 49 | $parsedLines = (new StreamLineGenerator($sourceStream))->getLines(); 50 | // validate lines 51 | $validLines = (new ValidateLineGenerator($parsedLines))->getLines(); 52 | 53 | // extract series, number values from the string line 54 | $items = (new ItemLineGenerator($validLines))->getItems(); 55 | 56 | // send items to the storage 57 | $storedCount = $this->itemStorage->updateItems($items); 58 | 59 | // close source stream 60 | $sourceStream->close(); 61 | 62 | // collect parser info 63 | $parsedLinesResult = $parsedLines->getReturn(); 64 | $this->logger?->info(sprintf('%d lines parsed', $parsedLinesResult['processed'])); 65 | 66 | // collect validation info 67 | $validLinesResult = $validLines->getReturn(); 68 | $this->logger?->info(sprintf('%d lines validated', $validLinesResult['processed'])); 69 | $this->logger?->info(sprintf('%d invalid lines ignored', $validLinesResult['ignored'])); 70 | 71 | // storage stats 72 | $this->logger?->info(sprintf('%d items saved', $storedCount)); 73 | 74 | // save new status 75 | $this->statusStorage->setStatus(new Status( 76 | lastUpdate: $this->source->getLastUpdate(), 77 | items: $storedCount 78 | )); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/Storage/Pilosa/Proto/Pair.php: -------------------------------------------------------------------------------- 1 | Pair 13 | */ 14 | class Pair extends \Google\Protobuf\Internal\Message 15 | { 16 | /** 17 | * Generated from protobuf field uint64 ID = 1; 18 | */ 19 | protected $ID = 0; 20 | /** 21 | * Generated from protobuf field string Key = 3; 22 | */ 23 | protected $Key = ''; 24 | /** 25 | * Generated from protobuf field uint64 Count = 2; 26 | */ 27 | protected $Count = 0; 28 | 29 | /** 30 | * Constructor. 31 | * 32 | * @param array $data { 33 | * Optional. Data for populating the Message object. 34 | * 35 | * @type int|string $ID 36 | * @type string $Key 37 | * @type int|string $Count 38 | * } 39 | */ 40 | public function __construct($data = NULL) { 41 | \App\Storage\Pilosa\Proto\GPBMetadata\PBPublic::initOnce(); 42 | parent::__construct($data); 43 | } 44 | 45 | /** 46 | * Generated from protobuf field uint64 ID = 1; 47 | * @return int|string 48 | */ 49 | public function getID() 50 | { 51 | return $this->ID; 52 | } 53 | 54 | /** 55 | * Generated from protobuf field uint64 ID = 1; 56 | * @param int|string $var 57 | * @return $this 58 | */ 59 | public function setID($var) 60 | { 61 | GPBUtil::checkUint64($var); 62 | $this->ID = $var; 63 | 64 | return $this; 65 | } 66 | 67 | /** 68 | * Generated from protobuf field string Key = 3; 69 | * @return string 70 | */ 71 | public function getKey() 72 | { 73 | return $this->Key; 74 | } 75 | 76 | /** 77 | * Generated from protobuf field string Key = 3; 78 | * @param string $var 79 | * @return $this 80 | */ 81 | public function setKey($var) 82 | { 83 | GPBUtil::checkString($var, True); 84 | $this->Key = $var; 85 | 86 | return $this; 87 | } 88 | 89 | /** 90 | * Generated from protobuf field uint64 Count = 2; 91 | * @return int|string 92 | */ 93 | public function getCount() 94 | { 95 | return $this->Count; 96 | } 97 | 98 | /** 99 | * Generated from protobuf field uint64 Count = 2; 100 | * @param int|string $var 101 | * @return $this 102 | */ 103 | public function setCount($var) 104 | { 105 | GPBUtil::checkUint64($var); 106 | $this->Count = $var; 107 | 108 | return $this; 109 | } 110 | 111 | } 112 | 113 | -------------------------------------------------------------------------------- /src/Storage/Pilosa/Proto/FieldRow.php: -------------------------------------------------------------------------------- 1 | FieldRow 13 | */ 14 | class FieldRow extends \Google\Protobuf\Internal\Message 15 | { 16 | /** 17 | * Generated from protobuf field string Field = 1; 18 | */ 19 | protected $Field = ''; 20 | /** 21 | * Generated from protobuf field uint64 RowID = 2; 22 | */ 23 | protected $RowID = 0; 24 | /** 25 | * Generated from protobuf field string RowKey = 3; 26 | */ 27 | protected $RowKey = ''; 28 | 29 | /** 30 | * Constructor. 31 | * 32 | * @param array $data { 33 | * Optional. Data for populating the Message object. 34 | * 35 | * @type string $Field 36 | * @type int|string $RowID 37 | * @type string $RowKey 38 | * } 39 | */ 40 | public function __construct($data = NULL) { 41 | \App\Storage\Pilosa\Proto\GPBMetadata\PBPublic::initOnce(); 42 | parent::__construct($data); 43 | } 44 | 45 | /** 46 | * Generated from protobuf field string Field = 1; 47 | * @return string 48 | */ 49 | public function getField() 50 | { 51 | return $this->Field; 52 | } 53 | 54 | /** 55 | * Generated from protobuf field string Field = 1; 56 | * @param string $var 57 | * @return $this 58 | */ 59 | public function setField($var) 60 | { 61 | GPBUtil::checkString($var, True); 62 | $this->Field = $var; 63 | 64 | return $this; 65 | } 66 | 67 | /** 68 | * Generated from protobuf field uint64 RowID = 2; 69 | * @return int|string 70 | */ 71 | public function getRowID() 72 | { 73 | return $this->RowID; 74 | } 75 | 76 | /** 77 | * Generated from protobuf field uint64 RowID = 2; 78 | * @param int|string $var 79 | * @return $this 80 | */ 81 | public function setRowID($var) 82 | { 83 | GPBUtil::checkUint64($var); 84 | $this->RowID = $var; 85 | 86 | return $this; 87 | } 88 | 89 | /** 90 | * Generated from protobuf field string RowKey = 3; 91 | * @return string 92 | */ 93 | public function getRowKey() 94 | { 95 | return $this->RowKey; 96 | } 97 | 98 | /** 99 | * Generated from protobuf field string RowKey = 3; 100 | * @param string $var 101 | * @return $this 102 | */ 103 | public function setRowKey($var) 104 | { 105 | GPBUtil::checkString($var, True); 106 | $this->RowKey = $var; 107 | 108 | return $this; 109 | } 110 | 111 | } 112 | 113 | -------------------------------------------------------------------------------- /src/Storage/PilosaItemStorage.php: -------------------------------------------------------------------------------- 1 | url, $this->index, self::FIELD)); 28 | curl_setopt($ch, CURLOPT_POST, true); 29 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 30 | curl_setopt($ch, CURLOPT_HTTPHEADER, [ 31 | 'Content-Type: application/x-protobuf', 32 | 'Accept: application/x-protobuf', 33 | ]); 34 | 35 | $bufferColumnIDs = $bufferRowIDs = []; 36 | $bufferCounter = 0; 37 | $processedCounter = 0; 38 | foreach ($items as $item) { 39 | $bufferColumnIDs[] = $item->number; 40 | $bufferRowIDs[] = $item->series; 41 | $bufferCounter++; 42 | $processedCounter++; 43 | 44 | // flush buffer 45 | if ($bufferCounter > $this->batchSize) { 46 | $importRequest = (new ImportRequest()) 47 | ->setIndex($this->index) 48 | ->setField(self::FIELD) 49 | ->setColumnIDs($bufferColumnIDs) 50 | ->setRowIDs($bufferRowIDs) 51 | ; 52 | 53 | curl_setopt($ch, CURLOPT_POSTFIELDS, $importRequest->serializeToString()); 54 | curl_exec($ch); 55 | if (curl_errno($ch)) { 56 | throw new \Exception('Curl error: ' . curl_error($ch)); 57 | } 58 | $bufferRowIDs = $bufferColumnIDs = []; 59 | $bufferCounter = 0; 60 | } 61 | } 62 | // final flush 63 | $importRequest = (new ImportRequest()) 64 | ->setIndex($this->index) 65 | ->setField(self::FIELD) 66 | ->setColumnIDs($bufferColumnIDs) 67 | ->setRowIDs($bufferRowIDs) 68 | ; 69 | curl_setopt($ch, CURLOPT_POSTFIELDS, $importRequest->serializeToString()); 70 | curl_exec($ch); 71 | 72 | return $processedCounter; 73 | } 74 | 75 | /** 76 | * @inheritdoc 77 | * @throws \Exception 78 | */ 79 | public function getItems(iterable $items): array 80 | { 81 | throw new \Exception('Method getItems is not implemented for Pilosa storage'); 82 | 83 | // $query = (new QueryRequest())->setQuery(sprintf( 84 | // 'GroupBy(Rows(series, column=%d), filter=Row(series=%04d), limit=1)', 85 | // $item->number, 86 | // $item->series, 87 | // )); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/Storage/Pilosa/Proto/TranslateKeysRequest.php: -------------------------------------------------------------------------------- 1 | TranslateKeysRequest 13 | */ 14 | class TranslateKeysRequest extends \Google\Protobuf\Internal\Message 15 | { 16 | /** 17 | * Generated from protobuf field string Index = 1; 18 | */ 19 | protected $Index = ''; 20 | /** 21 | * Generated from protobuf field string Field = 2; 22 | */ 23 | protected $Field = ''; 24 | /** 25 | * Generated from protobuf field repeated string Keys = 3; 26 | */ 27 | private $Keys; 28 | 29 | /** 30 | * Constructor. 31 | * 32 | * @param array $data { 33 | * Optional. Data for populating the Message object. 34 | * 35 | * @type string $Index 36 | * @type string $Field 37 | * @type string[]|\Google\Protobuf\Internal\RepeatedField $Keys 38 | * } 39 | */ 40 | public function __construct($data = NULL) { 41 | \App\Storage\Pilosa\Proto\GPBMetadata\PBPublic::initOnce(); 42 | parent::__construct($data); 43 | } 44 | 45 | /** 46 | * Generated from protobuf field string Index = 1; 47 | * @return string 48 | */ 49 | public function getIndex() 50 | { 51 | return $this->Index; 52 | } 53 | 54 | /** 55 | * Generated from protobuf field string Index = 1; 56 | * @param string $var 57 | * @return $this 58 | */ 59 | public function setIndex($var) 60 | { 61 | GPBUtil::checkString($var, True); 62 | $this->Index = $var; 63 | 64 | return $this; 65 | } 66 | 67 | /** 68 | * Generated from protobuf field string Field = 2; 69 | * @return string 70 | */ 71 | public function getField() 72 | { 73 | return $this->Field; 74 | } 75 | 76 | /** 77 | * Generated from protobuf field string Field = 2; 78 | * @param string $var 79 | * @return $this 80 | */ 81 | public function setField($var) 82 | { 83 | GPBUtil::checkString($var, True); 84 | $this->Field = $var; 85 | 86 | return $this; 87 | } 88 | 89 | /** 90 | * Generated from protobuf field repeated string Keys = 3; 91 | * @return \Google\Protobuf\Internal\RepeatedField 92 | */ 93 | public function getKeys() 94 | { 95 | return $this->Keys; 96 | } 97 | 98 | /** 99 | * Generated from protobuf field repeated string Keys = 3; 100 | * @param string[]|\Google\Protobuf\Internal\RepeatedField $var 101 | * @return $this 102 | */ 103 | public function setKeys($var) 104 | { 105 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); 106 | $this->Keys = $arr; 107 | 108 | return $this; 109 | } 110 | 111 | } 112 | 113 | -------------------------------------------------------------------------------- /src/Storage/Pilosa/Proto/ColumnAttrSet.php: -------------------------------------------------------------------------------- 1 | ColumnAttrSet 13 | */ 14 | class ColumnAttrSet extends \Google\Protobuf\Internal\Message 15 | { 16 | /** 17 | * Generated from protobuf field uint64 ID = 1; 18 | */ 19 | protected $ID = 0; 20 | /** 21 | * Generated from protobuf field string Key = 3; 22 | */ 23 | protected $Key = ''; 24 | /** 25 | * Generated from protobuf field repeated .Attr Attrs = 2; 26 | */ 27 | private $Attrs; 28 | 29 | /** 30 | * Constructor. 31 | * 32 | * @param array $data { 33 | * Optional. Data for populating the Message object. 34 | * 35 | * @type int|string $ID 36 | * @type string $Key 37 | * @type \App\Storage\Pilosa\Proto\Attr[]|\Google\Protobuf\Internal\RepeatedField $Attrs 38 | * } 39 | */ 40 | public function __construct($data = NULL) { 41 | \App\Storage\Pilosa\Proto\GPBMetadata\PBPublic::initOnce(); 42 | parent::__construct($data); 43 | } 44 | 45 | /** 46 | * Generated from protobuf field uint64 ID = 1; 47 | * @return int|string 48 | */ 49 | public function getID() 50 | { 51 | return $this->ID; 52 | } 53 | 54 | /** 55 | * Generated from protobuf field uint64 ID = 1; 56 | * @param int|string $var 57 | * @return $this 58 | */ 59 | public function setID($var) 60 | { 61 | GPBUtil::checkUint64($var); 62 | $this->ID = $var; 63 | 64 | return $this; 65 | } 66 | 67 | /** 68 | * Generated from protobuf field string Key = 3; 69 | * @return string 70 | */ 71 | public function getKey() 72 | { 73 | return $this->Key; 74 | } 75 | 76 | /** 77 | * Generated from protobuf field string Key = 3; 78 | * @param string $var 79 | * @return $this 80 | */ 81 | public function setKey($var) 82 | { 83 | GPBUtil::checkString($var, True); 84 | $this->Key = $var; 85 | 86 | return $this; 87 | } 88 | 89 | /** 90 | * Generated from protobuf field repeated .Attr Attrs = 2; 91 | * @return \Google\Protobuf\Internal\RepeatedField 92 | */ 93 | public function getAttrs() 94 | { 95 | return $this->Attrs; 96 | } 97 | 98 | /** 99 | * Generated from protobuf field repeated .Attr Attrs = 2; 100 | * @param \App\Storage\Pilosa\Proto\Attr[]|\Google\Protobuf\Internal\RepeatedField $var 101 | * @return $this 102 | */ 103 | public function setAttrs($var) 104 | { 105 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \App\Storage\Pilosa\Proto\Attr::class); 106 | $this->Attrs = $arr; 107 | 108 | return $this; 109 | } 110 | 111 | } 112 | 113 | -------------------------------------------------------------------------------- /src/Storage/Pilosa/Proto/Row.php: -------------------------------------------------------------------------------- 1 | Row 13 | */ 14 | class Row extends \Google\Protobuf\Internal\Message 15 | { 16 | /** 17 | * Generated from protobuf field repeated uint64 Columns = 1; 18 | */ 19 | private $Columns; 20 | /** 21 | * Generated from protobuf field repeated string Keys = 3; 22 | */ 23 | private $Keys; 24 | /** 25 | * Generated from protobuf field repeated .Attr Attrs = 2; 26 | */ 27 | private $Attrs; 28 | 29 | /** 30 | * Constructor. 31 | * 32 | * @param array $data { 33 | * Optional. Data for populating the Message object. 34 | * 35 | * @type int[]|string[]|\Google\Protobuf\Internal\RepeatedField $Columns 36 | * @type string[]|\Google\Protobuf\Internal\RepeatedField $Keys 37 | * @type \App\Storage\Pilosa\Proto\Attr[]|\Google\Protobuf\Internal\RepeatedField $Attrs 38 | * } 39 | */ 40 | public function __construct($data = NULL) { 41 | \App\Storage\Pilosa\Proto\GPBMetadata\PBPublic::initOnce(); 42 | parent::__construct($data); 43 | } 44 | 45 | /** 46 | * Generated from protobuf field repeated uint64 Columns = 1; 47 | * @return \Google\Protobuf\Internal\RepeatedField 48 | */ 49 | public function getColumns() 50 | { 51 | return $this->Columns; 52 | } 53 | 54 | /** 55 | * Generated from protobuf field repeated uint64 Columns = 1; 56 | * @param int[]|string[]|\Google\Protobuf\Internal\RepeatedField $var 57 | * @return $this 58 | */ 59 | public function setColumns($var) 60 | { 61 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::UINT64); 62 | $this->Columns = $arr; 63 | 64 | return $this; 65 | } 66 | 67 | /** 68 | * Generated from protobuf field repeated string Keys = 3; 69 | * @return \Google\Protobuf\Internal\RepeatedField 70 | */ 71 | public function getKeys() 72 | { 73 | return $this->Keys; 74 | } 75 | 76 | /** 77 | * Generated from protobuf field repeated string Keys = 3; 78 | * @param string[]|\Google\Protobuf\Internal\RepeatedField $var 79 | * @return $this 80 | */ 81 | public function setKeys($var) 82 | { 83 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); 84 | $this->Keys = $arr; 85 | 86 | return $this; 87 | } 88 | 89 | /** 90 | * Generated from protobuf field repeated .Attr Attrs = 2; 91 | * @return \Google\Protobuf\Internal\RepeatedField 92 | */ 93 | public function getAttrs() 94 | { 95 | return $this->Attrs; 96 | } 97 | 98 | /** 99 | * Generated from protobuf field repeated .Attr Attrs = 2; 100 | * @param \App\Storage\Pilosa\Proto\Attr[]|\Google\Protobuf\Internal\RepeatedField $var 101 | * @return $this 102 | */ 103 | public function setAttrs($var) 104 | { 105 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \App\Storage\Pilosa\Proto\Attr::class); 106 | $this->Attrs = $arr; 107 | 108 | return $this; 109 | } 110 | 111 | } 112 | 113 | -------------------------------------------------------------------------------- /src/bootstrap.php: -------------------------------------------------------------------------------- 1 | \DI\factory([RedisFactory::class, 'create']) 24 | ->parameter('host', \DI\get('redis.host')) 25 | ->parameter('port', \DI\get('redis.port')) 26 | ->parameter('password', \DI\get('redis.password')) 27 | , 28 | // logger 29 | LoggerInterface::class => \DI\factory(function () { 30 | return (new Logger('update')) 31 | ->pushHandler(new StreamHandler('php://stdout', Logger::INFO)); 32 | }), 33 | // source 34 | SourceInterface::class => \DI\factory(function (\Psr\Container\ContainerInterface $c) { 35 | try { 36 | return match ((string) $c->get('source.type')) { 37 | 'file' => new FileSource( 38 | path: $c->get('source.file.path'), 39 | ), 40 | 'http' => new HttpSource( 41 | url: $c->get('source.http.url'), 42 | ), 43 | }; 44 | } catch (\UnhandledMatchError) { 45 | trigger_error(sprintf("Unknown status type '%s'", $c->get('storage.type')), E_USER_ERROR); 46 | } 47 | }), 48 | // status 49 | StatusStorageInterface::class => \DI\factory(function (\Psr\Container\ContainerInterface $c) { 50 | try { 51 | return match ((string) $c->get('status.type')) { 52 | 'dummy' => new DummyStatusStorage(), 53 | 'file' => new FileStatusStorage( 54 | path: $c->get('status.file.path') 55 | ), 56 | 'redis' => new RedisStatusStorage( 57 | redis: $c->get(Redis::class), 58 | statusDb: $c->get('status.redis.db'), 59 | ), 60 | }; 61 | } catch (\UnhandledMatchError) { 62 | trigger_error(sprintf("Unknown status type '%s'", $c->get('storage.type')), E_USER_ERROR); 63 | } 64 | }), 65 | // storage 66 | ItemStorageInterface::class => \DI\factory(function (\Psr\Container\ContainerInterface $c) { 67 | try { 68 | return match ((string) $c->get('storage.type')) { 69 | 'redis' => new RedisItemStorage( 70 | redis: $c->get(Redis::class), 71 | primaryDb: $c->get('storage.redis.primary_db'), 72 | temporaryDb: $c->get('storage.redis.temporary_db'), 73 | ), 74 | }; 75 | } catch (\UnhandledMatchError) { 76 | trigger_error(sprintf("Unknown storage type '%s'", $c->get('storage.type')), E_USER_ERROR); 77 | } 78 | }), 79 | // updater service 80 | \App\Service\Updater::class => \DI\create()->constructor( 81 | source: \DI\get(SourceInterface::class), 82 | statusStorage: \DI\get(StatusStorageInterface::class), 83 | itemStorage: \DI\get(ItemStorageInterface::class), 84 | logger: \DI\get(LoggerInterface::class), 85 | ), 86 | ]; 87 | 88 | return (new \DI\ContainerBuilder()) 89 | ->addDefinitions(__DIR__ . '/../config/config.php') 90 | ->addDefinitions($containerConfig) 91 | // ->enableCompilation(__DIR__ . '/../var/cache') 92 | ->build() 93 | ; 94 | -------------------------------------------------------------------------------- /tests/integration/UpdateTest.php: -------------------------------------------------------------------------------- 1 | buildStatusStorage(); 10 | $source = $this->buildSource(); 11 | $itemStorage = $this->buildStorage(); 12 | $logger = $this->createMock(\Psr\Log\LoggerInterface::class); 13 | 14 | $updater = new \App\Service\Updater( 15 | source: $source, 16 | statusStorage: $statusStorage, 17 | itemStorage: $itemStorage, 18 | logger: $logger, 19 | ); 20 | 21 | $updater->run(); 22 | 23 | $this->assertEquals(3, $statusStorage->getStatus()->items); 24 | $this->assertCount(2, $itemStorage->getItems([ 25 | new \App\Storage\Item('1234', '123456'), 26 | new \App\Storage\Item('4321', '654321'), 27 | ])); 28 | } 29 | 30 | private function buildStorage(): \App\Storage\ItemStorageInterface 31 | { 32 | return new class() implements \App\Storage\ItemStorageInterface { 33 | private array $items = []; 34 | 35 | public function updateItems(iterable $items): int 36 | { 37 | $this->items = []; 38 | foreach ($items as $item) { 39 | $this->items[] = $item; 40 | } 41 | 42 | return count($this->items); 43 | } 44 | 45 | public function getItems(iterable $items): array 46 | { 47 | $result = []; 48 | foreach ($items as $searchItem) { 49 | foreach ($this->items as $storedItem) { 50 | if ($searchItem->series == $storedItem->series && $searchItem->number == $storedItem->number) { 51 | $result[] = $searchItem; 52 | } 53 | } 54 | } 55 | 56 | return $result; 57 | } 58 | }; 59 | } 60 | 61 | private function buildStatusStorage(): \App\Status\StatusStorageInterface 62 | { 63 | return new class() implements \App\Status\StatusStorageInterface { 64 | private App\Status\Status $status; 65 | 66 | public function __construct() 67 | { 68 | $this->status = new \App\Status\Status( 69 | lastUpdate: time() - 3600, 70 | items: 0, 71 | ); 72 | } 73 | 74 | public function getStatus(): \App\Status\Status 75 | { 76 | return $this->status; 77 | } 78 | 79 | public function setStatus(\App\Status\Status $status): void 80 | { 81 | $this->status = $status; 82 | } 83 | }; 84 | } 85 | 86 | private function buildSource(): \App\Source\SourceInterface 87 | { 88 | return new class() implements \App\Source\SourceInterface { 89 | public function getStream(): \Psr\Http\Message\StreamInterface 90 | { 91 | return \GuzzleHttp\Psr7\Utils::streamFor( 92 | <<QueryResponse 13 | */ 14 | class QueryResponse extends \Google\Protobuf\Internal\Message 15 | { 16 | /** 17 | * Generated from protobuf field string Err = 1; 18 | */ 19 | protected $Err = ''; 20 | /** 21 | * Generated from protobuf field repeated .QueryResult Results = 2; 22 | */ 23 | private $Results; 24 | /** 25 | * Generated from protobuf field repeated .ColumnAttrSet ColumnAttrSets = 3; 26 | */ 27 | private $ColumnAttrSets; 28 | 29 | /** 30 | * Constructor. 31 | * 32 | * @param array $data { 33 | * Optional. Data for populating the Message object. 34 | * 35 | * @type string $Err 36 | * @type \App\Storage\Pilosa\Proto\QueryResult[]|\Google\Protobuf\Internal\RepeatedField $Results 37 | * @type \App\Storage\Pilosa\Proto\ColumnAttrSet[]|\Google\Protobuf\Internal\RepeatedField $ColumnAttrSets 38 | * } 39 | */ 40 | public function __construct($data = NULL) { 41 | \App\Storage\Pilosa\Proto\GPBMetadata\PBPublic::initOnce(); 42 | parent::__construct($data); 43 | } 44 | 45 | /** 46 | * Generated from protobuf field string Err = 1; 47 | * @return string 48 | */ 49 | public function getErr() 50 | { 51 | return $this->Err; 52 | } 53 | 54 | /** 55 | * Generated from protobuf field string Err = 1; 56 | * @param string $var 57 | * @return $this 58 | */ 59 | public function setErr($var) 60 | { 61 | GPBUtil::checkString($var, True); 62 | $this->Err = $var; 63 | 64 | return $this; 65 | } 66 | 67 | /** 68 | * Generated from protobuf field repeated .QueryResult Results = 2; 69 | * @return \Google\Protobuf\Internal\RepeatedField 70 | */ 71 | public function getResults() 72 | { 73 | return $this->Results; 74 | } 75 | 76 | /** 77 | * Generated from protobuf field repeated .QueryResult Results = 2; 78 | * @param \App\Storage\Pilosa\Proto\QueryResult[]|\Google\Protobuf\Internal\RepeatedField $var 79 | * @return $this 80 | */ 81 | public function setResults($var) 82 | { 83 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \App\Storage\Pilosa\Proto\QueryResult::class); 84 | $this->Results = $arr; 85 | 86 | return $this; 87 | } 88 | 89 | /** 90 | * Generated from protobuf field repeated .ColumnAttrSet ColumnAttrSets = 3; 91 | * @return \Google\Protobuf\Internal\RepeatedField 92 | */ 93 | public function getColumnAttrSets() 94 | { 95 | return $this->ColumnAttrSets; 96 | } 97 | 98 | /** 99 | * Generated from protobuf field repeated .ColumnAttrSet ColumnAttrSets = 3; 100 | * @param \App\Storage\Pilosa\Proto\ColumnAttrSet[]|\Google\Protobuf\Internal\RepeatedField $var 101 | * @return $this 102 | */ 103 | public function setColumnAttrSets($var) 104 | { 105 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \App\Storage\Pilosa\Proto\ColumnAttrSet::class); 106 | $this->ColumnAttrSets = $arr; 107 | 108 | return $this; 109 | } 110 | 111 | } 112 | 113 | -------------------------------------------------------------------------------- /src/Storage/Pilosa/Proto/Attr.php: -------------------------------------------------------------------------------- 1 | Attr 13 | */ 14 | class Attr extends \Google\Protobuf\Internal\Message 15 | { 16 | /** 17 | * Generated from protobuf field string Key = 1; 18 | */ 19 | protected $Key = ''; 20 | /** 21 | * Generated from protobuf field uint64 Type = 2; 22 | */ 23 | protected $Type = 0; 24 | /** 25 | * Generated from protobuf field string StringValue = 3; 26 | */ 27 | protected $StringValue = ''; 28 | /** 29 | * Generated from protobuf field int64 IntValue = 4; 30 | */ 31 | protected $IntValue = 0; 32 | /** 33 | * Generated from protobuf field bool BoolValue = 5; 34 | */ 35 | protected $BoolValue = false; 36 | /** 37 | * Generated from protobuf field double FloatValue = 6; 38 | */ 39 | protected $FloatValue = 0.0; 40 | 41 | /** 42 | * Constructor. 43 | * 44 | * @param array $data { 45 | * Optional. Data for populating the Message object. 46 | * 47 | * @type string $Key 48 | * @type int|string $Type 49 | * @type string $StringValue 50 | * @type int|string $IntValue 51 | * @type bool $BoolValue 52 | * @type float $FloatValue 53 | * } 54 | */ 55 | public function __construct($data = NULL) { 56 | \App\Storage\Pilosa\Proto\GPBMetadata\PBPublic::initOnce(); 57 | parent::__construct($data); 58 | } 59 | 60 | /** 61 | * Generated from protobuf field string Key = 1; 62 | * @return string 63 | */ 64 | public function getKey() 65 | { 66 | return $this->Key; 67 | } 68 | 69 | /** 70 | * Generated from protobuf field string Key = 1; 71 | * @param string $var 72 | * @return $this 73 | */ 74 | public function setKey($var) 75 | { 76 | GPBUtil::checkString($var, True); 77 | $this->Key = $var; 78 | 79 | return $this; 80 | } 81 | 82 | /** 83 | * Generated from protobuf field uint64 Type = 2; 84 | * @return int|string 85 | */ 86 | public function getType() 87 | { 88 | return $this->Type; 89 | } 90 | 91 | /** 92 | * Generated from protobuf field uint64 Type = 2; 93 | * @param int|string $var 94 | * @return $this 95 | */ 96 | public function setType($var) 97 | { 98 | GPBUtil::checkUint64($var); 99 | $this->Type = $var; 100 | 101 | return $this; 102 | } 103 | 104 | /** 105 | * Generated from protobuf field string StringValue = 3; 106 | * @return string 107 | */ 108 | public function getStringValue() 109 | { 110 | return $this->StringValue; 111 | } 112 | 113 | /** 114 | * Generated from protobuf field string StringValue = 3; 115 | * @param string $var 116 | * @return $this 117 | */ 118 | public function setStringValue($var) 119 | { 120 | GPBUtil::checkString($var, True); 121 | $this->StringValue = $var; 122 | 123 | return $this; 124 | } 125 | 126 | /** 127 | * Generated from protobuf field int64 IntValue = 4; 128 | * @return int|string 129 | */ 130 | public function getIntValue() 131 | { 132 | return $this->IntValue; 133 | } 134 | 135 | /** 136 | * Generated from protobuf field int64 IntValue = 4; 137 | * @param int|string $var 138 | * @return $this 139 | */ 140 | public function setIntValue($var) 141 | { 142 | GPBUtil::checkInt64($var); 143 | $this->IntValue = $var; 144 | 145 | return $this; 146 | } 147 | 148 | /** 149 | * Generated from protobuf field bool BoolValue = 5; 150 | * @return bool 151 | */ 152 | public function getBoolValue() 153 | { 154 | return $this->BoolValue; 155 | } 156 | 157 | /** 158 | * Generated from protobuf field bool BoolValue = 5; 159 | * @param bool $var 160 | * @return $this 161 | */ 162 | public function setBoolValue($var) 163 | { 164 | GPBUtil::checkBool($var); 165 | $this->BoolValue = $var; 166 | 167 | return $this; 168 | } 169 | 170 | /** 171 | * Generated from protobuf field double FloatValue = 6; 172 | * @return float 173 | */ 174 | public function getFloatValue() 175 | { 176 | return $this->FloatValue; 177 | } 178 | 179 | /** 180 | * Generated from protobuf field double FloatValue = 6; 181 | * @param float $var 182 | * @return $this 183 | */ 184 | public function setFloatValue($var) 185 | { 186 | GPBUtil::checkDouble($var); 187 | $this->FloatValue = $var; 188 | 189 | return $this; 190 | } 191 | 192 | } 193 | 194 | -------------------------------------------------------------------------------- /src/Storage/Pilosa/Proto/QueryRequest.php: -------------------------------------------------------------------------------- 1 | QueryRequest 13 | */ 14 | class QueryRequest extends \Google\Protobuf\Internal\Message 15 | { 16 | /** 17 | * Generated from protobuf field string Query = 1; 18 | */ 19 | protected $Query = ''; 20 | /** 21 | * Generated from protobuf field repeated uint64 Shards = 2; 22 | */ 23 | private $Shards; 24 | /** 25 | * Generated from protobuf field bool ColumnAttrs = 3; 26 | */ 27 | protected $ColumnAttrs = false; 28 | /** 29 | * Generated from protobuf field bool Remote = 5; 30 | */ 31 | protected $Remote = false; 32 | /** 33 | * Generated from protobuf field bool ExcludeRowAttrs = 6; 34 | */ 35 | protected $ExcludeRowAttrs = false; 36 | /** 37 | * Generated from protobuf field bool ExcludeColumns = 7; 38 | */ 39 | protected $ExcludeColumns = false; 40 | 41 | /** 42 | * Constructor. 43 | * 44 | * @param array $data { 45 | * Optional. Data for populating the Message object. 46 | * 47 | * @type string $Query 48 | * @type int[]|string[]|\Google\Protobuf\Internal\RepeatedField $Shards 49 | * @type bool $ColumnAttrs 50 | * @type bool $Remote 51 | * @type bool $ExcludeRowAttrs 52 | * @type bool $ExcludeColumns 53 | * } 54 | */ 55 | public function __construct($data = NULL) { 56 | \App\Storage\Pilosa\Proto\GPBMetadata\PBPublic::initOnce(); 57 | parent::__construct($data); 58 | } 59 | 60 | /** 61 | * Generated from protobuf field string Query = 1; 62 | * @return string 63 | */ 64 | public function getQuery() 65 | { 66 | return $this->Query; 67 | } 68 | 69 | /** 70 | * Generated from protobuf field string Query = 1; 71 | * @param string $var 72 | * @return $this 73 | */ 74 | public function setQuery($var) 75 | { 76 | GPBUtil::checkString($var, True); 77 | $this->Query = $var; 78 | 79 | return $this; 80 | } 81 | 82 | /** 83 | * Generated from protobuf field repeated uint64 Shards = 2; 84 | * @return \Google\Protobuf\Internal\RepeatedField 85 | */ 86 | public function getShards() 87 | { 88 | return $this->Shards; 89 | } 90 | 91 | /** 92 | * Generated from protobuf field repeated uint64 Shards = 2; 93 | * @param int[]|string[]|\Google\Protobuf\Internal\RepeatedField $var 94 | * @return $this 95 | */ 96 | public function setShards($var) 97 | { 98 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::UINT64); 99 | $this->Shards = $arr; 100 | 101 | return $this; 102 | } 103 | 104 | /** 105 | * Generated from protobuf field bool ColumnAttrs = 3; 106 | * @return bool 107 | */ 108 | public function getColumnAttrs() 109 | { 110 | return $this->ColumnAttrs; 111 | } 112 | 113 | /** 114 | * Generated from protobuf field bool ColumnAttrs = 3; 115 | * @param bool $var 116 | * @return $this 117 | */ 118 | public function setColumnAttrs($var) 119 | { 120 | GPBUtil::checkBool($var); 121 | $this->ColumnAttrs = $var; 122 | 123 | return $this; 124 | } 125 | 126 | /** 127 | * Generated from protobuf field bool Remote = 5; 128 | * @return bool 129 | */ 130 | public function getRemote() 131 | { 132 | return $this->Remote; 133 | } 134 | 135 | /** 136 | * Generated from protobuf field bool Remote = 5; 137 | * @param bool $var 138 | * @return $this 139 | */ 140 | public function setRemote($var) 141 | { 142 | GPBUtil::checkBool($var); 143 | $this->Remote = $var; 144 | 145 | return $this; 146 | } 147 | 148 | /** 149 | * Generated from protobuf field bool ExcludeRowAttrs = 6; 150 | * @return bool 151 | */ 152 | public function getExcludeRowAttrs() 153 | { 154 | return $this->ExcludeRowAttrs; 155 | } 156 | 157 | /** 158 | * Generated from protobuf field bool ExcludeRowAttrs = 6; 159 | * @param bool $var 160 | * @return $this 161 | */ 162 | public function setExcludeRowAttrs($var) 163 | { 164 | GPBUtil::checkBool($var); 165 | $this->ExcludeRowAttrs = $var; 166 | 167 | return $this; 168 | } 169 | 170 | /** 171 | * Generated from protobuf field bool ExcludeColumns = 7; 172 | * @return bool 173 | */ 174 | public function getExcludeColumns() 175 | { 176 | return $this->ExcludeColumns; 177 | } 178 | 179 | /** 180 | * Generated from protobuf field bool ExcludeColumns = 7; 181 | * @param bool $var 182 | * @return $this 183 | */ 184 | public function setExcludeColumns($var) 185 | { 186 | GPBUtil::checkBool($var); 187 | $this->ExcludeColumns = $var; 188 | 189 | return $this; 190 | } 191 | 192 | } 193 | 194 | -------------------------------------------------------------------------------- /src/Storage/Pilosa/Proto/ImportValueRequest.php: -------------------------------------------------------------------------------- 1 | ImportValueRequest 13 | */ 14 | class ImportValueRequest extends \Google\Protobuf\Internal\Message 15 | { 16 | /** 17 | * Generated from protobuf field string Index = 1; 18 | */ 19 | protected $Index = ''; 20 | /** 21 | * Generated from protobuf field string Field = 2; 22 | */ 23 | protected $Field = ''; 24 | /** 25 | * Generated from protobuf field uint64 Shard = 3; 26 | */ 27 | protected $Shard = 0; 28 | /** 29 | * Generated from protobuf field repeated uint64 ColumnIDs = 5; 30 | */ 31 | private $ColumnIDs; 32 | /** 33 | * Generated from protobuf field repeated string ColumnKeys = 7; 34 | */ 35 | private $ColumnKeys; 36 | /** 37 | * Generated from protobuf field repeated int64 Values = 6; 38 | */ 39 | private $Values; 40 | 41 | /** 42 | * Constructor. 43 | * 44 | * @param array $data { 45 | * Optional. Data for populating the Message object. 46 | * 47 | * @type string $Index 48 | * @type string $Field 49 | * @type int|string $Shard 50 | * @type int[]|string[]|\Google\Protobuf\Internal\RepeatedField $ColumnIDs 51 | * @type string[]|\Google\Protobuf\Internal\RepeatedField $ColumnKeys 52 | * @type int[]|string[]|\Google\Protobuf\Internal\RepeatedField $Values 53 | * } 54 | */ 55 | public function __construct($data = NULL) { 56 | \App\Storage\Pilosa\Proto\GPBMetadata\PBPublic::initOnce(); 57 | parent::__construct($data); 58 | } 59 | 60 | /** 61 | * Generated from protobuf field string Index = 1; 62 | * @return string 63 | */ 64 | public function getIndex() 65 | { 66 | return $this->Index; 67 | } 68 | 69 | /** 70 | * Generated from protobuf field string Index = 1; 71 | * @param string $var 72 | * @return $this 73 | */ 74 | public function setIndex($var) 75 | { 76 | GPBUtil::checkString($var, True); 77 | $this->Index = $var; 78 | 79 | return $this; 80 | } 81 | 82 | /** 83 | * Generated from protobuf field string Field = 2; 84 | * @return string 85 | */ 86 | public function getField() 87 | { 88 | return $this->Field; 89 | } 90 | 91 | /** 92 | * Generated from protobuf field string Field = 2; 93 | * @param string $var 94 | * @return $this 95 | */ 96 | public function setField($var) 97 | { 98 | GPBUtil::checkString($var, True); 99 | $this->Field = $var; 100 | 101 | return $this; 102 | } 103 | 104 | /** 105 | * Generated from protobuf field uint64 Shard = 3; 106 | * @return int|string 107 | */ 108 | public function getShard() 109 | { 110 | return $this->Shard; 111 | } 112 | 113 | /** 114 | * Generated from protobuf field uint64 Shard = 3; 115 | * @param int|string $var 116 | * @return $this 117 | */ 118 | public function setShard($var) 119 | { 120 | GPBUtil::checkUint64($var); 121 | $this->Shard = $var; 122 | 123 | return $this; 124 | } 125 | 126 | /** 127 | * Generated from protobuf field repeated uint64 ColumnIDs = 5; 128 | * @return \Google\Protobuf\Internal\RepeatedField 129 | */ 130 | public function getColumnIDs() 131 | { 132 | return $this->ColumnIDs; 133 | } 134 | 135 | /** 136 | * Generated from protobuf field repeated uint64 ColumnIDs = 5; 137 | * @param int[]|string[]|\Google\Protobuf\Internal\RepeatedField $var 138 | * @return $this 139 | */ 140 | public function setColumnIDs($var) 141 | { 142 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::UINT64); 143 | $this->ColumnIDs = $arr; 144 | 145 | return $this; 146 | } 147 | 148 | /** 149 | * Generated from protobuf field repeated string ColumnKeys = 7; 150 | * @return \Google\Protobuf\Internal\RepeatedField 151 | */ 152 | public function getColumnKeys() 153 | { 154 | return $this->ColumnKeys; 155 | } 156 | 157 | /** 158 | * Generated from protobuf field repeated string ColumnKeys = 7; 159 | * @param string[]|\Google\Protobuf\Internal\RepeatedField $var 160 | * @return $this 161 | */ 162 | public function setColumnKeys($var) 163 | { 164 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); 165 | $this->ColumnKeys = $arr; 166 | 167 | return $this; 168 | } 169 | 170 | /** 171 | * Generated from protobuf field repeated int64 Values = 6; 172 | * @return \Google\Protobuf\Internal\RepeatedField 173 | */ 174 | public function getValues() 175 | { 176 | return $this->Values; 177 | } 178 | 179 | /** 180 | * Generated from protobuf field repeated int64 Values = 6; 181 | * @param int[]|string[]|\Google\Protobuf\Internal\RepeatedField $var 182 | * @return $this 183 | */ 184 | public function setValues($var) 185 | { 186 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT64); 187 | $this->Values = $arr; 188 | 189 | return $this; 190 | } 191 | 192 | } 193 | 194 | -------------------------------------------------------------------------------- /src/Storage/Pilosa/Proto/ImportRequest.php: -------------------------------------------------------------------------------- 1 | ImportRequest 13 | */ 14 | class ImportRequest extends \Google\Protobuf\Internal\Message 15 | { 16 | /** 17 | * Generated from protobuf field string Index = 1; 18 | */ 19 | protected $Index = ''; 20 | /** 21 | * Generated from protobuf field string Field = 2; 22 | */ 23 | protected $Field = ''; 24 | /** 25 | * Generated from protobuf field uint64 Shard = 3; 26 | */ 27 | protected $Shard = 0; 28 | /** 29 | * Generated from protobuf field repeated uint64 RowIDs = 4; 30 | */ 31 | private $RowIDs; 32 | /** 33 | * Generated from protobuf field repeated uint64 ColumnIDs = 5; 34 | */ 35 | private $ColumnIDs; 36 | /** 37 | * Generated from protobuf field repeated string RowKeys = 7; 38 | */ 39 | private $RowKeys; 40 | /** 41 | * Generated from protobuf field repeated string ColumnKeys = 8; 42 | */ 43 | private $ColumnKeys; 44 | /** 45 | * Generated from protobuf field repeated int64 Timestamps = 6; 46 | */ 47 | private $Timestamps; 48 | 49 | /** 50 | * Constructor. 51 | * 52 | * @param array $data { 53 | * Optional. Data for populating the Message object. 54 | * 55 | * @type string $Index 56 | * @type string $Field 57 | * @type int|string $Shard 58 | * @type int[]|string[]|\Google\Protobuf\Internal\RepeatedField $RowIDs 59 | * @type int[]|string[]|\Google\Protobuf\Internal\RepeatedField $ColumnIDs 60 | * @type string[]|\Google\Protobuf\Internal\RepeatedField $RowKeys 61 | * @type string[]|\Google\Protobuf\Internal\RepeatedField $ColumnKeys 62 | * @type int[]|string[]|\Google\Protobuf\Internal\RepeatedField $Timestamps 63 | * } 64 | */ 65 | public function __construct($data = NULL) { 66 | \App\Storage\Pilosa\Proto\GPBMetadata\PBPublic::initOnce(); 67 | parent::__construct($data); 68 | } 69 | 70 | /** 71 | * Generated from protobuf field string Index = 1; 72 | * @return string 73 | */ 74 | public function getIndex() 75 | { 76 | return $this->Index; 77 | } 78 | 79 | /** 80 | * Generated from protobuf field string Index = 1; 81 | * @param string $var 82 | * @return $this 83 | */ 84 | public function setIndex($var) 85 | { 86 | GPBUtil::checkString($var, True); 87 | $this->Index = $var; 88 | 89 | return $this; 90 | } 91 | 92 | /** 93 | * Generated from protobuf field string Field = 2; 94 | * @return string 95 | */ 96 | public function getField() 97 | { 98 | return $this->Field; 99 | } 100 | 101 | /** 102 | * Generated from protobuf field string Field = 2; 103 | * @param string $var 104 | * @return $this 105 | */ 106 | public function setField($var) 107 | { 108 | GPBUtil::checkString($var, True); 109 | $this->Field = $var; 110 | 111 | return $this; 112 | } 113 | 114 | /** 115 | * Generated from protobuf field uint64 Shard = 3; 116 | * @return int|string 117 | */ 118 | public function getShard() 119 | { 120 | return $this->Shard; 121 | } 122 | 123 | /** 124 | * Generated from protobuf field uint64 Shard = 3; 125 | * @param int|string $var 126 | * @return $this 127 | */ 128 | public function setShard($var) 129 | { 130 | GPBUtil::checkUint64($var); 131 | $this->Shard = $var; 132 | 133 | return $this; 134 | } 135 | 136 | /** 137 | * Generated from protobuf field repeated uint64 RowIDs = 4; 138 | * @return \Google\Protobuf\Internal\RepeatedField 139 | */ 140 | public function getRowIDs() 141 | { 142 | return $this->RowIDs; 143 | } 144 | 145 | /** 146 | * Generated from protobuf field repeated uint64 RowIDs = 4; 147 | * @param int[]|string[]|\Google\Protobuf\Internal\RepeatedField $var 148 | * @return $this 149 | */ 150 | public function setRowIDs($var) 151 | { 152 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::UINT64); 153 | $this->RowIDs = $arr; 154 | 155 | return $this; 156 | } 157 | 158 | /** 159 | * Generated from protobuf field repeated uint64 ColumnIDs = 5; 160 | * @return \Google\Protobuf\Internal\RepeatedField 161 | */ 162 | public function getColumnIDs() 163 | { 164 | return $this->ColumnIDs; 165 | } 166 | 167 | /** 168 | * Generated from protobuf field repeated uint64 ColumnIDs = 5; 169 | * @param int[]|string[]|\Google\Protobuf\Internal\RepeatedField $var 170 | * @return $this 171 | */ 172 | public function setColumnIDs($var) 173 | { 174 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::UINT64); 175 | $this->ColumnIDs = $arr; 176 | 177 | return $this; 178 | } 179 | 180 | /** 181 | * Generated from protobuf field repeated string RowKeys = 7; 182 | * @return \Google\Protobuf\Internal\RepeatedField 183 | */ 184 | public function getRowKeys() 185 | { 186 | return $this->RowKeys; 187 | } 188 | 189 | /** 190 | * Generated from protobuf field repeated string RowKeys = 7; 191 | * @param string[]|\Google\Protobuf\Internal\RepeatedField $var 192 | * @return $this 193 | */ 194 | public function setRowKeys($var) 195 | { 196 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); 197 | $this->RowKeys = $arr; 198 | 199 | return $this; 200 | } 201 | 202 | /** 203 | * Generated from protobuf field repeated string ColumnKeys = 8; 204 | * @return \Google\Protobuf\Internal\RepeatedField 205 | */ 206 | public function getColumnKeys() 207 | { 208 | return $this->ColumnKeys; 209 | } 210 | 211 | /** 212 | * Generated from protobuf field repeated string ColumnKeys = 8; 213 | * @param string[]|\Google\Protobuf\Internal\RepeatedField $var 214 | * @return $this 215 | */ 216 | public function setColumnKeys($var) 217 | { 218 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); 219 | $this->ColumnKeys = $arr; 220 | 221 | return $this; 222 | } 223 | 224 | /** 225 | * Generated from protobuf field repeated int64 Timestamps = 6; 226 | * @return \Google\Protobuf\Internal\RepeatedField 227 | */ 228 | public function getTimestamps() 229 | { 230 | return $this->Timestamps; 231 | } 232 | 233 | /** 234 | * Generated from protobuf field repeated int64 Timestamps = 6; 235 | * @param int[]|string[]|\Google\Protobuf\Internal\RepeatedField $var 236 | * @return $this 237 | */ 238 | public function setTimestamps($var) 239 | { 240 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT64); 241 | $this->Timestamps = $arr; 242 | 243 | return $this; 244 | } 245 | 246 | } 247 | 248 | -------------------------------------------------------------------------------- /src/Storage/Pilosa/Proto/QueryResult.php: -------------------------------------------------------------------------------- 1 | QueryResult 13 | */ 14 | class QueryResult extends \Google\Protobuf\Internal\Message 15 | { 16 | /** 17 | * Generated from protobuf field uint32 Type = 6; 18 | */ 19 | protected $Type = 0; 20 | /** 21 | * Generated from protobuf field .Row Row = 1; 22 | */ 23 | protected $Row = null; 24 | /** 25 | * Generated from protobuf field uint64 N = 2; 26 | */ 27 | protected $N = 0; 28 | /** 29 | * Generated from protobuf field repeated .Pair Pairs = 3; 30 | */ 31 | private $Pairs; 32 | /** 33 | * Generated from protobuf field bool Changed = 4; 34 | */ 35 | protected $Changed = false; 36 | /** 37 | * Generated from protobuf field .ValCount ValCount = 5; 38 | */ 39 | protected $ValCount = null; 40 | /** 41 | * Generated from protobuf field repeated uint64 RowIDs = 7; 42 | */ 43 | private $RowIDs; 44 | /** 45 | * Generated from protobuf field repeated .GroupCount GroupCounts = 8; 46 | */ 47 | private $GroupCounts; 48 | /** 49 | * Generated from protobuf field .RowIdentifiers RowIdentifiers = 9; 50 | */ 51 | protected $RowIdentifiers = null; 52 | 53 | /** 54 | * Constructor. 55 | * 56 | * @param array $data { 57 | * Optional. Data for populating the Message object. 58 | * 59 | * @type int $Type 60 | * @type \App\Storage\Pilosa\Proto\Row $Row 61 | * @type int|string $N 62 | * @type \App\Storage\Pilosa\Proto\Pair[]|\Google\Protobuf\Internal\RepeatedField $Pairs 63 | * @type bool $Changed 64 | * @type \App\Storage\Pilosa\Proto\ValCount $ValCount 65 | * @type int[]|string[]|\Google\Protobuf\Internal\RepeatedField $RowIDs 66 | * @type \App\Storage\Pilosa\Proto\GroupCount[]|\Google\Protobuf\Internal\RepeatedField $GroupCounts 67 | * @type \App\Storage\Pilosa\Proto\RowIdentifiers $RowIdentifiers 68 | * } 69 | */ 70 | public function __construct($data = NULL) { 71 | \App\Storage\Pilosa\Proto\GPBMetadata\PBPublic::initOnce(); 72 | parent::__construct($data); 73 | } 74 | 75 | /** 76 | * Generated from protobuf field uint32 Type = 6; 77 | * @return int 78 | */ 79 | public function getType() 80 | { 81 | return $this->Type; 82 | } 83 | 84 | /** 85 | * Generated from protobuf field uint32 Type = 6; 86 | * @param int $var 87 | * @return $this 88 | */ 89 | public function setType($var) 90 | { 91 | GPBUtil::checkUint32($var); 92 | $this->Type = $var; 93 | 94 | return $this; 95 | } 96 | 97 | /** 98 | * Generated from protobuf field .Row Row = 1; 99 | * @return \App\Storage\Pilosa\Proto\Row 100 | */ 101 | public function getRow() 102 | { 103 | return isset($this->Row) ? $this->Row : null; 104 | } 105 | 106 | public function hasRow() 107 | { 108 | return isset($this->Row); 109 | } 110 | 111 | public function clearRow() 112 | { 113 | unset($this->Row); 114 | } 115 | 116 | /** 117 | * Generated from protobuf field .Row Row = 1; 118 | * @param \App\Storage\Pilosa\Proto\Row $var 119 | * @return $this 120 | */ 121 | public function setRow($var) 122 | { 123 | GPBUtil::checkMessage($var, \App\Storage\Pilosa\Proto\Row::class); 124 | $this->Row = $var; 125 | 126 | return $this; 127 | } 128 | 129 | /** 130 | * Generated from protobuf field uint64 N = 2; 131 | * @return int|string 132 | */ 133 | public function getN() 134 | { 135 | return $this->N; 136 | } 137 | 138 | /** 139 | * Generated from protobuf field uint64 N = 2; 140 | * @param int|string $var 141 | * @return $this 142 | */ 143 | public function setN($var) 144 | { 145 | GPBUtil::checkUint64($var); 146 | $this->N = $var; 147 | 148 | return $this; 149 | } 150 | 151 | /** 152 | * Generated from protobuf field repeated .Pair Pairs = 3; 153 | * @return \Google\Protobuf\Internal\RepeatedField 154 | */ 155 | public function getPairs() 156 | { 157 | return $this->Pairs; 158 | } 159 | 160 | /** 161 | * Generated from protobuf field repeated .Pair Pairs = 3; 162 | * @param \App\Storage\Pilosa\Proto\Pair[]|\Google\Protobuf\Internal\RepeatedField $var 163 | * @return $this 164 | */ 165 | public function setPairs($var) 166 | { 167 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \App\Storage\Pilosa\Proto\Pair::class); 168 | $this->Pairs = $arr; 169 | 170 | return $this; 171 | } 172 | 173 | /** 174 | * Generated from protobuf field bool Changed = 4; 175 | * @return bool 176 | */ 177 | public function getChanged() 178 | { 179 | return $this->Changed; 180 | } 181 | 182 | /** 183 | * Generated from protobuf field bool Changed = 4; 184 | * @param bool $var 185 | * @return $this 186 | */ 187 | public function setChanged($var) 188 | { 189 | GPBUtil::checkBool($var); 190 | $this->Changed = $var; 191 | 192 | return $this; 193 | } 194 | 195 | /** 196 | * Generated from protobuf field .ValCount ValCount = 5; 197 | * @return \App\Storage\Pilosa\Proto\ValCount 198 | */ 199 | public function getValCount() 200 | { 201 | return isset($this->ValCount) ? $this->ValCount : null; 202 | } 203 | 204 | public function hasValCount() 205 | { 206 | return isset($this->ValCount); 207 | } 208 | 209 | public function clearValCount() 210 | { 211 | unset($this->ValCount); 212 | } 213 | 214 | /** 215 | * Generated from protobuf field .ValCount ValCount = 5; 216 | * @param \App\Storage\Pilosa\Proto\ValCount $var 217 | * @return $this 218 | */ 219 | public function setValCount($var) 220 | { 221 | GPBUtil::checkMessage($var, \App\Storage\Pilosa\Proto\ValCount::class); 222 | $this->ValCount = $var; 223 | 224 | return $this; 225 | } 226 | 227 | /** 228 | * Generated from protobuf field repeated uint64 RowIDs = 7; 229 | * @return \Google\Protobuf\Internal\RepeatedField 230 | */ 231 | public function getRowIDs() 232 | { 233 | return $this->RowIDs; 234 | } 235 | 236 | /** 237 | * Generated from protobuf field repeated uint64 RowIDs = 7; 238 | * @param int[]|string[]|\Google\Protobuf\Internal\RepeatedField $var 239 | * @return $this 240 | */ 241 | public function setRowIDs($var) 242 | { 243 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::UINT64); 244 | $this->RowIDs = $arr; 245 | 246 | return $this; 247 | } 248 | 249 | /** 250 | * Generated from protobuf field repeated .GroupCount GroupCounts = 8; 251 | * @return \Google\Protobuf\Internal\RepeatedField 252 | */ 253 | public function getGroupCounts() 254 | { 255 | return $this->GroupCounts; 256 | } 257 | 258 | /** 259 | * Generated from protobuf field repeated .GroupCount GroupCounts = 8; 260 | * @param \App\Storage\Pilosa\Proto\GroupCount[]|\Google\Protobuf\Internal\RepeatedField $var 261 | * @return $this 262 | */ 263 | public function setGroupCounts($var) 264 | { 265 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \App\Storage\Pilosa\Proto\GroupCount::class); 266 | $this->GroupCounts = $arr; 267 | 268 | return $this; 269 | } 270 | 271 | /** 272 | * Generated from protobuf field .RowIdentifiers RowIdentifiers = 9; 273 | * @return \App\Storage\Pilosa\Proto\RowIdentifiers 274 | */ 275 | public function getRowIdentifiers() 276 | { 277 | return isset($this->RowIdentifiers) ? $this->RowIdentifiers : null; 278 | } 279 | 280 | public function hasRowIdentifiers() 281 | { 282 | return isset($this->RowIdentifiers); 283 | } 284 | 285 | public function clearRowIdentifiers() 286 | { 287 | unset($this->RowIdentifiers); 288 | } 289 | 290 | /** 291 | * Generated from protobuf field .RowIdentifiers RowIdentifiers = 9; 292 | * @param \App\Storage\Pilosa\Proto\RowIdentifiers $var 293 | * @return $this 294 | */ 295 | public function setRowIdentifiers($var) 296 | { 297 | GPBUtil::checkMessage($var, \App\Storage\Pilosa\Proto\RowIdentifiers::class); 298 | $this->RowIdentifiers = $var; 299 | 300 | return $this; 301 | } 302 | 303 | } 304 | 305 | --------------------------------------------------------------------------------