Пример #1
0
        public void MergeConsecutiveEqualValues_AsExpected()
        {
            var input = new[] { 1, 2, 3, 3, 2, 5, 4, 4 };

            var expected = new[] { 1, 2, 3, 2, 5, 4 };

            Assert.Equal(expected, PartitionUtilities.MergeConsecutiveEqualValues(input).ToArray());
        }
Пример #2
0
        public void GetEqualSizeOffsets_AsExpected()
        {
            const int fileSize      = 1001;
            const int numPartitions = 3;

            var expected = new long[] { 0, 333, 666 };

            Assert.Equal(expected, PartitionUtilities.GetEqualSizeOffsets(fileSize, numPartitions));
        }
Пример #3
0
        public void FindEqualOrClosestSmallerOffsets_AsExpected()
        {
            var sizeBasedOffsets = new long[] { 0, 100, 200, 300, 400 };
            var allLinearIndexes = new long[] { 15, 45, 97, 123, 146, 175, 200, 234, 265, 293, 401 };

            var blockOffsets = PartitionUtilities.FindEqualOrClosestSmallerOffsets(sizeBasedOffsets, allLinearIndexes);

            var expected = new long[] { 15, 97, 200, 293 };

            Assert.Equal(expected, blockOffsets);
        }
        private async Task <string[]> GetPartitionsAsync(EventHubClient client)
        {
            var info = await client.GetRuntimeInformationAsync().ConfigureAwait(false);

            var partitions = await PartitionUtilities.GetOrderedPartitionListAsync(Context.ServiceName).ConfigureAwait(false);

            var thisPartitionIndex    = partitions.FindIndex(spi => spi.Id == Partition.PartitionInfo.Id);
            var partitionsPerIndex    = info.PartitionCount / partitions.Count;
            var firstPartition        = thisPartitionIndex * partitionsPerIndex;
            var possibleLastPartition = (firstPartition + partitionsPerIndex) - 1;
            var lastPartition         = possibleLastPartition > info.PartitionCount ? info.PartitionCount - 1 : possibleLastPartition;
            var ourPartitions         = new string[(lastPartition - firstPartition) + 1];

            Array.Copy(info.PartitionIds, firstPartition, ourPartitions, 0, ourPartitions.Length);
            return(ourPartitions);
        }
Пример #5
0
        private static void StartSetEstimatedCountsOnPartition(object threadInfo)
        {
            SetEstimatedCountsOnPartitionThreadInfo info = (SetEstimatedCountsOnPartitionThreadInfo)threadInfo;

            try
            {
                if (info.aggDesign != null && info.measureGroupDimension != null)
                {
                    if (info.instance.CheckCancelled())
                    {
                        return;
                    }
                    try
                    {
                        PartitionUtilities.SetEstimatedCountInAttributes(info.aggDesign, info.measureGroupDimension, new Partition[] { info.partition }, null);
                    }
                    catch (Exception ex)
                    {
                        info.errors.Add("BIDS Helper error setting estimated counts for dimension attributes of " + info.measureGroupDimension.CubeDimension.Name + " on partition " + info.partition.Name + " of measure group " + info.partition.Parent.Name + ": " + ex.Message);
                    }
                }

                if (info.instance.CheckCancelled() || info.partition.EstimatedRows > 0)
                {
                    return;
                }
                try
                {
                    PartitionUtilities.SetEstimatedCountInPartition(info.partition, null);
                }
                catch (Exception ex)
                {
                    info.errors.Add("BIDS Helper error setting estimated counts for partition " + info.partition.Name + " of measure group " + info.partition.Parent.Name + ": " + ex.Message);
                }
            }
            catch { } //silently catch errors... don't want to message box errors because there could be hundreds of them
            finally
            {
                info.done = true;
                //info.autoResetEvent.Set();
            }
        }