• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BulkWriteResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.mongodb.BulkWriteResult的典型用法代码示例。如果您正苦于以下问题:Java BulkWriteResult类的具体用法?Java BulkWriteResult怎么用?Java BulkWriteResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BulkWriteResult类属于com.mongodb包,在下文中一共展示了BulkWriteResult类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: updateProcessingStatus

import com.mongodb.BulkWriteResult; //导入依赖的package包/类
public void updateProcessingStatus(Collection<String> statusesToApplyTo, Stream<Submittable> submittables, Submission submission, ProcessingStatusEnum processingStatusEnum) {

        BulkOperations ops = mongoTemplate.bulkOps(BulkOperations.BulkMode.UNORDERED, ProcessingStatus.class);

        Update update = update("status", processingStatusEnum.name());

        submittables
                .map(submittable -> query(
                        where("submissionId").is(submission.getId())
                                .and("submittableId").is(submittable.getId())
                                .and("status").in(statusesToApplyTo)
                ))
                .forEach(query ->
                        ops.updateOne(query, update)
                );

        BulkWriteResult writeResult = ops.execute();
        logger.info("Setting processing status to {} for certs for {} items in submission {}",
                processingStatusEnum,
                writeResult.getModifiedCount(),
                submission.getId()
        );
    }
 
开发者ID:EMBL-EBI-SUBS-OLD,项目名称:subs,代码行数:24,代码来源:ProcessingStatusBulkOperations.java


示例2: executeBatchUpdate

import com.mongodb.BulkWriteResult; //导入依赖的package包/类
private void executeBatchUpdate(BulkWriteOperation batchOp, BasicDBList fullBatch) {

		if(batchOp != null){
			BulkWriteResult result = batchOp.execute();
			logger.debug("Wrote sample batch - sent {} : updated {}", 
					fullBatch.size(), result.getModifiedCount());
		}
	}
 
开发者ID:mongodb-labs,项目名称:hvdf,代码行数:9,代码来源:RollupStorageInterceptor.java


示例3: applyProcessingCertificates

import com.mongodb.BulkWriteResult; //导入依赖的package包/类
public void applyProcessingCertificates(ProcessingCertificateEnvelope envelope, Class submittableClass) {
    Assert.notNull(envelope);
    Assert.notNull(envelope.getSubmissionId());
    Assert.notNull(envelope.getProcessingCertificates());

    BulkOperations ops = mongoTemplate.bulkOps(BulkOperations.BulkMode.UNORDERED, submittableClass);
    boolean haveAccession = false;

    for (ProcessingCertificate certificate : envelope.getProcessingCertificates()) {
        Query query = query(
                where("_id").is(certificate.getSubmittableId())
                        .and("submission.$id").is(envelope.getSubmissionId())
        );

        Update update = new Update();
        boolean haveUpdates = false;

        if (certificate.getAccession() != null) {
            update.set("accession", certificate.getAccession());
            haveUpdates = true;
            haveAccession = true;
        }

        if (haveUpdates) {
            ops.updateOne(query, update);
        }

    }

    if (haveAccession) {
        BulkWriteResult writeResult = ops.execute();
        logger.info("Applying certs for {} in submission {}, {} certs, changed {}",
                submittableClass,
                envelope.getSubmissionId(),
                envelope.getProcessingCertificates().size(),
                writeResult.getModifiedCount()
        );
    }

}
 
开发者ID:EMBL-EBI-SUBS-OLD,项目名称:subs,代码行数:41,代码来源:SubmittablesBulkOperations.java


示例4: bulkSave2

import com.mongodb.BulkWriteResult; //导入依赖的package包/类
/**
 * MongoDB bulk save
 * 
 * @return
 */

protected boolean bulkSave2(List<DBObject> objects) {
	if (objects.size() == 0)
		return false;
	BulkWriteOperation builder = getCollection().initializeUnorderedBulkOperation();
	for (DBObject doc : objects) {
		builder.insert(doc);
	}
	BulkWriteResult result = builder.execute();
	return result.isAcknowledged();
}
 
开发者ID:AKSW,项目名称:LODVader,代码行数:17,代码来源:DBSuperClass2.java


示例5: executeBatchWrite

import com.mongodb.BulkWriteResult; //导入依赖的package包/类
private void executeBatchWrite(BulkWriteOperation batchOp, BasicDBList fullBatch) {

		if(batchOp != null){
			BulkWriteResult result = batchOp.execute();
			logger.debug("Wrote sample batch - sent {} : inserted {}", 
					fullBatch.size(), result.getInsertedCount());
		}
	}
 
开发者ID:mongodb-labs,项目名称:hvdf,代码行数:9,代码来源:RawStorageInterceptor.java


示例6: putAll

import com.mongodb.BulkWriteResult; //导入依赖的package包/类
@Override
public void putAll(GridCacheTx tx,
		Map<? extends String, ? extends YagoLabel> map)
		throws GridException {
	BulkWriteOperation bulk = labelColl.initializeUnorderedBulkOperation();
	for (Entry<? extends String, ? extends YagoLabel> entry : map.entrySet()) {
		BasicDBObject dbo = toDBObject(entry.getKey(), entry.getValue());
		bulk.find(new BasicDBObject("_id", entry.getKey())).upsert().replaceOne(dbo);
	}
	BulkWriteResult writeResult = bulk.execute();
	log.debug("Put {} documents: inserted={}, modified={}, upserted={}", 
			map.size(), writeResult.getInsertedCount(), writeResult.getModifiedCount(), writeResult.getUpserts().size());
}
 
开发者ID:lumenrobot,项目名称:lumen-kb,代码行数:14,代码来源:YagoLabelCacheStore.java


示例7: batchUpdate

import com.mongodb.BulkWriteResult; //导入依赖的package包/类
/**
 * Runs a batch update using bwo
 *
 * @param bwo The bulk write operation
 * @param writeConcern
 * @param batchSize
 * @param results The results are populated during this call with an error for each failed doc
 * @param logger The logger
 *
 * @return If returns true, all docs are updated. Otherwise, there
 * are some failed docs, and concurrent update error detection
 * should be called
 */
public static boolean batchUpdate(BulkWriteOperation bwo,
                                  WriteConcern writeConcern,
                                  int batchSize,
                                  Map<Integer,Error> results,
                                  Logger logger) {
    boolean ret=true;
    BulkWriteResult writeResult;
    logger.debug("attemptToUpdate={}",batchSize);
    try {
        if(writeConcern==null) {
            writeResult=bwo.execute();
        } else {
            writeResult=bwo.execute(writeConcern);
        }
        logger.debug("writeResult={}",writeResult);
        if(batchSize==writeResult.getMatchedCount()) {
            logger.debug("Successful update");
        } else {
            logger.warn("notUpdated={}",batchSize-writeResult.getMatchedCount());
            ret=false;
        }
    } catch (BulkWriteException e) {
        List<BulkWriteError> writeErrors=e.getWriteErrors();
        if(writeErrors!=null) {
            for(BulkWriteError we:writeErrors) {
                if (MongoCrudConstants.isDuplicate(we.getCode())) {
                    results.put(we.getIndex(),
                                Error.get("update", MongoCrudConstants.ERR_DUPLICATE, we.getMessage()));
                } else {
                    results.put(we.getIndex(),
                                Error.get("update", MongoCrudConstants.ERR_SAVE_ERROR, we.getMessage()));
                }
            }
        }
        ret=false;
    }
    return ret;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:52,代码来源:BatchUpdate.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ValueArray类代码示例发布时间:2022-05-23
下一篇:
Java EquivalenceTester类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap