Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Linq / Parallel / QueryOperators / Inlined / InlinedAggregationOperatorEnumerator.cs / 1305376 / InlinedAggregationOperatorEnumerator.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // InlinedAggregationOperatorEnumerator.cs // //[....] // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Threading; namespace System.Linq.Parallel { //---------------------------------------------------------------------------------------- // Inlined aggregate operators for finding the min/max values for primitives (int, long, float, // double, decimal). Versions are also offered for the nullable primitives (int?, long?, float?, // double?, decimal?), which differ slightly in behavior: they return a null value for empty // streams, whereas the ordinary primitive versions throw. // //--------------------------------------------------------------------------------------- // Inlined average operators for primitives (int, long, float, double, decimal), and the // nullable variants. The difference between the nromal and nullable variety is that // nulls are skipped in tallying the count and sum for the average. // ////// A class with some shared implementation between all aggregation enumerators. /// ///internal abstract class InlinedAggregationOperatorEnumerator : QueryOperatorEnumerator { private int m_partitionIndex; // This partition's unique index. protected CancellationToken m_cancellationToken; //--------------------------------------------------------------------------------------- // Instantiates a new aggregation operator. // internal InlinedAggregationOperatorEnumerator(int partitionIndex, CancellationToken cancellationToken) { m_partitionIndex = partitionIndex; m_cancellationToken = cancellationToken; } //--------------------------------------------------------------------------------------- // Tallies up the sum of the underlying data source, walking the entire thing the first // time MoveNext is called on this object. There is a boilerplate variant used by callers, // and then one that is used for extensibility by subclasses. // internal sealed override bool MoveNext(ref TIntermediate currentElement, ref int currentKey) { if (MoveNextCore(ref currentElement)) { // A reduction's "index" is the same as its partition number. currentKey = m_partitionIndex; return true; } return false; } protected abstract bool MoveNextCore(ref TIntermediate currentElement); } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // InlinedAggregationOperatorEnumerator.cs // // [....] // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Threading; namespace System.Linq.Parallel { //---------------------------------------------------------------------------------------- // Inlined aggregate operators for finding the min/max values for primitives (int, long, float, // double, decimal). Versions are also offered for the nullable primitives (int?, long?, float?, // double?, decimal?), which differ slightly in behavior: they return a null value for empty // streams, whereas the ordinary primitive versions throw. // //--------------------------------------------------------------------------------------- // Inlined average operators for primitives (int, long, float, double, decimal), and the // nullable variants. The difference between the nromal and nullable variety is that // nulls are skipped in tallying the count and sum for the average. // ////// A class with some shared implementation between all aggregation enumerators. /// ///internal abstract class InlinedAggregationOperatorEnumerator : QueryOperatorEnumerator { private int m_partitionIndex; // This partition's unique index. protected CancellationToken m_cancellationToken; //--------------------------------------------------------------------------------------- // Instantiates a new aggregation operator. // internal InlinedAggregationOperatorEnumerator(int partitionIndex, CancellationToken cancellationToken) { m_partitionIndex = partitionIndex; m_cancellationToken = cancellationToken; } //--------------------------------------------------------------------------------------- // Tallies up the sum of the underlying data source, walking the entire thing the first // time MoveNext is called on this object. There is a boilerplate variant used by callers, // and then one that is used for extensibility by subclasses. // internal sealed override bool MoveNext(ref TIntermediate currentElement, ref int currentKey) { if (MoveNextCore(ref currentElement)) { // A reduction's "index" is the same as its partition number. currentKey = m_partitionIndex; return true; } return false; } protected abstract bool MoveNextCore(ref TIntermediate currentElement); } } // 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
- PartitionedStream.cs
- InkSerializer.cs
- SafeEventLogWriteHandle.cs
- ParameterToken.cs
- FixedDocumentPaginator.cs
- FieldAccessException.cs
- LinkDesigner.cs
- PersonalizationStateInfoCollection.cs
- TypedTableHandler.cs
- HostingEnvironmentException.cs
- PathFigureCollectionValueSerializer.cs
- DataColumnPropertyDescriptor.cs
- _ProxyRegBlob.cs
- SourceFileInfo.cs
- HtmlInputButton.cs
- MachineKeySection.cs
- SafeLocalAllocation.cs
- SecurityTokenValidationException.cs
- BasicExpressionVisitor.cs
- x509utils.cs
- ScrollPatternIdentifiers.cs
- ErrorBehavior.cs
- HttpHeaderCollection.cs
- DataGridDesigner.cs
- WebBrowserSiteBase.cs
- OutputCacheSection.cs
- ClientSettingsProvider.cs
- InteropExecutor.cs
- MappingMetadataHelper.cs
- DataTableMapping.cs
- ErrorHandlingReceiver.cs
- BitmapEffectrendercontext.cs
- GradientStop.cs
- CodeTypeDeclarationCollection.cs
- PageBuildProvider.cs
- DataTableCollection.cs
- WorkflowWebService.cs
- CellLabel.cs
- CachedFontFamily.cs
- HttpCacheParams.cs
- WindowsListViewGroup.cs
- MetabaseSettings.cs
- SchemaEntity.cs
- WindowsTokenRoleProvider.cs
- LazyTextWriterCreator.cs
- WorkflowTransactionService.cs
- TextBoxAutomationPeer.cs
- DatatypeImplementation.cs
- TraceHandler.cs
- XmlRootAttribute.cs
- AmbiguousMatchException.cs
- TypeBuilderInstantiation.cs
- HttpServerUtilityWrapper.cs
- MatrixAnimationUsingPath.cs
- ServiceRouteHandler.cs
- FieldToken.cs
- ObjectParameterCollection.cs
- PagesChangedEventArgs.cs
- FieldMetadata.cs
- DesignerView.Commands.cs
- DBAsyncResult.cs
- GlobalizationAssembly.cs
- XmlElementAttribute.cs
- HttpRequest.cs
- uribuilder.cs
- MappedMetaModel.cs
- Renderer.cs
- CharacterHit.cs
- AdornerPresentationContext.cs
- ParserStack.cs
- AsymmetricSignatureFormatter.cs
- Clipboard.cs
- Encoder.cs
- GroupBox.cs
- ThicknessAnimationBase.cs
- BatchWriter.cs
- MailAddressParser.cs
- TokenizerHelper.cs
- SequentialOutput.cs
- MarkupCompilePass1.cs
- Profiler.cs
- NCryptNative.cs
- CompiledXpathExpr.cs
- TableCell.cs
- IsolatedStorageFile.cs
- GridItemPatternIdentifiers.cs
- FuncCompletionCallbackWrapper.cs
- SchemaTypeEmitter.cs
- COM2PictureConverter.cs
- VirtualizedCellInfoCollection.cs
- FilterFactory.cs
- ListViewInsertedEventArgs.cs
- KerberosSecurityTokenProvider.cs
- CrossSiteScriptingValidation.cs
- Vertex.cs
- GacUtil.cs
- XmlUnspecifiedAttribute.cs
- CodeArgumentReferenceExpression.cs
- DataConnectionHelper.cs
- PlainXmlSerializer.cs