public void UpdateAutoThrottler(List<JsonDocument> jsonDocs, TimeSpan indexingDuration)
{
int currentBatchSize = autoTuner.NumberOfItemsToIndexInSingleBatch;
int futureLen = futureIndexBatches.Values.Sum(x =>
{
if (x.Task.IsCompleted)
{
return x.Task.Result.Count;
}
return currentBatchSize / 15;
});
long futureSize = futureIndexBatches.Values.Sum(x =>
{
if (x.Task.IsCompleted)
{
var jsonResults = x.Task.Result;
return jsonResults.Sum(s => (long)s.SerializedSizeOnDisk);
}
return currentBatchSize * 256;
});
autoTuner.AutoThrottleBatchSize(
jsonDocs.Count + futureLen,
futureSize + jsonDocs.Sum(x => (long)x.SerializedSizeOnDisk),
indexingDuration);
}
}