/*
Copyright (c) Microsoft Corporation
All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License
at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER
EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF
TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions and
limitations under the License.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Globalization;
using System.Reflection;
using System.Linq;
using Microsoft.Research.DryadLinq.Internal;
#pragma warning disable 1591
namespace Microsoft.Research.DryadLinq.Internal
{
///
/// This class provides the IEnumerable implementation of the operators
/// we introduced in DryadLINQ. This is needed to implement LocalDebug.
///
/// A DryadLINQ user should not need to use this class directly.
public static class DryadLinqEnumerable
{
// Operator: HashPartition
public static IEnumerable
HashPartition(this IEnumerable source,
Func keySelector,
IEqualityComparer comparer,
int count)
{
return source;
}
public static IEnumerable
HashPartition(this IEnumerable source,
Func keySelector,
int count)
{
return source;
}
public static IEnumerable
HashPartition(this IEnumerable source,
Func keySelector)
{
return source;
}
public static IEnumerable
HashPartition(this IEnumerable source,
Func keySelector,
IEqualityComparer comparer)
{
return source;
}
public static IEnumerable
HashPartition(this IEnumerable source,
Func keySelector,
Func resultSelector)
{
foreach (TSource x in source)
{
yield return resultSelector(x);
}
}
public static IEnumerable
HashPartition(this IEnumerable source,
Func keySelector,
IEqualityComparer comparer,
Func resultSelector)
{
foreach (TSource x in source)
{
yield return resultSelector(x);
}
}
// Operator: RangePartition
public static IEnumerable
RangePartition(this IEnumerable source,
Func keySelector,
bool isDescending)
{
return source;
}
public static IEnumerable
RangePartition(this IEnumerable source,
Func keySelector,
IComparer comparer,
bool isDescending)
{
return source;
}
public static IEnumerable
RangePartition(this IEnumerable source,
Func keySelector,
TKey[] rangeSeparators)
{
return source;
}
public static IEnumerable
RangePartition(this IEnumerable source,
Func keySelector,
TKey[] rangeSeparators,
IComparer comparer)
{
return source;
}
// Operator: Apply
public static IEnumerable
Apply(this IEnumerable source,
Func, IEnumerable> procFunc)
{
return procFunc(source);
}
public static IEnumerable
Apply(this IEnumerable source1,
IEnumerable source2,
Func, IEnumerable, IEnumerable> procFunc)
{
return procFunc(source1, source2);
}
public static IEnumerable
Apply(this IEnumerable source,
IEnumerable[] otherSources,
Func[], IEnumerable> procFunc)
{
IEnumerable[] allSources = new IEnumerable[otherSources.Length + 1];
allSources[0] = source;
for (int i = 0; i < otherSources.Length; i++)
{
allSources[i+1] = otherSources[i];
}
return procFunc(allSources);
}
public static IEnumerable
Apply(this IEnumerable source,
IEnumerable[] otherSources,
Func, IEnumerable[], IEnumerable> procFunc)
{
return procFunc(source, otherSources);
}
// Operator: DoWhile
public static IEnumerable
DoWhile(this IEnumerable source,
Func, IQueryable> body,
Func, IQueryable, IQueryable> cond)
{
IEnumerable before = source;
while (true)
{
IEnumerable after = before;
after = body(after.AsQueryable());
var more = cond(before.AsQueryable(), after.AsQueryable()).Single();
if (!more) return after;
before = after;
}
}
// Operator: SlidingWindow
public static IEnumerable
SlidingWindow(this IEnumerable source,
Func, T2> procFunc,
Int32 windowSize)
{
Window window = new Window(windowSize);
using (IEnumerator sourceEnum = source.GetEnumerator())
{
while (window.Count() < windowSize)
{
if (!sourceEnum.MoveNext()) break;
window.Add(sourceEnum.Current);
}
if (window.Count() == windowSize)
{
yield return procFunc(window);
while (sourceEnum.MoveNext())
{
window.Add(sourceEnum.Current);
yield return procFunc(window);
}
}
}
}
// Operator: ApplyWithPartitionIndex
public static IEnumerable
ApplyWithPartitionIndex(this IEnumerable source,
Func, int, IEnumerable> procFunc)
{
return procFunc(source, 0);
}
public static IEnumerable AnyAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Any());
}
public static IEnumerable
AnyAsQuery(this IEnumerable source, Func predicate)
{
return DryadLinqVertex.AsEnumerable(source.Any(predicate));
}
public static IEnumerable
AllAsQuery(this IEnumerable source, Func predicate)
{
return DryadLinqVertex.AsEnumerable(source.All(predicate));
}
public static IEnumerable
CountAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Count());
}
public static IEnumerable
CountAsQuery(this IEnumerable source, Func predicate)
{
return DryadLinqVertex.AsEnumerable(source.Count(predicate));
}
public static IEnumerable
LongCountAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.LongCount());
}
public static IEnumerable
LongCountAsQuery(this IEnumerable source,
Func predicate)
{
return DryadLinqVertex.AsEnumerable(source.LongCount(predicate));
}
public static IEnumerable
ContainsAsQuery(this IEnumerable source, TSource value)
{
return DryadLinqVertex.AsEnumerable(source.Contains(value));
}
public static IEnumerable
ContainsAsQuery(this IEnumerable source,
TSource value,
IEqualityComparer comparer)
{
return DryadLinqVertex.AsEnumerable(source.Contains(value, comparer));
}
public static IEnumerable
SequenceEqualAsQuery(this IEnumerable first,
IEnumerable second)
{
return DryadLinqVertex.AsEnumerable(first.SequenceEqual(second));
}
public static IEnumerable
SequenceEqualAsQuery(this IEnumerable first,
IEnumerable second,
IEqualityComparer comparer)
{
return DryadLinqVertex.AsEnumerable(first.SequenceEqual(second, comparer));
}
public static IEnumerable FirstAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.First());
}
public static IEnumerable
FirstAsQuery(this IEnumerable source,
Func predicate)
{
return DryadLinqVertex.AsEnumerable(source.First(predicate));
}
public static IEnumerable LastAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Last());
}
public static IEnumerable
LastAsQuery(this IEnumerable source,
Func predicate)
{
return DryadLinqVertex.AsEnumerable(source.Last(predicate));
}
public static IEnumerable SingleAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Single());
}
public static IEnumerable
SingleAsQuery(this IEnumerable source,
Func predicate)
{
return DryadLinqVertex.AsEnumerable(source.Single(predicate));
}
public static IEnumerable SumAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Sum());
}
public static IEnumerable SumAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Sum());
}
public static IEnumerable SumAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Sum());
}
public static IEnumerable SumAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Sum());
}
public static IEnumerable SumAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Sum());
}
public static IEnumerable SumAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Sum());
}
public static IEnumerable SumAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Sum());
}
public static IEnumerable SumAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Sum());
}
public static IEnumerable SumAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Sum());
}
public static IEnumerable SumAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Sum());
}
public static IEnumerable
SumAsQuery(this IEnumerable source,
Func selector)
{
return DryadLinqVertex.AsEnumerable(source.Sum(selector));
}
public static IEnumerable
SumAsQuery(this IEnumerable source,
Func selector)
{
return DryadLinqVertex.AsEnumerable(source.Sum(selector));
}
public static IEnumerable
SumAsQuery(this IEnumerable source,
Func selector)
{
return DryadLinqVertex.AsEnumerable(source.Sum(selector));
}
public static IEnumerable
SumAsQuery(this IEnumerable source,
Func selector)
{
return DryadLinqVertex.AsEnumerable(source.Sum(selector));
}
public static IEnumerable
SumAsQuery(this IEnumerable source,
Func selector)
{
return DryadLinqVertex.AsEnumerable(source.Sum(selector));
}
public static IEnumerable
SumAsQuery(this IEnumerable source,
Func selector)
{
return DryadLinqVertex.AsEnumerable(source.Sum(selector));
}
public static IEnumerable
SumAsQuery(this IEnumerable source,
Func selector)
{
return DryadLinqVertex.AsEnumerable(source.Sum(selector));
}
public static IEnumerable
SumAsQuery(this IEnumerable source,
Func selector)
{
return DryadLinqVertex.AsEnumerable(source.Sum(selector));
}
public static IEnumerable
SumAsQuery(this IEnumerable source,
Func selector)
{
return DryadLinqVertex.AsEnumerable(source.Sum(selector));
}
public static IEnumerable
SumAsQuery(this IEnumerable source,
Func selector)
{
return DryadLinqVertex.AsEnumerable(source.Sum(selector));
}
public static IEnumerable MinAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Min());
}
public static IEnumerable MinAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Min());
}
public static IEnumerable MinAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Min());
}
public static IEnumerable MinAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Min());
}
public static IEnumerable MinAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Min());
}
public static IEnumerable MinAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Min());
}
public static IEnumerable MinAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Min());
}
public static IEnumerable MinAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Min());
}
public static IEnumerable MinAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Min());
}
public static IEnumerable MinAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Min());
}
public static IEnumerable MinAsQuery(this IEnumerable source)
{
return DryadLinqVertex.AsEnumerable(source.Min());
}
public static IEnumerable
MinAsQuery(this IEnumerable source,
Func selector)
{
return DryadLinqVertex.AsEnumerable(source.Min(selector));
}
public static IEnumerable
MinAsQuery(this IEnumerable source,
Func selector)
{
return DryadLinqVertex.AsEnumerable(source.Min(selector));
}
public static IEnumerable
MinAsQuery(this IEnumerable source,
Func selector)
{
return DryadLinqVertex.AsEnumerable(source.Min(selector));
}
public static IEnumerable
MinAsQuery(this IEnumerable source,
Func