|
|
@@ -40,9 +40,10 @@ var GroupDocumentSource = module.exports = function GroupDocumentSource(expCtx)
|
|
|
this.expressions = [];
|
|
|
this.idExpressions = [];
|
|
|
this.currentGroupsKeysIndex = 0;
|
|
|
-
|
|
|
}, klass = GroupDocumentSource, base = DocumentSource, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
|
|
|
|
|
|
+klass.isSplittableDocumentSource = true;
|
|
|
+
|
|
|
// TODO: Do we need this?
|
|
|
klass.groupOps = {
|
|
|
"$addToSet": Accumulators.AddToSetAccumulator.create,
|
|
|
@@ -507,3 +508,21 @@ proto._getTypeStr = function _getTypeStr(obj) {
|
|
|
typeStr = (typeofStr == "object" && obj !== null) ? obj.constructor.name : typeofStr;
|
|
|
return typeStr;
|
|
|
};
|
|
|
+
|
|
|
+proto.getShardSource = function getShardSource() {
|
|
|
+ return this;
|
|
|
+}
|
|
|
+
|
|
|
+proto.getMergeSource = function getMergeSource() {
|
|
|
+ var merger = klass.create(this.expCtx);
|
|
|
+
|
|
|
+ var idGenerator = new VariablesIdGenerator(),
|
|
|
+ vps = new VariablesParseState(idGenerator);
|
|
|
+
|
|
|
+ merger.idExpressions.push(FieldPathExpression.parse("$$ROOT._id", vps));
|
|
|
+ for (var i = 0; i < self.fieldNames.length; i++) {
|
|
|
+ merger.addAccumulator(self.fieldNames[i], self.accumulatorFactories[i], FieldPathExpression("$$ROOT." + self.fieldNames[i], vps));
|
|
|
+ }
|
|
|
+
|
|
|
+ return merger;
|
|
|
+};
|