Displaying differences for changeset |
@@ -164,6 +164,7 @@ |
*/ |
public void insertData(MongoCollection collection, Document locationDoc) { |
// Create a document with each chunk |
+ List<Document> docs = new ArrayList<>(); |
for (Pair<Integer, List<List<Object>>> chunk : data) { |
int year = chunk.getLeft(); |
List<List<Object>> rows = chunk.getRight(); |
@@ -171,7 +172,8 @@ |
.append("location_id", locationDoc.get("_id")) |
.append("year", year) |
.append("data", rows); |
- collection.insertOne(chunkDoc); |
+ docs.add(chunkDoc); |
} |
+ collection.insertMany(docs); |
} |
} |