public OppositeMergeQuickSort( ChunkStack <T> chunkStack, ChunkStack <T> tempChunkStack, int chunkSize = 1000000, bool onlyMemoryMerge = false) : base(chunkStack, tempChunkStack, onlyMemoryMerge) { _chunkSize = chunkSize; }
public ChunkStackAppender( ChunkStack <T> chunkStack, ChunkStack <T> tempChunkStack, bool onlyMemoryMerge = false) { _chunkStack = chunkStack; _tempChunkStack = tempChunkStack; _onlyMemoryMerge = onlyMemoryMerge; }
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(); } }
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()); } }
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()); } }
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; }
protected ChunkStack <T> GetOtherChunkStack(ChunkStack <T> chunkStack) { return(chunkStack == _chunkStack ? _tempChunkStack : _chunkStack); }
protected MergeSortBase(ChunkStack <T> chunkStack, ChunkStack <T> tempChunkStack, bool onlyMemoryMerge) { _appender = new ChunkStackAppender(chunkStack, tempChunkStack, onlyMemoryMerge); _tempChunkStack = tempChunkStack; _chunkStack = chunkStack; }
public OppositeMergeSort(ChunkStack <T> chunkStack, ChunkStack <T> tempChunkStack, bool onlyMemoryMerge = false) : base(chunkStack, tempChunkStack, onlyMemoryMerge) { }