allow disk in query

This commit is contained in:
Kevin Darby committed 2019-12-12 18:19:08 -05:00
1 parent ef874dda7e
commit 3ba17f1c87
2 files changed
+36 -9

No files matched your search

@@ -112,7 +112,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 5,
"metadata": {
"scrolled": true
},
@@ -131,7 +131,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 6,
"metadata": {
"scrolled": true
},
@@ -144,7 +144,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
@@ -220,7 +220,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
@@ -234,11 +234,37 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {
"scrolled": true
},
"outputs": [],
"outputs": [
{
"ename": "Unhandled Exception",
"evalue": "Command aggregate failed: Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in..",
"output_type": "error",
"traceback": [
"Unhandled Exception",
"Command aggregate failed: Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in..",
" at MongoDB.Driver.Linq.MongoQueryProviderImpl`1.Execute(Expression expression)",
" at MongoDB.Driver.Linq.MongoQueryableImpl`2.GetEnumerator()",
" at bts.history.Query.stream_data[T,U](IEnumerable`1[] datastream, Func`3 function)+MoveNext() in c:\\code\\bts\\spark\\src\\client\\spark_historical\\Query\\Query.cs:line 70",
" at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()",
" at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()",
" at System.Linq.Enumerable.EnumerablePartition`1.MoveNext()",
" at Microsoft.DotNet.Interactive.Rendering.HtmlFormatter`1.<>c__DisplayClass7_0.<CreateForSequence>b__4(T instance, TextWriter writer)",
" at Microsoft.DotNet.Interactive.Rendering.HtmlFormatter`1.Format(T instance, TextWriter writer)",
" at Microsoft.DotNet.Interactive.Rendering.TypeFormatter`1.Microsoft.DotNet.Interactive.Rendering.ITypeFormatter.Format(Object instance, TextWriter writer)",
" at Microsoft.DotNet.Interactive.Rendering.Formatter`1.FormatTo(T obj, TextWriter writer, String mimeType)",
" at Microsoft.DotNet.Interactive.Rendering.Formatter.FormatTo[T](T obj, TextWriter writer, String mimeType)",
" at Microsoft.DotNet.Interactive.Rendering.Formatter.ToDisplayString(Object obj, String mimeType)",
" at Microsoft.DotNet.Interactive.Kernel.display(Object value, String mimeType)",
" at Submission#10.<<Initialize>>d__0.MoveNext()",
"--- End of stack trace from previous location where exception was thrown ---",
" at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)"
]
}
],
"source": [
"var fill_model = new FIFOModel(new Bucket(20_000, 20_001));\n",
"var stream = run_algo<HistoryRow,AlgoReport>(algo_type, fill_model, algo_params,\n",
+4 -3
View File
@@ -35,15 +35,16 @@ namespace bts.history
public IMongoQueryable<T> queryable<T>(string collection)
{
var coll = _db.GetCollection<T>(collection);
IMongoQueryable<T> res = coll.AsQueryable();
IMongoQueryable<T> res = queryable(coll);
return res;
}
public IMongoQueryable<T> queryable<T>(IMongoCollection<T> collection) => collection.AsQueryable();
public IMongoQueryable<T> queryable<T>(IMongoCollection<T> collection) =>
collection.AsQueryable(new AggregateOptions { AllowDiskUse = true } );
public IMongoQueryable<H> timeseries<H>(IMongoCollection<H> collection, DateTime begin, DateTime end, bool use_sending_time = true)
where H : IHasTimestamp
{
IMongoQueryable<H> res = collection.AsQueryable();
IMongoQueryable<H> res = queryable(collection);
Expression<Func<H, bool>> timeexpr = null;
begin = begin.ToUniversalTime();
end = end.ToUniversalTime();