this.customPartitioner = custom;
}
+ // If possible, this property will return the number of element the query
+ // is going to process. If that number if pretty low, executing the query
+ // sequentially is better
+ internal int Count {
+ get {
+ if (source == null)
+ return -1;
+
+ ICollection coll = source as ICollection;
+ return coll == null ? -1 : coll.Count;
+ }
+ }
+
public override void Visit (INodeVisitor visitor)
{
visitor.Visit<T> (this);
internal class QueryCheckerVisitor : INodeVisitor
{
+ const int minSequentialThreshold = 20;
+
// Information gathering
ParallelMergeOptions? options = null;
ParallelExecutionMode? mode = null;
behindOrderGuard = false;
if (degreeOfParallelism != null)
partitionCount = degreeOfParallelism.Value;
+
+ int count;
+ if ((count = node.Count) != -1 && count < minSequentialThreshold)
+ ShouldBeSequential = true;
}
public void Visit<T, TParent> (QueryStreamNode<T, TParent> node)