Example #1
0
        internal QuerySettings WithDefaults()
        {
            QuerySettings settings = this;

            if (settings.TaskScheduler == null)
            {
                settings.TaskScheduler = System.Threading.Tasks.TaskScheduler.Default;
            }
            if (!settings.DegreeOfParallelism.HasValue)
            {
                settings.DegreeOfParallelism = new int?(Scheduling.GetDefaultDegreeOfParallelism());
            }
            if (!settings.ExecutionMode.HasValue)
            {
                settings.ExecutionMode = 0;
            }
            if (!settings.MergeOptions.HasValue)
            {
                settings.MergeOptions = 0;
            }
            if (((ParallelMergeOptions)settings.MergeOptions) == ParallelMergeOptions.Default)
            {
                settings.MergeOptions = 2;
            }
            return(settings);
        }
        //-----------------------------------------------------------------------------------
        // Copies the settings, replacing unspecified settings with defaults.
        //
        internal QuerySettings WithDefaults()
        {
            QuerySettings settings = this;

            if (settings.TaskScheduler == null)
            {
                settings.TaskScheduler = TaskScheduler.Default;
            }

            if (settings.DegreeOfParallelism == null)
            {
                settings.DegreeOfParallelism = Scheduling.GetDefaultDegreeOfParallelism();
            }

            if (settings.ExecutionMode == null)
            {
                settings.ExecutionMode = ParallelExecutionMode.Default;
            }

            if (settings.MergeOptions == null)
            {
                settings.MergeOptions = ParallelMergeOptions.Default;
            }

            if (settings.MergeOptions == ParallelMergeOptions.Default)
            {
                settings.MergeOptions = ParallelMergeOptions.AutoBuffered;
            }

            Contract.Assert(settings.TaskScheduler != null);
            Contract.Assert(settings.DegreeOfParallelism.HasValue);
            Contract.Assert(settings.DegreeOfParallelism.Value >= 1 && settings.DegreeOfParallelism <= Scheduling.MAX_SUPPORTED_DOP);
            Contract.Assert(settings.ExecutionMode != null);
            Contract.Assert(settings.MergeOptions != null);

            Contract.Assert(settings.MergeOptions != ParallelMergeOptions.Default);

            return(settings);
        }