/// <summary>Returns the total number of elements of the CloudFlow.</summary> /// <param name="flow">The input CloudFlow.</param> /// <param name="predicate">Optional inclusive element predicate.</param> /// <returns>The total number of elements.</returns> public static Cloud <long> Count <TSource>(this CloudFlow <TSource> flow, Func <TSource, bool> predicate = null) { if (predicate == null) { return(CloudFlowModule.length(flow)); } return(flow.Where(predicate).Count()); }
/// <summary>Returns the sum of the elements.</summary> /// <param name="flow">The input CloudFlow.</param> /// <returns>The sum of the elements.</returns> public static Cloud <decimal> Sum(this CloudFlow <decimal?> flow) { return(flow.Select(value => value.GetValueOrDefault(0)).Sum()); }
/// <summary>Applies a function to each element of the CloudFlow, threading an accumulator argument through the computation. If the input function is f and the elements are i0...iN, then this function computes f (... (f s i0)...) iN.</summary> /// <param name="folder">A function that updates the state with each element from the CloudFlow.</param> /// <param name="combiner">A function that combines partial states into a new state.</param> /// <param name="state">A function that produces the initial state.</param> /// <param name="stream">The input CloudFlow.</param> /// <returns>The final result.</returns> public static Cloud <TAccumulate> Aggregate <TSource, TAccumulate>(this CloudFlow <TSource> stream, Func <TAccumulate> state, Func <TAccumulate, TSource, TAccumulate> folder, Func <TAccumulate, TAccumulate, TAccumulate> combiner) { return(CSharpProxy.Aggregate(stream, state, folder, combiner)); }
/// <summary>Transforms each element of the input CloudFlow to a new stream and flattens its elements.</summary> /// <param name="f">A function to transform items from the input CloudFlow.</param> /// <param name="stream">The input CloudFlow.</param> /// <returns>The result CloudFlow.</returns> public static CloudFlow <TResult> SelectMany <TSource, TResult>(this CloudFlow <TSource> stream, Func <TSource, IEnumerable <TResult> > f) { return(CSharpProxy.SelectMany(stream, f)); }
/// <summary>Transforms each element of the input CloudFlow.</summary> /// <param name="f">A function to transform items from the input CloudFlow.</param> /// <param name="stream">The input CloudFlow.</param> /// <returns>The result CloudFlow.</returns> public static CloudFlow <TResult> Select <TSource, TResult>(this CloudFlow <TSource> stream, Func <TSource, TResult> f) { return(CSharpProxy.Select(stream, f)); }
/// <summary>Creates an array from the given CloudFlow.</summary> /// <param name="stream">The input CloudFlow.</param> /// <returns>The result array.</returns> public static Cloud <TSource[]> ToArray <TSource>(this CloudFlow <TSource> stream) { return(CloudFlowModule.toArray(stream)); }
/// <summary>Returns the total number of elements of the CloudFlow.</summary> /// <param name="stream">The input CloudFlow.</param> /// <returns>The total number of elements.</returns> public static Cloud <long> Count <TSource>(this CloudFlow <TSource> stream) { return(CSharpProxy.Count(stream)); }
/// <summary>Returns the sum of the elements.</summary> /// <param name="stream">The input CloudFlow.</param> /// <returns>The sum of the elements.</returns> public static Cloud <float> Sum(this CloudFlow <float> stream) { return(CSharpProxy.Sum(stream)); }
/// <summary> /// Locates the minimum element of the flow by given key. /// </summary> /// <param name="projection">A function that maps items from the input CloudFlow to comparable keys.</param> /// <param name="flow">The input CloudFlow.</param> public static Cloud <TSource> MinBy <TSource, TKey>(this CloudFlow <TSource> flow, Func <TSource, TKey> projection) { return(CloudFlowModule.minBy(FSharpFunc.Create(projection), flow)); }
/// <summary> /// Applies a key-generating function to each element of a CloudFlow and return a CloudFlow yielding unique keys and their number of occurrences in the original sequence. /// </summary> /// <param name="projection">A function that maps items from the input CloudFlow to keys.</param> /// <param name="flow">The input CloudFlow.</param> public static CloudFlow <Tuple <TKey, long> > CountBy <TSource, TKey>(this CloudFlow <TSource> flow, Func <TSource, TKey> projection) { return(CloudFlowModule.countBy(FSharpFunc.Create(projection), flow)); }
/// <summary> /// Averages the elements of given cloud flow by applying key and value projections. /// </summary> /// <typeparam name="TSource">Source element type.</typeparam> /// <typeparam name="TKey">Element key type.</typeparam> /// <param name="flow">Input CloudFlow.</param> /// <param name="keyProjection">Element key projection.</param> /// <param name="valueProjection">Averaged value projection.</param> /// <returns>A flow of computed averages, distinguished by key.</returns> public static CloudFlow <KeyValuePair <TKey, double> > AverageByKey <TSource, TKey>(this CloudFlow <TSource> flow, Func <TSource, TKey> keyProjection, Func <TSource, double> valueProjection) { return(CloudFlowModule .averageByKey(keyProjection.ToFSharpFunc(), valueProjection.ToFSharpFunc(), flow) .Select(result => new KeyValuePair <TKey, double>(result.Item1, result.Item2))); }
/// <summary> /// Computes the average of a flow of numbers. /// </summary> /// <param name="flow">Input CloudFlow.</param> /// <returns>A cloud computation that computes the average of suplied workflow.</returns> public static Cloud <decimal> Average(this CloudFlow <decimal> flow) { return(CloudFlowModule.average(flow)); }
/// <summary> /// Computes the average of a flow of numbers. /// </summary> /// <param name="flow">Input CloudFlow.</param> /// <returns>A cloud computation that computes the average of suplied workflow.</returns> public static Cloud <float> Average(this CloudFlow <float> flow) { return(CloudFlowModule.average(flow)); }
/// <summary> /// Computes the average of a flow of numbers. /// </summary> /// <param name="flow">Input CloudFlow.</param> /// <returns>A cloud computation that computes the average of suplied workflow.</returns> public static Cloud <double> Average(this CloudFlow <long> flow) { return(flow.Select(i => (double)i).Average()); }
/// <summary>Applies a key-generating function to each element of the input CloudFlow and yields the CloudFlow of the given length, ordered by keys.</summary> /// <param name="projection">A function to transform items of the input CloudFlow into comparable keys.</param> /// <param name="stream">The input CloudFlow.</param> /// <param name="takeCount">The number of elements to return.</param> /// <returns>The result CloudFlow.</returns> public static CloudFlow <TSource> OrderBy <TSource, TKey>(this CloudFlow <TSource> stream, Func <TSource, TKey> projection, int takeCount) where TKey : IComparable <TKey> { return(CSharpProxy.OrderBy(stream, projection, takeCount)); }
/// <summary> /// Returns a flow that contains no duplicate elements according to their generic hash and equality comparisons. /// If an element occurs multiple times in the flow then only one is retained. /// </summary> /// <typeparam name="TSource">Cloud flow element type.</typeparam> /// <param name="flow">Input cloud flow.</param> /// <returns>A CloudFlow with unique occurences of elements.</returns> public static CloudFlow <TSource> Distinct <TSource>(this CloudFlow <TSource> flow) where TSource : IComparable { return(CloudFlowModule.distinct(flow)); }
/// <summary>Returns the sum of the elements.</summary> /// <param name="stream">The input CloudFlow.</param> /// <returns>The sum of the elements.</returns> public static Cloud <long> Sum(this CloudFlow <long> stream) { return(CSharpProxy.Sum(stream)); }
/// <summary> /// Returns a flow that contains no duplicate entries according to the generic hash and equality comparisons on the keys returned by the given key-generating function. /// If an element occurs multiple times in the flow then only one is retained. /// </summary> /// <typeparam name="TSource">Cloud flow element type.</typeparam> /// <typeparam name="TKey">Distinction key type.</typeparam> /// <param name="flow">Input cloud flow.</param> /// <param name="projection">Key projection function.</param> /// <returns>A CloudFlow with unique occurences of elements up to key comparison.</returns> public static CloudFlow <TSource> DistinctBy <TSource, TKey>(this CloudFlow <TSource> flow, Func <TSource, TKey> projection) where TKey : IComparable { return(CloudFlowModule.distinctBy(projection.ToFSharpFunc(), flow)); }
/// <summary>Returns the sum of the elements.</summary> /// <param name="stream">The input CloudFlow.</param> /// <returns>The sum of the elements.</returns> public static Cloud <decimal> Sum(this CloudFlow <decimal> stream) { return(CSharpProxy.Sum(stream)); }
/// <summary> /// Returns true if all elements in the CloudFlow satisfy the supplied predicate. /// </summary> /// <typeparam name="TSource">Cloud flow element type.</typeparam> /// <param name="flow">Input cloud flow.</param> /// <param name="predicate">A function to test each source element for a condition.</param> /// <returns>Returns true if all elements in the CloudFlow satisfy the supplied predicate.</returns> public static Cloud <bool> All <TSource>(this CloudFlow <TSource> flow, Func <TSource, bool> predicate) { return(CloudFlowModule.forall(predicate.ToFSharpFunc(), flow)); }
/// <summary> /// Applies a key-generating function to each element of a CloudFlow and return a CloudFlow yielding unique keys and their number of occurrences in the original sequence. /// </summary> /// <param name="projection">A function that maps items from the input CloudFlow to keys.</param> /// <param name="stream">The input CloudFlow.</param> public static CloudFlow <Tuple <TKey, long> > CountBy <TSource, TKey>(this CloudFlow <TSource> stream, Func <TSource, TKey> projection) { return(CSharpProxy.CountBy(stream, projection)); }
/// <summary>Creates an array from the given CloudFlow.</summary> /// <param name="flow">The input CloudFlow.</param> /// <returns>The result array.</returns> public static Cloud <TSource[]> ToArray <TSource>(this CloudFlow <TSource> flow) { return(CloudFlowModule.toArray(flow)); }
/// <summary>Creates a CloudVector from the given CloudFlow.</summary> /// <param name="stream">The input CloudFlow.</param> /// <returns>The result CloudVector.</returns> public static Cloud <CloudVector <TSource> > ToCloudVector <TSource>(this CloudFlow <TSource> stream) { return(CloudFlowModule.toCloudVector(stream)); }
/// <summary>Creates a PersistedCloudFlow from the given CloudFlow.</summary> /// <param name="flow">The input CloudFlow.</param> /// <param name="storageLevel">Desired storage level for the persisted CloudFlow.</param> /// <returns>The result PersistedCloudFlow.</returns> public static Cloud <PersistedCloudFlow <TSource> > Persist <TSource>(this CloudFlow <TSource> flow, StorageLevel storageLevel) { return(CloudFlowModule.persist(storageLevel, flow)); }
/// <summary>Filters the elements of the input CloudFlow.</summary> /// <param name="predicate">A function to test each source element for a condition.</param> /// <param name="stream">The input CloudFlow.</param> /// <returns>The result CloudFlow.</returns> public static CloudFlow <TSource> Where <TSource>(this CloudFlow <TSource> stream, Func <TSource, bool> predicate) { return(CSharpProxy.Where(stream, predicate)); }
/// <summary>Creates a PersistedCloudFlow from the given CloudFlow.</summary> /// <param name="flow">The input CloudFlow.</param> /// <returns>The result PersistedCloudFlow.</returns> public static Cloud <PersistedCloudFlow <TSource> > Cache <TSource>(this CloudFlow <TSource> flow) { return(CloudFlowModule.cache(flow)); }
/// <summary>Returns a cloud stream with a new degree of parallelism.</summary> /// <param name="stream">The input cloud stream.</param> /// <param name="degreeOfParallelism">The degree of parallelism.</param> /// <returns>The result cloud stream.</returns> public static CloudFlow <TSource> WithDegreeOfParallelism <TSource>(this CloudFlow <TSource> stream, int degreeOfParallelism) { return(CloudFlowModule.withDegreeOfParallelism(degreeOfParallelism, stream)); }
/// <summary> /// Enqueues all values in the cloud flow to the supplied cloud queue /// </summary> /// <typeparam name="TSource">Cloud flow element type.</typeparam> /// <param name="flow">The input CloudFlow.</param> /// <param name="queue">Target CloudQueue to enqueue messages.</param> /// <returns>A Cloud computation which distributively enqueues all elements in the cloud flow to the supplied queue.</returns> public static Cloud <Unit> ToCloudQueue <TSource>(this CloudFlow <TSource> flow, CloudQueue <TSource> queue) { return(CloudFlowModule.toCloudQueue(queue, flow)); }
/// <summary>Applies a key-generating function to each element of a CloudFlow and return a CloudFlow yielding unique keys and the result of the threading an accumulator.</summary> /// <param name="projection">A function to transform items from the input CloudFlow to keys.</param> /// <param name="folder">A function that updates the state with each element from the CloudFlow.</param> /// <param name="combiner">A function that combines partial states into a new state.</param> /// <param name="state">A function that produces the initial state.</param> /// <param name="stream">The input CloudFlow.</param> /// <returns>The final result.</returns> public static CloudFlow <Tuple <TKey, TAccumulate> > AggregateBy <TSource, TKey, TAccumulate>(this CloudFlow <TSource> stream, Func <TSource, TKey> projection, Func <TAccumulate> state, Func <TAccumulate, TSource, TAccumulate> folder, Func <TAccumulate, TAccumulate, TAccumulate> combiner) { return(CSharpProxy.AggregateBy(stream, projection, state, folder, combiner)); }
/// <summary>Returns the sum of the elements.</summary> /// <param name="flow">The input CloudFlow.</param> /// <returns>The sum of the elements.</returns> public static Cloud <decimal> Sum(this CloudFlow <decimal> flow) { return(CloudFlowModule.sum(flow)); }