From 27e404fa08fcc86cd54f3e3e29ef2e34bf579b13 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Sun, 1 Aug 2010 01:02:51 -0400 Subject: [PATCH] cleaning to make sure _init isn't being called twice --- client/parallel.cpp | 12 ++++++++++-- client/parallel.h | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/client/parallel.cpp b/client/parallel.cpp index 16fed16d08c..d605ebd857e 100644 --- a/client/parallel.cpp +++ b/client/parallel.cpp @@ -311,6 +311,7 @@ namespace mongo { : ClusteredCursor( q ) , _servers( servers ){ _sortKey = sortKey.getOwned(); _needToSkip = q.ntoskip; + _finishCons(); } ParallelSortClusteredCursor::ParallelSortClusteredCursor( const set& servers , const string& ns , @@ -319,15 +320,21 @@ namespace mongo { : ClusteredCursor( ns , q.obj , options , fields ) , _servers( servers ){ _sortKey = q.getSort().copy(); _needToSkip = 0; + _finishCons(); } - void ParallelSortClusteredCursor::_init(){ + void ParallelSortClusteredCursor::_finishCons(){ _numServers = _servers.size(); + _cursors = 0; + } + + void ParallelSortClusteredCursor::_init(){ + assert( ! _cursors ); _cursors = new FilteringClientCursor[_numServers]; // TODO: parellize int num = 0; - for ( set::iterator i = _servers.begin(); i!=_servers.end(); i++ ){ + for ( set::iterator i = _servers.begin(); i!=_servers.end(); ++i ){ const ServerAndQuery& sq = *i; _cursors[num++].reset( query( sq._server , 0 , sq._extra , _needToSkip ) ); } @@ -336,6 +343,7 @@ namespace mongo { ParallelSortClusteredCursor::~ParallelSortClusteredCursor(){ delete [] _cursors; + _cursors = 0; } bool ParallelSortClusteredCursor::more(){ diff --git a/client/parallel.h b/client/parallel.h index 87f1b022a0e..b60190aa3b0 100644 --- a/client/parallel.h +++ b/client/parallel.h @@ -195,7 +195,7 @@ namespace mongo { virtual BSONObj next(); virtual string type() const { return "SerialServer"; } - private: + protected: virtual void _explain( map< string,list >& out ); void _init(){} @@ -223,6 +223,7 @@ namespace mongo { virtual BSONObj next(); virtual string type() const { return "ParallelSort"; } protected: + void _finishCons(); void _init(); virtual void _explain( map< string,list >& out );