本文整理汇总了Java中com.mongodb.bulk.BulkWriteResult.wasAcknowledged方法的典型用法代码示例。如果您正苦于以下问题:Java BulkWriteResult.wasAcknowledged方法的具体用法?Java BulkWriteResult.wasAcknowledged怎么用?Java BulkWriteResult.wasAcknowledged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mongodb.bulk.BulkWriteResult
的用法示例。
在下文中一共展示了BulkWriteResult.wasAcknowledged方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toMessage
import com.mongodb.bulk.BulkWriteResult; //导入方法依赖的package包/类
public static String toMessage(final String context,
final BulkWriteResult result,
final int objectCount) {
final StringBuilder message = new StringBuilder(128);
message.append("processed ").append(objectCount).append(" ").append(context);
if (result.wasAcknowledged()) {
final int updates = result.getMatchedCount();
final int inserts = objectCount - updates;
message.append(" with ").append(inserts).append(" inserts and ");
message.append(updates).append(" updates");
} else {
message.append(" (result NOT acknowledged)");
}
return message.toString();
}
示例2: addWriteResult
import com.mongodb.bulk.BulkWriteResult; //导入方法依赖的package包/类
private void addWriteResult(
final BulkWriteResult wr,
final Representation rep,
final String requestPath) {
Representation nrep = new Representation();
if (wr.wasAcknowledged()) {
if (wr.getUpserts() != null) {
nrep.addProperty("inserted",
new BsonInt32(wr.getUpserts().size()));
// add links to new, upserted documents
wr.getUpserts().stream().
forEach(update -> {
nrep.addLink(
new Link("rh:newdoc",
URLUtils
.getReferenceLink(
requestPath,
update.getId())),
true);
});
}
nrep.addProperty("deleted",
new BsonInt32(wr.getDeletedCount()));
if (wr.isModifiedCountAvailable()) {
nrep.addProperty("modified",
new BsonInt32(wr.getModifiedCount()));
}
nrep.addProperty("matched",
new BsonInt32(wr.getMatchedCount()));
rep.addRepresentation("rh:result", nrep);
}
}
示例3: addBulkResult
import com.mongodb.bulk.BulkWriteResult; //导入方法依赖的package包/类
private void addBulkResult(
final BulkOperationResult result,
final RequestContext context,
final Representation rep,
final String requestPath) {
Representation nrep = new Representation();
BulkWriteResult wr = result.getBulkResult();
if (wr.wasAcknowledged()) {
if (wr.getUpserts() != null) {
nrep.addProperty("inserted",
new BsonInt32(wr.getUpserts().size()));
// add links to new, upserted documents
wr.getUpserts().stream().
forEach(update -> {
nrep.addLink(
new Link("rh:newdoc",
URLUtils
.getReferenceLink(
context,
requestPath,
update.getId())),
true);
});
}
nrep.addProperty("deleted",
new BsonInt32(wr.getDeletedCount()));
if (wr.isModifiedCountAvailable()) {
nrep.addProperty("modified",
new BsonInt32(wr.getModifiedCount()));
}
nrep.addProperty("matched",
new BsonInt32(wr.getMatchedCount()));
rep.addRepresentation("rh:result", nrep);
}
}