Skip to content

Commit

Permalink
Release Scroll memory before calling ES for next recordset (#1740)
Browse files Browse the repository at this point in the history
  • Loading branch information
rattuscz authored and thePanz committed Jan 13, 2020
1 parent 642d932 commit 9392fb0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ All notable changes to this project will be documented in this file based on the

### Improvements

* Scroll releases previous ResultSet from memory before calling ES for next data batch [#1740](https://github.com/ruflin/Elastica/pull/1740)

### Deprecated

## [7.0.0-beta2](https://github.com/ruflin/Elastica/compare/7.0.0-beta1...7.0.0-beta2)
Expand Down
3 changes: 2 additions & 1 deletion lib/Elastica/Scroll.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function current(): ?ResultSet
*/
public function next()
{
$this->_currentResultSet = null;
if ($this->currentPage < $this->totalPages) {
$this->_saveOptions();

Expand All @@ -81,7 +82,6 @@ public function next()
} else {
// If there are no pages left, we do not need to query ES.
$this->clear();
$this->_currentResultSet = null;
}
}

Expand Down Expand Up @@ -121,6 +121,7 @@ public function rewind(): void

$this->_search->setOption(Search::OPTION_SCROLL, $this->expiryTime);
$this->_search->setOption(Search::OPTION_SCROLL_ID, null);
$this->_currentResultSet = null;
$this->_setScrollId($this->_search->search());

$this->_revertOptions();
Expand Down

0 comments on commit 9392fb0

Please sign in to comment.