private List<JsonDocument> GetDocsFromBatchWithPossibleDuplicates(Etag etag)
{
var result = new List<JsonDocument>();
bool docsLoaded;
do
{
var nextEtagToIndex = GetNextDocEtag(etag);
var firstEtagInQueue = prefetchingQueue.NextDocumentETag();
if (nextEtagToIndex != firstEtagInQueue)
{
if (TryLoadDocumentsFromFutureBatches(nextEtagToIndex) == false)
{
LoadDocumentsFromDisk(etag, firstEtagInQueue); // here we _intentionally_ use the current etag, not the next one
}
}
docsLoaded = TryGetDocumentsFromQueue(nextEtagToIndex, ref result);
if (docsLoaded)
etag = result[result.Count - 1].Etag;
} while (result.Count < autoTuner.NumberOfItemsToIndexInSingleBatch && docsLoaded);
return result;
}