Move more inconsistent code to mongodb and orm implementations
This commit is contained in:
parent
1ba79f83cf
commit
05ab288051
3 changed files with 43 additions and 1 deletions
|
|
@ -44,7 +44,7 @@ abstract class AbstractDoctrineProvider implements ProviderInterface
|
|||
|
||||
$stepStartTime = microtime(true);
|
||||
$documents = array();
|
||||
$objects = $queryBuilder->limit($this->options['batch_size'])->skip($offset)->getQuery()->execute()->toArray();
|
||||
$objects = $this->fetchSlice($queryBuilder, $this->options['batch_size'], $offset);
|
||||
|
||||
foreach ($objects as $object) {
|
||||
try {
|
||||
|
|
@ -69,10 +69,21 @@ abstract class AbstractDoctrineProvider implements ProviderInterface
|
|||
/**
|
||||
* Counts the objects of a query builder
|
||||
*
|
||||
* @param queryBuilder
|
||||
* @return int
|
||||
**/
|
||||
protected abstract function countObjects($queryBuilder);
|
||||
|
||||
/**
|
||||
* Fetches a slice of objects
|
||||
*
|
||||
* @param queryBuilder
|
||||
* @param int limit
|
||||
* @param int offset
|
||||
* @return array of objects
|
||||
**/
|
||||
protected abstract function fetchSlice($queryBuilder, $limit, $offset);
|
||||
|
||||
/**
|
||||
* Creates the query buider used to fetch the documents to index
|
||||
*
|
||||
|
|
|
|||
|
|
@ -7,10 +7,24 @@ class DoctrineMongoDBProvider extends AbstractDoctrineProvider
|
|||
/**
|
||||
* Counts the objects of a query builder
|
||||
*
|
||||
* @param queryBuilder
|
||||
* @return int
|
||||
**/
|
||||
protected function countObjects($queryBuilder)
|
||||
{
|
||||
return $queryBuilder->getQuery()->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a slice of objects
|
||||
*
|
||||
* @param queryBuilder
|
||||
* @param int limit
|
||||
* @param int offset
|
||||
* @return array of objects
|
||||
**/
|
||||
protected function fetchSlice($queryBuilder, $limit, $offset)
|
||||
{
|
||||
return $queryBuilder->limit($limit)->skip($offset)->getQuery()->execute()->toArray();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,10 +7,27 @@ class DoctrineORMProvider extends AbstractDoctrineProvider
|
|||
/**
|
||||
* Counts the objects of a query builder
|
||||
*
|
||||
* @param queryBuilder
|
||||
* @return int
|
||||
**/
|
||||
protected function countObjects($queryBuilder)
|
||||
{
|
||||
return $queryBuilder->count()->getQuery()->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a slice of objects
|
||||
*
|
||||
* @param queryBuilder
|
||||
* @param int limit
|
||||
* @param int offset
|
||||
* @return array of objects
|
||||
**/
|
||||
protected function fetchSlice($queryBuilder, $limit, $offset)
|
||||
{
|
||||
$queryBuilder->setFirstResult($offset);
|
||||
$queryBuilder->setMaxResults($limit);
|
||||
|
||||
return $queryBuilder->getQuery()->getArrayResult();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue