Example #1
0
        internal override IList <IEnumerable <T> > GetEnumerables(QueryOptions options)
        {
            if (customPartitioner != null)
            {
                return(WrapHelper.Wrap(customPartitioner.GetPartitions(options.PartitionCount)));
            }

            Partitioner <T> partitioner
                = (options.UseStrip) ? ParallelPartitioner.CreateForStrips(source, 1) : ParallelPartitioner.CreateBest(source);

            return(WrapHelper.Wrap(partitioner.GetPartitions(options.PartitionCount)));
        }
Example #2
0
        internal override IList <IEnumerable <KeyValuePair <long, T> > > GetOrderedEnumerables(QueryOptions options)
        {
            OrderablePartitioner <T> partitioner = null;

            if (customPartitioner != null)
            {
                partitioner = customPartitioner as OrderablePartitioner <T>;
                if (partitioner == null)
                {
                    throw new InvalidOperationException("The partitionner you are using doesn't support ordered partitionning");
                }
            }
            else
            {
                partitioner =
                    (options.UseStrip) ? ParallelPartitioner.CreateForStrips(source, 1) : ParallelPartitioner.CreateBest(source);
            }

            options.PartitionerSettings = Tuple.Create(partitioner.KeysOrderedAcrossPartitions,
                                                       partitioner.KeysOrderedInEachPartition,
                                                       partitioner.KeysNormalized);

            // We only support one style of partitioning at the moment.
            // Standard partitioners follow this style.
            if (options.UseStrip && (!partitioner.KeysOrderedInEachPartition || partitioner.KeysOrderedAcrossPartitions))
            {
                throw new NotImplementedException("Partitioner must have KeysOrderedInEachPartition "
                                                  + "and !KeysOrderedAcrossPartitions"
                                                  + "to be used with indexed operators");
            }

            return(WrapHelper.Wrap(partitioner.GetOrderablePartitions(options.PartitionCount)));
        }