Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pixelfederation/druid-php
Druid driver for PHP
https://github.com/pixelfederation/druid-php
Last synced: 3 months ago
JSON representation
Druid driver for PHP
- Host: GitHub
- URL: https://github.com/pixelfederation/druid-php
- Owner: pixelfederation
- License: other
- Created: 2016-07-13T10:46:46.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-16T13:19:41.000Z (over 7 years ago)
- Last Synced: 2024-02-14T22:31:52.821Z (9 months ago)
- Language: PHP
- Size: 223 KB
- Stars: 34
- Watchers: 11
- Forks: 14
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Druid PHP driver
This library provider a [Druid](http://druid.io/) PHP Driver.
## [License](LICENSE)
## Instalation
Installation of this library uses composer. For composer documentation, please refer to
[getcomposer.org](http://getcomposer.org/).Put the following into your composer.json
{
"require": {
"pixelfederation/druid-php": "dev-master"
}
}## Current State
Currently this driver supports **GroupBy, TopN** and **Timeseries** aggregation types, and **Search** query type.
Everybody is welcome to create pull requests to implement some of the missing things.Also, some unit tests are bound to running on our internal Druid instance, there is plan to change it to docker container
with some testing data.## Usage
### Average aggregation
```php
'http',
'host' => 'localhost',
'port' => '9999',
'path' => '/druid/v2',
'proxy' => 'tcp://127.0.0.1:8080', // default null
'timeout' => 3.7, // in seconds - default null
]
);$queryBuilder = $druid->createQueryBuilder(AbstractQuery::TYPE_GROUP_BY); // or AbstractQuery::TYPE_TIMESERIES
$queryBuilder->setDataSource('kpi_registrations_v1');
$queryBuilder->addInterval(new \DateTime('2000-01-01'), new \DateTime());$granularity = new PeriodGranularity('P1D', 'UTC');
$queryBuilder->setGranularity($granularity);$queryBuilder->addAggregator($queryBuilder->aggregator()->count('count_rows'));
$queryBuilder->addAggregator($queryBuilder->aggregator()->doubleSum('sum_rows', 'event_count_metric'));
$queryBuilder->addAggregator($queryBuilder->aggregator()->hyperUnique('registrations', 'registrations'));// Only include for GroupBy queries
$queryBuilder->addDimension('project', 'project');$queryBuilder->addPostAggregator(
$queryBuilder->postAggregator()->arithmeticPostAggregator(
'average',
'/',
[
$queryBuilder->postAggregator()->fieldAccessPostAggregator('sum_rows', 'sum_rows'),
$queryBuilder->postAggregator()->fieldAccessPostAggregator('count_rows', 'count_rows')
]
)
);$response = $druid->send($queryBuilder->getQuery());
```## Contribution
If you'd like to contribtue, we strongly recommend to run
```bash
./bin/setup-dev
```from the project directory. This script will set up a commit hook, which checks the PSR/2 coding standards
using [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer) and also runs PHP linter and
PHP Mess Detector [PHPMD](http://phpmd.org/)## TODO
1. **Query types**
* Metadata Queries
* Time Boundary
* Segment Metadata
* Datasource Metadata
2. **Components**
* Data source
* query
* Aggregations
* Cardinality aggregator