예제 #1
0
        public static void GetOrderableDynamicPartitions(long from, long count)
        {
            long to          = from + count;
            var  partitioner = Partitioner.Create(from, to);

            //var elements = partitioner.GetOrderableDynamicPartitions().SelectMany(tuple => tuple.UnRoll());
            IList <long> elements = new List <long>();

            foreach (var partition in partitioner.GetOrderableDynamicPartitions())
            {
                foreach (var item in partition.UnRoll())
                {
                    elements.Add(item);
                }
            }
            Assert.True(elements.CompareSequences <long>(RangePartitionerHelpers.LongEnumerable(from, to)), "GetOrderableDynamicPartitions Element mismatch");

            //var keys = partitioner.GetOrderableDynamicPartitions().Select(tuple => tuple.Key).ToArray();
            IList <long> keys = new List <long>();

            foreach (var tuple in partitioner.GetOrderableDynamicPartitions())
            {
                keys.Add(tuple.Key);
            }
            Assert.True(keys.CompareSequences <long>(RangePartitionerHelpers.LongEnumerable(keys[0], keys.Count)), "GetOrderableDynamicPartitions key mismatch");
        }
예제 #2
0
        public static void CheckGetDynamicPartitionsWithRange(long from, long count, long desiredRangeSize)
        {
            long to          = from + count;
            var  partitioner = Partitioner.Create(from, to, desiredRangeSize);

            //var elements = partitioner.GetDynamicPartitions().SelectMany(tuple => tuple.UnRoll());
            IList <long> elements = new List <long>();

            foreach (var partition in partitioner.GetDynamicPartitions())
            {
                foreach (var item in partition.UnRoll())
                {
                    elements.Add(item);
                }
            }
            Assert.True(elements.CompareSequences <long>(RangePartitionerHelpers.LongEnumerable(from, to)), "GetDynamicPartitions Element mismatch");

            //var rangeSizes = partitioner.GetDynamicPartitions().Select(tuple => tuple.GetRangeSize()).ToArray();
            IList <long> rangeSizes = new List <long>();

            foreach (var partition in partitioner.GetDynamicPartitions())
            {
                rangeSizes.Add(partition.GetRangeSize());
            }
            ValidateRangeSize(desiredRangeSize, rangeSizes);
        }
예제 #3
0
        public static void CheckGetOrderablePartitions(long from, long count, int dop)
        {
            long to          = from + count;
            var  partitioner = Partitioner.Create(from, to);

            //var elements = partitioner.GetOrderablePartitions(dop).SelectMany(enumerator => enumerator.UnRoll());
            IList <long> elements = new List <long>();

            foreach (var partition in partitioner.GetPartitions(dop))
            {
                foreach (var item in partition.UnRoll())
                {
                    elements.Add(item);
                }
            }

            Assert.True(elements.CompareSequences <long>(RangePartitionerHelpers.LongEnumerable(from, to)), "GetOrderablePartitions Element mismatch");

            //var keys = partitioner.GetOrderablePartitions(dop).SelectMany(enumerator => enumerator.UnRollIndices()).ToArray();
            IList <long> keys = new List <long>();

            foreach (var partition in partitioner.GetOrderablePartitions(dop))
            {
                foreach (var item in partition.UnRollIndices())
                {
                    keys.Add(item);
                }
            }
            Assert.True(keys.CompareSequences <long>(RangePartitionerHelpers.LongEnumerable(keys[0], keys.Count)), "GetOrderablePartitions key mismatch");
        }
예제 #4
0
        public static void GetOrderableDynamicPartitionsWithRange(int from, int count, int desiredRangeSize)
        {
            int to          = from + count;
            var partitioner = Partitioner.Create(from, to, desiredRangeSize);

            //var elements = partitioner.GetOrderableDynamicPartitions().SelectMany(tuple => tuple.UnRoll());
            IList <int> elements = new List <int>();

            foreach (var tuple in partitioner.GetOrderableDynamicPartitions())
            {
                foreach (var item in tuple.UnRoll())
                {
                    elements.Add(item);
                }
            }
            Assert.True(elements.CompareSequences <int>(RangePartitionerHelpers.IntEnumerable(from, to)), "GetOrderableDynamicPartitions Element mismatch");

            //var keys = partitioner.GetOrderableDynamicPartitions().Select(tuple => tuple.Key).ToArray();
            IList <long> keys = new List <long>();

            foreach (var tuple in partitioner.GetOrderableDynamicPartitions())
            {
                keys.Add(tuple.Key);
            }
            Assert.True(keys.CompareSequences <long>(RangePartitionerHelpers.LongEnumerable(keys[0], keys.Count)), "GetOrderableDynamicPartitions key mismatch");

            //var rangeSizes = partitioner.GetOrderableDynamicPartitions().Select(tuple => tuple.GetRangeSize()).ToArray();
            IList <int> rangeSizes = new List <int>();

            foreach (var partition in partitioner.GetOrderableDynamicPartitions())
            {
                rangeSizes.Add(partition.GetRangeSize());
            }
            ValidateRangeSize(desiredRangeSize, rangeSizes);
        }
예제 #5
0
        public static void CheckGetPartitionsWithRange(int from, int count, int desiredRangeSize, int dop)
        {
            int to          = from + count;
            var partitioner = Partitioner.Create(from, to, desiredRangeSize);

            //var elements = partitioner.GetPartitions(dop).SelectMany(enumerator => enumerator.UnRoll());
            IList <int> elements = new List <int>();

            foreach (var partition in partitioner.GetPartitions(dop))
            {
                foreach (var item in partition.UnRoll())
                {
                    elements.Add(item);
                }
            }
            Assert.True(elements.CompareSequences <int>(RangePartitionerHelpers.IntEnumerable(from, to)), "GetPartitions element mismatch");

            //var rangeSizes = partitioner.GetPartitions(dop).SelectMany(enumerator => enumerator.GetRangeSize()).ToArray();
            IList <int> rangeSizes = new List <int>();

            foreach (var partition in partitioner.GetPartitions(dop))
            {
                foreach (var item in partition.GetRangeSize())
                {
                    rangeSizes.Add(item);
                }
            }

            ValidateRangeSize(desiredRangeSize, rangeSizes);
        }
예제 #6
0
        public static void CheckGetDynamicPartitions(int from, int count)
        {
            int to          = from + count;
            var partitioner = Partitioner.Create(from, to);

            //var elements = partitioner.GetDynamicPartitions().SelectMany(tuple => tuple.UnRoll());
            IList <int> elements = new List <int>();

            foreach (var partition in partitioner.GetDynamicPartitions())
            {
                foreach (var item in partition.UnRoll())
                {
                    elements.Add(item);
                }
            }

            Assert.True(elements.CompareSequences <int>(RangePartitionerHelpers.IntEnumerable(from, to)), "GetDynamicPartitions Element mismatch");
        }
예제 #7
0
        public static void CheckGetPartitions(int from, int count, int dop)
        {
            int to          = from + count;
            var partitioner = Partitioner.Create(from, to);

            //var elements = dopPartitions.SelectMany(enumerator => enumerator.UnRoll());
            IList <int> elements = new List <int>();

            foreach (var partition in partitioner.GetPartitions(dop))
            {
                foreach (var item in partition.UnRoll())
                {
                    elements.Add(item);
                }
            }

            Assert.True(elements.CompareSequences <int>(RangePartitionerHelpers.IntEnumerable(from, to)), "GetPartitions element mismatch");
        }