private void mergeUpserts(final List<BulkWriteUpsert> upserts, final IndexMap indexMap) { for (BulkWriteUpsert bulkWriteUpsert : upserts) { writeUpserts.add(new BulkWriteUpsert(indexMap.map(bulkWriteUpsert.getIndex()), bulkWriteUpsert.getId())); } }
private WriteConcernResult translateBulkWriteResult(final BulkWriteResult bulkWriteResult) { return WriteConcernResult.acknowledged(getCount(bulkWriteResult), getUpdatedExisting(bulkWriteResult), bulkWriteResult.getUpserts().isEmpty() ? null : bulkWriteResult.getUpserts().get(0).getId()); }
private UpdateResult toUpdateResult(final com.mongodb.bulk.BulkWriteResult result) { if (result.wasAcknowledged()) { Long modifiedCount = result.isModifiedCountAvailable() ? (long) result.getModifiedCount() : null; BsonValue upsertedId = result.getUpserts().isEmpty() ? null : result.getUpserts().get(0).getId(); return UpdateResult.acknowledged(result.getMatchedCount(), modifiedCount, upsertedId); } else { return UpdateResult.unacknowledged(); } }
private WriteConcernResult translateBulkWriteResult(final WriteRequest.Type type, final BulkWriteResult writeResult) { switch (type) { case INSERT: return WriteConcernResult.acknowledged(writeResult.getInsertedCount(), false, null); case DELETE: return WriteConcernResult.acknowledged(writeResult.getDeletedCount(), false, null); case UPDATE: case REPLACE: return WriteConcernResult.acknowledged(writeResult.getMatchedCount() + writeResult.getUpserts().size(), writeResult.getMatchedCount() > 0, writeResult.getUpserts().isEmpty() ? null : writeResult.getUpserts().get(0).getId()); default: throw new MongoInternalException("Unhandled write request type: " + type); } }
private static Object getUpsertedId(final com.mongodb.bulk.BulkWriteUpsert cur, final Decoder<DBObject> decoder) { return decoder.decode(new BsonDocumentReader(new BsonDocument("_id", cur.getId())), DecoderContext.builder().build()).get("_id"); }
private void addBulkWriteResultToResponse(final BulkWriteResult bulkWriteResult, final BsonDocument response) { response.put("ok", new BsonInt32(1)); if (getType() == INSERT) { response.put("n", new BsonInt32(0)); } else if (getType() == DELETE) { response.put("n", new BsonInt32(bulkWriteResult.getDeletedCount())); } else if (getType() == UPDATE || getType() == REPLACE) { response.put("n", new BsonInt32(bulkWriteResult.getMatchedCount() + bulkWriteResult.getUpserts().size())); if (bulkWriteResult.getUpserts().isEmpty()) { response.put("updatedExisting", BsonBoolean.TRUE); } else { response.put("updatedExisting", BsonBoolean.FALSE); response.put("upserted", bulkWriteResult.getUpserts().get(0).getId()); } } }
private void mergeUpserts(final List<BulkWriteUpsert> upserts, final IndexMap indexMap) { for (BulkWriteUpsert bulkWriteUpsert : upserts) { writeUpserts.add(new BulkWriteUpsert(indexMap.map(bulkWriteUpsert.getIndex()), bulkWriteUpsert.getId())); } }
private WriteConcernResult translateBulkWriteResult(final BulkWriteResult bulkWriteResult) { return WriteConcernResult.acknowledged(getCount(bulkWriteResult), getUpdatedExisting(bulkWriteResult), bulkWriteResult.getUpserts().isEmpty() ? null : bulkWriteResult.getUpserts().get(0).getId()); }
private UpdateResult toUpdateResult(final com.mongodb.bulk.BulkWriteResult result) { if (result.wasAcknowledged()) { Long modifiedCount = result.isModifiedCountAvailable() ? (long) result.getModifiedCount() : null; BsonValue upsertedId = result.getUpserts().isEmpty() ? null : result.getUpserts().get(0).getId(); return UpdateResult.acknowledged(result.getMatchedCount(), modifiedCount, upsertedId); } else { return UpdateResult.unacknowledged(); } }
private UpdateResult toUpdateResult(final com.mongodb.bulk.BulkWriteResult result) { if (result.wasAcknowledged()) { Long modifiedCount = result.isModifiedCountAvailable() ? (long) result.getModifiedCount() : null; BsonValue upsertedId = result.getUpserts().isEmpty() ? null : result.getUpserts().get(0).getId(); return UpdateResult.acknowledged(result.getMatchedCount(), modifiedCount, upsertedId); } else { return UpdateResult.unacknowledged(); } }
private WriteConcernResult translateBulkWriteResult(final WriteRequest.Type type, final BulkWriteResult writeResult) { switch (type) { case INSERT: return WriteConcernResult.acknowledged(writeResult.getInsertedCount(), false, null); case DELETE: return WriteConcernResult.acknowledged(writeResult.getDeletedCount(), false, null); case UPDATE: case REPLACE: return WriteConcernResult.acknowledged(writeResult.getMatchedCount() + writeResult.getUpserts().size(), writeResult.getMatchedCount() > 0, writeResult.getUpserts().isEmpty() ? null : writeResult.getUpserts().get(0).getId()); default: throw new MongoInternalException("Unhandled write request type: " + type); } }
private WriteConcernResult translateBulkWriteResult(final WriteRequest.Type type, final BulkWriteResult writeResult) { switch (type) { case INSERT: return WriteConcernResult.acknowledged(writeResult.getInsertedCount(), false, null); case DELETE: return WriteConcernResult.acknowledged(writeResult.getDeletedCount(), false, null); case UPDATE: case REPLACE: return WriteConcernResult.acknowledged(writeResult.getMatchedCount() + writeResult.getUpserts().size(), writeResult.getMatchedCount() > 0, writeResult.getUpserts().isEmpty() ? null : writeResult.getUpserts().get(0).getId()); default: throw new MongoInternalException("Unhandled write request type: " + type); } }
private static Object getUpsertedId(final com.mongodb.bulk.BulkWriteUpsert cur, final Decoder<DBObject> decoder) { return decoder.decode(new BsonDocumentReader(new BsonDocument("_id", cur.getId())), DecoderContext.builder().build()).get("_id"); }
private void addBulkWriteResultToResponse(final BulkWriteResult bulkWriteResult, final BsonDocument response) { response.put("ok", new BsonInt32(1)); if (getType() == INSERT) { response.put("n", new BsonInt32(0)); } else if (getType() == DELETE) { response.put("n", new BsonInt32(bulkWriteResult.getDeletedCount())); } else if (getType() == UPDATE || getType() == REPLACE) { response.put("n", new BsonInt32(bulkWriteResult.getMatchedCount() + bulkWriteResult.getUpserts().size())); if (bulkWriteResult.getUpserts().isEmpty()) { response.put("updatedExisting", BsonBoolean.TRUE); } else { response.put("updatedExisting", BsonBoolean.FALSE); response.put("upserted", bulkWriteResult.getUpserts().get(0).getId()); } } }
.getReferenceLink( requestPath, update.getId())), true); });
context, requestPath, update.getId())), true); });