当前位置: 首页>>代码示例>>Java>>正文


Java BulkWriteResult.wasAcknowledged方法代码示例

本文整理汇总了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();
}
 
开发者ID:saalfeldlab,项目名称:render,代码行数:20,代码来源:MongoUtil.java

示例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);
    }
}
 
开发者ID:SoftInstigate,项目名称:restheart,代码行数:39,代码来源:BulkResultRepresentationFactory.java

示例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);
    }
}
 
开发者ID:SoftInstigate,项目名称:restheart,代码行数:43,代码来源:BulkResultRepresentationFactory.java


注:本文中的com.mongodb.bulk.BulkWriteResult.wasAcknowledged方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。