Skip to content
Snippets Groups Projects
Commit 8ae0bd30 authored by Jeff Yemin's avatar Jeff Yemin Committed by Robert J. Moore
Browse files

A bit more cleanup of scan and read in MongoDbClient

parent 00f0a91b
No related branches found
No related tags found
No related merge requests found
......@@ -284,7 +284,6 @@ public class MongoDbClient extends DB {
FindIterable<Document> findIterable = collection.find(query);
Document queryResult = null;
if (fields != null) {
Document projection = new Document();
for (String field : fields) {
......@@ -293,7 +292,7 @@ public class MongoDbClient extends DB {
findIterable.projection(projection);
}
queryResult = findIterable.first();
Document queryResult = findIterable.first();
if (queryResult != null) {
fillMap(result, queryResult);
......@@ -335,16 +334,21 @@ public class MongoDbClient extends DB {
Document scanRange = new Document("$gte", startkey);
Document query = new Document("_id", scanRange);
Document sort = new Document("_id", INCLUDE);
Document projection = null;
FindIterable<Document> findIterable = collection.find(query)
.sort(sort)
.limit(recordcount);
if (fields != null) {
projection = new Document();
Document projection = new Document();
for (String fieldName : fields) {
projection.put(fieldName, INCLUDE);
}
findIterable.projection(projection);
}
cursor = collection.find(query)
.projection(projection).sort(sort).limit(recordcount).iterator();
cursor = findIterable.iterator();
if (!cursor.hasNext()) {
System.err.println("Nothing found in scan for key " + startkey);
return 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment