mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
update key extraction to fit returned server format
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package io.nosqlbench.adapter.mongodb;
|
||||
|
||||
import com.mongodb.client.MongoCursor;
|
||||
import org.bson.Document;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -7,9 +8,10 @@ import java.util.List;
|
||||
|
||||
public class MongoDbUtils {
|
||||
public static int[] getFieldFromResults(String field, Document document) {
|
||||
List<Document> value = document.getList(field, Document.class);
|
||||
Document _cursor = document.get("cursor", Document.class);
|
||||
List<Document> _firstBatch = _cursor.getList("firstBatch", Document.class);
|
||||
List<String> keyStrings = new ArrayList<>();
|
||||
for (Document matchingVector : value) {
|
||||
for (Document matchingVector : _firstBatch) {
|
||||
keyStrings.add(matchingVector.get("key",String.class));
|
||||
}
|
||||
return keyStrings.stream().mapToInt(Integer::parseInt).toArray();
|
||||
|
||||
Reference in New Issue
Block a user