Skip to content
Browse files

Made MapReduce non generic again, since we dose not need it to be gen…

…eric.
  • Loading branch information...
1 parent 90b0912 commit ffa6baae134616428caae6336e3b58ad703e32e4 @lanwin lanwin committed May 12, 2010
View
4 source/MongoDB/Exceptions/MongoMapReduceException.cs
@@ -5,7 +5,7 @@ namespace MongoDB
/// <summary>
/// Raised when a map reduce call fails.
/// </summary>
- public class MongoMapReduceException<T> : MongoCommandException
+ public class MongoMapReduceException : MongoCommandException
{
/// <summary>
/// Gets or sets the map reduce result.
@@ -14,7 +14,7 @@ public class MongoMapReduceException<T> : MongoCommandException
public MapReduceResult MapReduceResult { get; private set; }
/// <summary>
- /// Initializes a new instance of the <see cref="MongoMapReduceException&lt;T&gt;"/> class.
+ /// Initializes a new instance of the <see cref="MongoMapReduceException"/> class.
/// </summary>
/// <param name="exception">The exception.</param>
public MongoMapReduceException(MongoCommandException exception)
View
2 source/MongoDB/IMongoCollection_1.cs
@@ -156,7 +156,7 @@ public interface IMongoCollection<T>
/// Entrypoint into executing a map/reduce query against the collection.
/// </summary>
/// <returns></returns>
- MapReduce<T> MapReduce();
+ MapReduce MapReduce();
///<summary>
/// Count all items in the collection.
View
40 source/MongoDB/MapReduce.cs
@@ -8,25 +8,29 @@ namespace MongoDB
/// <summary>
/// Provides a Fluent interface to build and execute Map/Reduce calls.
/// </summary>
- public class MapReduce<T> : IDisposable
- where T : class
+ public class MapReduce : IDisposable
{
private readonly IMongoDatabase _database;
+ private readonly Type _rootType;
private bool _canModify = true;
private bool _disposing;
/// <summary>
- /// Initializes a new instance of the <see cref = "MapReduce&lt;T&gt;" /> class.
+ /// Initializes a new instance of the <see cref = "MapReduce" /> class.
/// </summary>
/// <param name = "database">The database.</param>
/// <param name = "name">The name.</param>
- public MapReduce(IMongoDatabase database, string name)
+ /// <param name = "rootType">Type of the root.</param>
+ public MapReduce(IMongoDatabase database, string name, Type rootType)
{
if(database == null)
throw new ArgumentNullException("database");
if(name == null)
throw new ArgumentNullException("name");
+ if(rootType == null)
+ throw new ArgumentNullException("rootType");
+ _rootType = rootType;
_database = database;
Command = new MapReduceCommand(name);
}
@@ -87,7 +91,7 @@ public void Dispose()
/// A map function must call emit(key,value) at least once, but may be invoked any number of times,
/// as may be appropriate.
/// </summary>
- public MapReduce<T> Map(string function)
+ public MapReduce Map(string function)
{
return Map(new Code(function));
}
@@ -97,7 +101,7 @@ public MapReduce<T> Map(string function)
/// A map function must call emit(key,value) at least once, but may be invoked any number of times,
/// as may be appropriate.
/// </summary>
- public MapReduce<T> Map(Code function)
+ public MapReduce Map(Code function)
{
TryModify();
Command.Map = function;
@@ -112,7 +116,7 @@ public MapReduce<T> Map(Code function)
/// The MapReduce engine may invoke reduce functions iteratively; thus, these functions
/// must be idempotent. If you need to perform an operation only once, use a finalize function.
/// </remarks>
- public MapReduce<T> Reduce(string function)
+ public MapReduce Reduce(string function)
{
return Reduce(new Code(function));
}
@@ -125,7 +129,7 @@ public MapReduce<T> Reduce(string function)
/// The MapReduce engine may invoke reduce functions iteratively; thus, these functions
/// must be idempotent. If you need to perform an operation only once, use a finalize function.
/// </remarks>
- public MapReduce<T> Reduce(Code function)
+ public MapReduce Reduce(Code function)
{
TryModify();
Command.Reduce = function;
@@ -135,7 +139,7 @@ public MapReduce<T> Reduce(Code function)
/// <summary>
/// Query filter object
/// </summary>
- public MapReduce<T> Query(Document query)
+ public MapReduce Query(Document query)
{
TryModify();
Command.Query = query;
@@ -145,7 +149,7 @@ public MapReduce<T> Query(Document query)
/// <summary>
/// Sort the query. Useful for optimization
/// </summary>
- public MapReduce<T> Sort(Document sort)
+ public MapReduce Sort(Document sort)
{
TryModify();
Command.Sort = sort;
@@ -155,7 +159,7 @@ public MapReduce<T> Sort(Document sort)
/// <summary>
/// Number of objects to return from collection
/// </summary>
- public MapReduce<T> Limit(long limit)
+ public MapReduce Limit(long limit)
{
TryModify();
Command.Limit = limit;
@@ -168,7 +172,7 @@ public MapReduce<T> Limit(long limit)
/// <remarks>
/// A temporary collection is still used and then renamed to the target name atomically.
/// </remarks>
- public MapReduce<T> Out(String name)
+ public MapReduce Out(String name)
{
TryModify();
Command.Out = name;
@@ -179,7 +183,7 @@ public MapReduce<T> Out(String name)
/// When true the generated collection is not treated as temporary. Specifying out automatically makes
/// the collection permanent
/// </summary>
- public MapReduce<T> KeepTemp(bool keep)
+ public MapReduce KeepTemp(bool keep)
{
TryModify();
Command.KeepTemp = keep;
@@ -189,7 +193,7 @@ public MapReduce<T> KeepTemp(bool keep)
/// <summary>
/// Provides statistics on job execution time.
/// </summary>
- public MapReduce<T> Verbose(bool val)
+ public MapReduce Verbose(bool val)
{
TryModify();
Command.Verbose = val;
@@ -199,7 +203,7 @@ public MapReduce<T> Verbose(bool val)
/// <summary>
/// Function to apply to all the results when finished.
/// </summary>
- public MapReduce<T> Finalize(Code function)
+ public MapReduce Finalize(Code function)
{
TryModify();
Command.Finalize = function;
@@ -209,7 +213,7 @@ public MapReduce<T> Finalize(Code function)
/// <summary>
/// Document where fields go into javascript global scope
/// </summary>
- public MapReduce<T> Scope(Document scope)
+ public MapReduce Scope(Document scope)
{
TryModify();
Command.Scope = scope;
@@ -228,12 +232,12 @@ internal void RetrieveData()
try
{
- Result = new MapReduceResult(_database.SendCommand(typeof(T), Command.Command));
+ Result = new MapReduceResult(_database.SendCommand(_rootType, Command.Command));
}
catch(MongoCommandException exception)
{
Result = new MapReduceResult(exception.Error);
- throw new MongoMapReduceException<T>(exception);
+ throw new MongoMapReduceException(exception);
}
}
View
4 source/MongoDB/MongoCollection_1.cs
@@ -232,8 +232,8 @@ public T FindOne(string javascriptWhere)
return null;
}
}
-
- /// <summary>
+
+ /// <summary>
/// Entrypoint into executing a map/reduce query against the collection.
/// </summary>
/// <returns>A <see cref="MapReduce"/></returns>
View
2 source/MongoDB/Obsolete/IMongoCollection.cs
@@ -129,7 +129,7 @@ public interface IMongoCollection
/// Maps the reduce.
/// </summary>
/// <returns></returns>
- MapReduce<Document> MapReduce();
+ MapReduce MapReduce();
/// <summary>
/// Counts this instance.
View
2 source/MongoDB/Obsolete/MongoCollection.cs
@@ -180,7 +180,7 @@ public Document FindAndModify (Document document, Document spec, Document sort,
/// Maps the reduce.
/// </summary>
/// <returns></returns>
- public MapReduce<Document> MapReduce(){
+ public MapReduce MapReduce(){
return _collection.MapReduce();
}

0 comments on commit ffa6baa

Please sign in to comment.
Something went wrong with that request. Please try again.