public OppositeMergeQuickSort(
     ChunkStack <T> chunkStack,
     ChunkStack <T> tempChunkStack,
     int chunkSize        = 1000000,
     bool onlyMemoryMerge = false)
     : base(chunkStack, tempChunkStack, onlyMemoryMerge)
 {
     _chunkSize = chunkSize;
 }
Esempio n. 2
0
 public ChunkStackAppender(
     ChunkStack <T> chunkStack,
     ChunkStack <T> tempChunkStack,
     bool onlyMemoryMerge = false)
 {
     _chunkStack      = chunkStack;
     _tempChunkStack  = tempChunkStack;
     _onlyMemoryMerge = onlyMemoryMerge;
 }
Esempio n. 3
0
        public ISortMethod <T> CreateSortMethod <T>(ChunkStack <T> chunkStack, IChunkStackFactory <T> chunkStackFactory) where T : IComparable
        {
            switch (_sortMethod)
            {
            case SortMethod.MergeSort:
            {
                return(new OppositeMergeSort <T>(
                           chunkStack,
                           chunkStackFactory.CreateChunkStack(),
                           _onlyMemoryMerge));
            }

            case SortMethod.MergeQuickSort:
            {
                if (_quickSortSize != null)
                {
                    return(new OppositeMergeQuickSort <T>(
                               chunkStack,
                               chunkStackFactory.CreateChunkStack(),
                               _quickSortSize.Value,
                               _onlyMemoryMerge));
                }

                return(new OppositeMergeQuickSort <T>(
                           chunkStack,
                           chunkStackFactory.CreateChunkStack(),
                           onlyMemoryMerge: _onlyMemoryMerge));
            }

            case SortMethod.ConcurrentMergeQuickSort:
            {
                if (_quickSortSize != null)
                {
                    return(new ConcurrentOppositeMergeQuickSort <T>(
                               chunkStack,
                               chunkStackFactory,
                               _channelCapacity,
                               _sortConcurrency,
                               _mergeConcurrency,
                               _quickSortSize.Value,
                               _onlyMemoryMerge));
                }

                return(new ConcurrentOppositeMergeQuickSort <T>(
                           chunkStack,
                           chunkStackFactory,
                           _channelCapacity,
                           _sortConcurrency,
                           _mergeConcurrency,
                           onlyMemoryMerge: _onlyMemoryMerge));
            }

            default:
                throw new NotSupportedException();
            }
        }
Esempio n. 4
0
 protected IChunkReference <T> Merge(
     IChunkReference <T> left,
     IChunkReference <T> right,
     ChunkStack <T> chunkStack)
 {
     using (var chunkWriter = chunkStack.CreateChunkForMerge(left, right))
     {
         foreach (var value in _sortJoin.Join(left.GetValue(), right.GetValue()))
         {
             chunkWriter.Write(value);
         }
         return(chunkWriter.Complete());
     }
 }
Esempio n. 5
0
            public IChunkReference <T> Merge(
                IChunkReference <T>[] chunks,
                ChunkStack <T> chunkStack)
            {
                using (var chunkWriter = chunkStack.CreateChunkForMerge(chunks))
                {
                    foreach (var value in _sortJoin.Join(chunks.Select(x => x.GetValue()).ToArray()))
                    {
                        chunkWriter.Write(value);
                    }

                    return(chunkWriter.Complete());
                }
            }
Esempio n. 6
0
 public ConcurrentOppositeMergeQuickSort(
     ChunkStack <T> chunkStack,
     IChunkStackFactory <T> chunkStackFactory,
     int channelCapacity  = 2,
     int sortConcurrency  = 10,
     int mergeConcurrency = 4,
     int chunkSize        = 1000000,
     bool onlyMemoryMerge = false)
     : base(chunkStack, null, onlyMemoryMerge)
 {
     _chunkSize         = chunkSize;
     _chunkStackFactory = chunkStackFactory;
     _channelCapacity   = channelCapacity;
     _sortConcurrency   = sortConcurrency;
     _mergeConcurrency  = mergeConcurrency;
     _onlyMemoryMerge   = onlyMemoryMerge;
 }
Esempio n. 7
0
 protected ChunkStack <T> GetOtherChunkStack(ChunkStack <T> chunkStack)
 {
     return(chunkStack == _chunkStack ? _tempChunkStack : _chunkStack);
 }
Esempio n. 8
0
 protected MergeSortBase(ChunkStack <T> chunkStack, ChunkStack <T> tempChunkStack, bool onlyMemoryMerge)
 {
     _appender       = new ChunkStackAppender(chunkStack, tempChunkStack, onlyMemoryMerge);
     _tempChunkStack = tempChunkStack;
     _chunkStack     = chunkStack;
 }
Esempio n. 9
0
 public OppositeMergeSort(ChunkStack <T> chunkStack, ChunkStack <T> tempChunkStack, bool onlyMemoryMerge = false)
     : base(chunkStack, tempChunkStack, onlyMemoryMerge)
 {
 }