Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Linq / Parallel / Merging / OrderPreservingMergeHelper.cs / 1305376 / OrderPreservingMergeHelper.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // OrderPreservingMergeHelper.cs // //[....] // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Collections.Generic; using System.Threading.Tasks; using System.Diagnostics.Contracts; namespace System.Linq.Parallel { ////// The order preserving merge helper guarantees the output stream is in a specific order. This is done /// by comparing keys from a set of already-sorted input partitions, and coalescing output data using /// incremental key comparisons. /// ////// internal class OrderPreservingMergeHelper : IMergeHelper { private QueryTaskGroupState m_taskGroupState; // State shared among tasks. private PartitionedStream m_partitions; // Source partitions. private Shared m_results; // The array where results are stored. private TaskScheduler m_taskScheduler; // The task manager to execute the query. //------------------------------------------------------------------------------------ // Instantiates a new merge helper. // // Arguments: // partitions - the source partitions from which to consume data. // ignoreOutput - whether we're enumerating "for effect" or for output. // internal OrderPreservingMergeHelper(PartitionedStream partitions, TaskScheduler taskScheduler, CancellationState cancellationState, int queryId) { Contract.Assert(partitions != null); TraceHelpers.TraceInfo("KeyOrderPreservingMergeHelper::.ctor(..): creating an order preserving merge helper"); m_taskGroupState = new QueryTaskGroupState(cancellationState, queryId); m_partitions = partitions; m_results = new Shared (null); m_taskScheduler = taskScheduler; } //----------------------------------------------------------------------------------- // Schedules execution of the merge itself. // // Arguments: // ordinalIndexState - the state of the ordinal index of the merged partitions // void IMergeHelper .Execute() { OrderPreservingSpoolingTask .Spool(m_taskGroupState, m_partitions, m_results, m_taskScheduler); } //----------------------------------------------------------------------------------- // Gets the enumerator from which to enumerate output results. // IEnumerator IMergeHelper .GetEnumerator() { Contract.Assert(m_results.Value != null); return ((IEnumerable )m_results.Value).GetEnumerator(); } //----------------------------------------------------------------------------------- // Returns the results as an array. // public TInputOutput[] GetResultsAsArray() { return m_results.Value; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ClientScriptManager.cs
- safelink.cs
- SignedXml.cs
- ContextMenu.cs
- COM2PropertyBuilderUITypeEditor.cs
- EventSetter.cs
- DetailsViewInsertEventArgs.cs
- Listener.cs
- TabControlCancelEvent.cs
- SetStateDesigner.cs
- SatelliteContractVersionAttribute.cs
- ResXResourceReader.cs
- AppDomainCompilerProxy.cs
- ListViewItem.cs
- XDeferredAxisSource.cs
- UnsignedPublishLicense.cs
- ConfigXmlAttribute.cs
- ProjectionPlan.cs
- PasswordRecoveryAutoFormat.cs
- BookmarkEventArgs.cs
- HtmlEncodedRawTextWriter.cs
- Duration.cs
- Vector.cs
- CookieHandler.cs
- DesignerDataSchemaClass.cs
- ColorBuilder.cs
- SiteIdentityPermission.cs
- UrlEncodedParameterWriter.cs
- UpWmlPageAdapter.cs
- TreeView.cs
- SafeRightsManagementPubHandle.cs
- _ConnectStream.cs
- SpellerInterop.cs
- IChannel.cs
- XmlILConstructAnalyzer.cs
- DataSetUtil.cs
- DataBindingHandlerAttribute.cs
- XmlILIndex.cs
- MetadataCache.cs
- activationcontext.cs
- TransformationRules.cs
- SqlFacetAttribute.cs
- DrawingAttributesDefaultValueFactory.cs
- NotCondition.cs
- ResourcePool.cs
- HostExecutionContextManager.cs
- OperationValidationEventArgs.cs
- PopupEventArgs.cs
- StickyNoteHelper.cs
- ExceptionHelpers.cs
- PlatformCulture.cs
- SQLBytes.cs
- AssertUtility.cs
- CodeVariableReferenceExpression.cs
- SoapEnumAttribute.cs
- SecurityResources.cs
- SecurityResources.cs
- Stream.cs
- DbConnectionInternal.cs
- InkPresenterAutomationPeer.cs
- HttpValueCollection.cs
- InternalControlCollection.cs
- CalendarDay.cs
- AnnotationResourceChangedEventArgs.cs
- ThreadStateException.cs
- AspProxy.cs
- XmlBaseReader.cs
- RuntimeArgumentHandle.cs
- ComponentDesigner.cs
- Menu.cs
- HttpRawResponse.cs
- ExpressionPrefixAttribute.cs
- ResourcePermissionBaseEntry.cs
- Win32PrintDialog.cs
- TextServicesManager.cs
- XmlObjectSerializerReadContext.cs
- TemplateLookupAction.cs
- RegisteredArrayDeclaration.cs
- PersistNameAttribute.cs
- DependencyPropertyKind.cs
- LicFileLicenseProvider.cs
- ObjectDataSourceSelectingEventArgs.cs
- FieldToken.cs
- InputQueueChannelAcceptor.cs
- TextWriterEngine.cs
- ListItem.cs
- FormsAuthenticationConfiguration.cs
- VisualStyleElement.cs
- TemplateInstanceAttribute.cs
- XdrBuilder.cs
- diagnosticsswitches.cs
- TCEAdapterGenerator.cs
- ActivityDelegate.cs
- JavaScriptObjectDeserializer.cs
- QilTypeChecker.cs
- PreviewPrintController.cs
- ProviderUtil.cs
- StaticFileHandler.cs
- ToolBarButtonClickEvent.cs
- ListViewHitTestInfo.cs