20
20
21
21
// Mongo
22
22
23
- import org .bson .LazyBSONObject ;
24
23
import org .bson .LazyDBList ;
25
24
import org .bson .types .ObjectId ;
26
25
@@ -1149,9 +1148,9 @@ public List distinct( String key, ReadPreference readPrefs ){
1149
1148
* @return
1150
1149
* @throws MongoException
1151
1150
*/
1152
- public List distinct ( String key , DBObject query ){
1153
- return distinct (key , query , getReadPreference ());
1154
- }
1151
+ public List distinct ( String key , DBObject query ){
1152
+ return distinct (key , query , getReadPreference ());
1153
+ }
1155
1154
1156
1155
/**
1157
1156
* find distinct values for a key
@@ -1172,7 +1171,7 @@ public List distinct( String key , DBObject query, ReadPreference readPrefs ){
1172
1171
res .throwOnError ();
1173
1172
return (List )(res .get ( "values" ));
1174
1173
}
1175
-
1174
+
1176
1175
/**
1177
1176
* performs a map reduce operation
1178
1177
* Runs the command in REPLACE output mode (saves to named collection)
@@ -1262,11 +1261,7 @@ public MapReduceOutput mapReduce( String map , String reduce , String outputTarg
1262
1261
public MapReduceOutput mapReduce ( MapReduceCommand command ){
1263
1262
DBObject cmd = command .toDBObject ();
1264
1263
// if type in inline, then query options like slaveOk is fine
1265
- CommandResult res = null ;
1266
- if (command .getOutputType () == MapReduceCommand .OutputType .INLINE )
1267
- res = _db .command ( cmd , getOptions (), command .getReadPreference () != null ? command .getReadPreference () : getReadPreference () );
1268
- else
1269
- res = _db .command ( cmd );
1264
+ CommandResult res = _db .command ( cmd , getOptions (), command .getReadPreference () != null ? command .getReadPreference () : getReadPreference () );
1270
1265
res .throwOnError ();
1271
1266
return new MapReduceOutput ( this , cmd , res );
1272
1267
}
@@ -1282,7 +1277,7 @@ public MapReduceOutput mapReduce( MapReduceCommand command ){
1282
1277
public MapReduceOutput mapReduce ( DBObject command ){
1283
1278
if ( command .get ( "mapreduce" ) == null && command .get ( "mapReduce" ) == null )
1284
1279
throw new IllegalArgumentException ( "need mapreduce arg" );
1285
- CommandResult res = _db .command ( command );
1280
+ CommandResult res = _db .command ( command , getOptions (), getReadPreference () );
1286
1281
res .throwOnError ();
1287
1282
return new MapReduceOutput ( this , command , res );
1288
1283
}
@@ -1309,7 +1304,7 @@ public AggregationOutput aggregate( DBObject firstOp, DBObject ... additionalOps
1309
1304
Collections .addAll (pipelineOps , additionalOps );
1310
1305
command .put ( "pipeline" , pipelineOps );
1311
1306
1312
- CommandResult res = _db .command ( command );
1307
+ CommandResult res = _db .command ( command , getOptions (), getReadPreference () );
1313
1308
res .throwOnError ();
1314
1309
return new AggregationOutput ( command , res );
1315
1310
}
@@ -1360,7 +1355,7 @@ public void dropIndex( String name ){
1360
1355
* @throws MongoException
1361
1356
*/
1362
1357
public CommandResult getStats () {
1363
- return getDB ().command (new BasicDBObject ("collstats" , getName ()), getOptions ());
1358
+ return getDB ().command (new BasicDBObject ("collstats" , getName ()), getOptions (), getReadPreference () );
1364
1359
}
1365
1360
1366
1361
/**
0 commit comments