/**
  * @return integer
  */
 public function getCount()
 {
     if ($this->_iterator && $this->get('count') === null) {
         $this->_iterator->init();
         $this->set('count', (int) $this->_iterator->getTotalCount());
     }
     return parent::getCount();
 }
 protected function _stopIterator()
 {
     $this->_buffer = null;
     $this->_bufferEnd = true;
     $this->_bufferItemIndex = 0;
     parent::_stopIterator();
 }
 public function __construct($params = array())
 {
     parent::__construct($params);
     if (!isset($params['mapper'])) {
         throw new InvalidArgumentException("Mongo mapper must be defined");
     }
     $mapper = $params['mapper'];
     unset($params['mapper']);
     if (is_string($mapper)) {
         $mapper = $mapper::getInstance();
     }
     if (!$mapper instanceof MongoAbstractStreamMapper) {
         throw new InvalidArgumentException("Mapper must be a mongo mapper");
     }
     $this->_mapper = $mapper;
     $this->_options = $params;
 }