MCPcopy Index your code
hub / github.com/django-haystack/django-haystack / _manual_iter

Method _manual_iter

haystack/query.py:126–153  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

124 return len(self._result_cache) > 0
125
126 def _manual_iter(self):
127 # If we're here, our cache isn't fully populated.
128 # For efficiency, fill the cache as we go if we run out of results.
129 # Also, this can't be part of the __iter__ method due to Python's rules
130 # about generator functions.
131 current_position = 0
132 current_cache_max = 0
133
134 while True:
135 if len(self._result_cache) > 0:
136 try:
137 current_cache_max = self._result_cache.index(None)
138 except ValueError:
139 current_cache_max = len(self._result_cache)
140
141 while current_position < current_cache_max:
142 yield self._result_cache[current_position]
143 current_position += 1
144
145 if self._cache_is_full():
146 return
147
148 # We've run out of results and haven't hit our limit.
149 # Fill more of the cache.
150 if not self._fill_cache(
151 current_position, current_position + ITERATOR_LOAD_PER_QUERY
152 ):
153 return
154
155 def post_process_results(self, results):
156 to_cache = []

Callers 11

__iter__Method · 0.95
test_manual_iterMethod · 0.80
test_manual_iterMethod · 0.80
test_manual_iterMethod · 0.80
test_manual_iterMethod · 0.80
test_manual_iterMethod · 0.80
test_manual_iterMethod · 0.80

Calls 2

_cache_is_fullMethod · 0.95
_fill_cacheMethod · 0.95

Tested by 10

test_manual_iterMethod · 0.64
test_manual_iterMethod · 0.64
test_manual_iterMethod · 0.64
test_manual_iterMethod · 0.64
test_manual_iterMethod · 0.64
test_manual_iterMethod · 0.64