दे रही है मैं एक PLINQ क्वेरी चल रहा हूँ इस प्रकार है:PLINQ क्वेरी अतिप्रवाह अपवाद
ParallelQuery<string> winningCombos = from n in nextComboMaker.GetNextCombo()
.AsParallel().WithCancellation(_cancelSource.Token)
where ComboWasAWinner(n)
select n;
ConcurrentBag<string> wins = new ConcurrentBag<string>();
foreach (var winningCombo in winningCombos)
{
wins.Add(winningCombo);
if (wins.Count == _maxWinsAllowed)
break;
}
GetNextCombo विधि बस, अक्षरों और संख्याओं का अगले संयोजन लौटा रहा है अरबों/अरबों संभावनाओं को साथ।
अब इस अपवाद फेंक रहा है जब मैं कोई Int32 के अनुमत आकार से अधिक से अधिक संयोजन की एक श्रेणी चुनें, यह हमेशा फेंकता है जब कॉम्बो इसे चलाने है के काउंटर 2147483584.
है यकीन है कि यह कुछ भी नहीं है मैं कर दिया है
System.AggregateException was unhandled by user code
Message=One or more errors occurred.
Source=System.Core
StackTrace:
at System.Linq.Parallel.QueryTaskGroupState.QueryEnd(Boolean userInitiatedDispose)
at System.Linq.Parallel.MergeExecutor`1.Execute[TKey](PartitionedStream`2 partitions, Boolean ignoreOutput, ParallelMergeOptions options, TaskScheduler taskScheduler, Boolean isOrdered, CancellationState cancellationState, Int32 queryId)
at System.Linq.Parallel.PartitionedStreamMerger`1.Receive[TKey](PartitionedStream`2 partitionedStream)
at System.Linq.Parallel.ForAllOperator`1.WrapPartitionedStream[TKey](PartitionedStream`2 inputStream, IPartitionedStreamRecipient`1 recipient, Boolean preferStriping, QuerySettings settings)
at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.ChildResultsRecipient.Receive[TKey](PartitionedStream`2 inputStream)
at System.Linq.Parallel.WhereQueryOperator`1.WrapPartitionedStream[TKey](PartitionedStream`2 inputStream, IPartitionedStreamRecipient`1 recipient, Boolean preferStriping, QuerySettings settings)
at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.ChildResultsRecipient.Receive[TKey](PartitionedStream`2 inputStream)
at System.Linq.Parallel.ScanQueryOperator`1.ScanEnumerableQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient`1 recipient)
at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient`1 recipient)
at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient`1 recipient)
at System.Linq.Parallel.QueryOperator`1.GetOpenedEnumerator(Nullable`1 mergeOptions, Boolean suppressOrder, Boolean forEffect, QuerySettings querySettings)
at System.Linq.Parallel.ForAllOperator`1.RunSynchronously()
at StockWiz.Library.PLINQArrayProcessor.DoProcessing() in C:\Users\dad\Documents\BitBucket\stockwiz_clone\stockwiz\StockWiz.Library\PLINQArrayProcessor.cs:line 50
at System.Threading.Tasks.Task.Execute()
InnerException: System.OverflowException
Message=Arithmetic operation resulted in an overflow.
Source=System.Core
StackTrace:
at System.Linq.Parallel.PartitionedDataSource`1.ContiguousChunkLazyEnumerator.MoveNext(T& currentElement, Int32& currentKey)
at System.Linq.Parallel.WhereQueryOperator`1.WhereQueryOperatorEnumerator`1.MoveNext(TInputOutput& currentElement, TKey& currentKey)
at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
at System.Linq.Parallel.SpoolingTaskBase.Work()
at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
at System.Threading.Tasks.Task.Execute()
InnerException:
मैं अगर सोच रहा हूँ: हर बार वापस जाने के लिए एक नकली कॉम्बो बनाने के द्वारा GetNextCombo में
अपवाद LINQ द्वारा फेंका जा रहा है (एक उपज वापसी "234gf24fa23 ..." आदि कर) इस quer को बदलने के लिए मैं कुछ भी कर सकता हूं
var query = nextComboMaker.GetNextCombo().AsParallel();
query.ForAll(x => if(ComboWasAWinner(x) wins.Add(x));
अब भी वही अतिप्रवाह: y अतिप्रवाह नहीं, किसी भी क्रम जिसमें मैं काम करते हैं, आदि के लिए हो सकता है कि हालांकि मैं इस की कोशिश की है, LINQ क्वेरी एक जहां करते हैं और चयन के लिए नहीं।
मेरे लिए काम नहीं कर रहा है, आपको करना होगा। Inumerable पर Toorray या ToList() मैं समानांतर हूं और आकार एक int से अधिक होने के बाद एक स्टैक ओवरफ़्लो बना देगा। इसे लंबे समय से गिनने के लिए मैं विशेष रूप से क्या ओवरराइड कर सकता हूं? –