Additional assert for _safeAppendToBuffer

This commit is contained in:
Slava Kim
2014-02-23 17:51:51 -08:00
parent 622d61f0a7
commit 9d4783e4fc

View File

@@ -174,13 +174,16 @@ _.extend(OplogObserveDriver.prototype, {
self._multiplexer.removed(id);
if (! self._limit)
return;
// xcxc size on heaps should be cached to O(1)
if (self._published.size() < self._limit) {
// The unpublished buffer is empty iff published contains the whole
// matching set, i.e. number of matching documents is less or equal to the
// queries limit.
if (! self._unpublishedBuffer.size())
if (! self._unpublishedBuffer.size()) {
// Assertion of the statement above
if (! self._safeAppendToBuffer && self._phase !== PHASE.QUERYING)
throw new Error("At this phase, buffer can be empty only if published contains the whole matching set");
return;
}
var newDocId = self._unpublishedBuffer.minElementId();
var newDoc = self._unpublishedBuffer.get(newDocId);