Download the PHP package easybib/generator-processes without Composer
On this page you can find all versions of the php package easybib/generator-processes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download easybib/generator-processes
More information about easybib/generator-processes
Files in easybib/generator-processes
Package generator-processes
Short Description A collection of processes for iterators
License BSD-2-Clause
Informations about the package generator-processes
easybib/generator-processes
A collection of processes operating on iterators, usually implemented as generators
Processes
All processes are callables which operate on an input traversable (typically an iterator) and return an iterator.
Bulk adding Elastica documents
\EasyBib\Process\Elastica::write
uses Elastica to bulk write arrays of
documents to Elasticsearch using an Elastica type. You may use
Elastica::bindWrite($type)
to retrieve a method which accepts only an
iterator of document sets.
use Easybib\Process\Elastica;
$documentGroups = [
[$doc1, $doc2, $doc3],
[$doc4, $doc5],
];
$outputIterator = Elastica::write($elasticaType, $documentGroups);
// equivalent to
$write = Elastica::bindWrite($elasticaType);
$outputIterator = $write($documentGroups);
// $documentGroups == iterator_to_array($outputIterator);
Searching Elastica documents
EasyBib\Process\Elastica::search
uses Elastica to search for a set of
documents matching a given search query. You may use
Elastica::bindSearch($type, $limit)
to retrieve a method which accepts only
a search query string and an initial search offset.
use Easybib\Process\Elastica;
$iterator = Elastica::search($elasticaIndex, 100, $keywords, 0);
// equivalent to
$search = Elastica::bindSearch($elasticaIndex, 100);
$iterator = $search($keywords, 0);
Bulkify Transformation
\EasyBib\Process\Transform::bulkify
aggregates the input iterator into arrays.
use Easybib\Process\Transform;
$items = [1, 2, 3, 4];
$outputIterator = Transform::bulkify(2, $items);
// equivalent to
$bulkify = Transform::bindBulkify(2);
$outputIterator = $bulkify($items);
// [[1, 2], [3, 4]] == iterator_to_array($outputIterator)
Unbulkify Transformation
Flattens the input by a single level, thus reversing a bulkify operation.
use Easybib\Process\Transform;
$bulks = [[1, 2], [3, 4], [5, ['some', 'array']]]];
$outputIterator = Transform::unbulkify($bulks);
// [1, 2, 3, 4, 5, ['some', 'array']] == iterator_to_array($outputIterator)