|
|
@@ -179,25 +179,17 @@ proto.makeSortOptions = function makeSortOptions(){
|
|
|
|
|
|
var opts;
|
|
|
if ( this.limitSrc)
|
|
|
- opts.limit = limitSrc.getLimt();
|
|
|
+ opts.limit = this.limitSrc.getLimt();
|
|
|
|
|
|
return opts;
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
|
|
|
proto.populate = function populate(callback) {
|
|
|
if ( this._mergePresorted ){
|
|
|
// Skipping stuff about mergeCursors and commandShards
|
|
|
-
|
|
|
- if ( this.source instanceof MergeCursorDocumentSouce ){
|
|
|
- populateFromCursors( this.source);
|
|
|
- } else if ( this.source instanceof CommandShardsDocumentSource){
|
|
|
- populateFromJsonArrays(this.source);
|
|
|
- } else {
|
|
|
- throw new Error("code 17196; the " + klass.sortName + "can only mergePresorted from MergeCursors and CommandShards");
|
|
|
- }
|
|
|
+ throw new Error("Merge presorted not implemented.");
|
|
|
} else {
|
|
|
-
|
|
|
/* pull everything from the underlying source */
|
|
|
var self = this,
|
|
|
next;
|
|
|
@@ -251,7 +243,7 @@ klass.IteratorFromCursor = (function(){
|
|
|
};
|
|
|
|
|
|
proto.next = function next() {
|
|
|
- var doc = DocumentSourceMergeCursors(this._cursor);
|
|
|
+ // var doc = new DocumentSourceMergeCursors(this._cursor);
|
|
|
// TODO: make_pair for return
|
|
|
//return {this._sorter.extractKey(doc): doc};
|
|
|
};
|
|
|
@@ -266,7 +258,7 @@ proto.populateFromCursors = function populateFromCursors(cursors){
|
|
|
|
|
|
this._output.reset( ); // TODO: MySorter::Iterator::merge(iterators, makeSortOptions(), Comparator(*this))
|
|
|
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
klass.IteratorFromBsonArray = (function(){
|
|
|
/**
|
|
|
@@ -280,7 +272,7 @@ klass.IteratorFromBsonArray = (function(){
|
|
|
}, base = Object, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
|
|
|
|
|
|
proto.next = function next() {
|
|
|
- var doc = DocumentSourceMergeCursors(this._cursor);
|
|
|
+ // var doc = new DocumentSourceMergeCursors(this._cursor);
|
|
|
// TODO: make_pair for return
|
|
|
//return {this._sorter.extractKey(doc): doc};
|
|
|
};
|
|
|
@@ -298,7 +290,8 @@ proto.populateFromBsonArrays = function populateFromBsonArrays(arrays){
|
|
|
//this.iterators.push(boost::make_shared<IteratorFromBsonArray>(this, arrays[i]));
|
|
|
}
|
|
|
this._output.reset( ); // TODO: MySorter::Iterator::merge(iterators, makeSortOptions(), Comparator(*this))
|
|
|
-}
|
|
|
+};
|
|
|
+
|
|
|
/**
|
|
|
* Extract the key
|
|
|
*
|
|
|
@@ -316,7 +309,7 @@ proto.extractKey = function extractKey(d){
|
|
|
keys.push(this.vSortKey[i].evaluate(vars));
|
|
|
}
|
|
|
return keys;
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
/**
|
|
|
* Compare two documents according to the specified sort key.
|
|
|
@@ -420,10 +413,6 @@ klass.create = function create(expCtx, sortOrder, limit) {
|
|
|
if ( keyField instanceof Object) {
|
|
|
// this restriction is due to needing to figure out sort direction
|
|
|
throw new Error("code 17312; " + klass.sortName + "the only expression supported by $sort right now is {$meta: 'textScore'}");
|
|
|
-
|
|
|
- nextSort.vSortKey.push(new ExpressionMeta());
|
|
|
- nextSort.vAscending.push(false); // best scoring documents first
|
|
|
- continue;
|
|
|
}
|
|
|
|
|
|
if (typeof sortOrder[keyField] !== "number") throw new Error("code 15974; " + klass.sortName + "$sort key ordering must be specified using a number or {$meta: 'text'}");
|