本文整理汇总了Java中com.mongodb.client.model.BulkWriteOptions类的典型用法代码示例。如果您正苦于以下问题:Java BulkWriteOptions类的具体用法?Java BulkWriteOptions怎么用?Java BulkWriteOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BulkWriteOptions类属于com.mongodb.client.model包,在下文中一共展示了BulkWriteOptions类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: updateAll
import com.mongodb.client.model.BulkWriteOptions; //导入依赖的package包/类
@Override
public <P extends ParaObject> void updateAll(String appid, List<P> objects) {
if (StringUtils.isBlank(appid) || objects == null) {
return;
}
try {
ArrayList<WriteModel<Document>> updates = new ArrayList<WriteModel<Document>>();
List<String> ids = new ArrayList<String>(objects.size());
for (P object : objects) {
if (object != null) {
object.setUpdated(Utils.timestamp());
Document id = new Document(ID, object.getId());
Document data = new Document("$set", toRow(object, Locked.class, true));
UpdateOneModel<Document> um = new UpdateOneModel<Document>(id, data);
updates.add(um);
ids.add(object.getId());
}
}
BulkWriteResult res = getTable(appid).bulkWrite(updates, new BulkWriteOptions().ordered(true));
logger.debug("Updated: " + res.getModifiedCount() + ", keys: " + ids);
} catch (Exception e) {
logger.error(null, e);
}
logger.debug("DAO.updateAll() {}", objects.size());
}
开发者ID:Erudika,项目名称:para-dao-mongodb,代码行数:26,代码来源:MongoDBDAO.java
示例2: bulkDelete
import com.mongodb.client.model.BulkWriteOptions; //导入依赖的package包/类
@Override
public long bulkDelete(List<?> ids) {
StopWatch watch = new StopWatch();
int deletedRows = 0;
try {
List<DeleteOneModel<T>> models = new ArrayList<>(ids.size());
for (Object id : ids) {
models.add(new DeleteOneModel<>(Filters.eq("_id", id)));
}
BulkWriteResult result = collection().bulkWrite(models, new BulkWriteOptions().ordered(false));
deletedRows = result.getDeletedCount();
return deletedRows;
} finally {
long elapsedTime = watch.elapsedTime();
ActionLogContext.track("mongoDB", elapsedTime, 0, deletedRows);
logger.debug("bulkDelete, collection={}, size={}, elapsedTime={}", collectionName, ids.size(), elapsedTime);
checkSlowOperation(elapsedTime);
}
}
开发者ID:neowu,项目名称:core-ng-project,代码行数:20,代码来源:MongoCollectionImpl.java
示例3: storeAll
import com.mongodb.client.model.BulkWriteOptions; //导入依赖的package包/类
@Override
public void storeAll(Map<String, Supplement> map) {
log.info("storeAll");
List<InsertOneModel> batch = new LinkedList<InsertOneModel>();
for (Map.Entry<String, Supplement> entry : map.entrySet()) {
String key = entry.getKey();
Supplement value = entry.getValue();
batch.add(new InsertOneModel(
new Document("name", value.getName()).append("price", value.getPrice())
.append("_id", key)));
}
this.collection.bulkWrite(batch, new BulkWriteOptions().ordered(false));
}
开发者ID:gAmUssA,项目名称:testcontainers-hazelcast,代码行数:14,代码来源:MongoMapStore.java
示例4: onScheduled
import com.mongodb.client.model.BulkWriteOptions; //导入依赖的package包/类
@OnScheduled
public void onScheduled(final ProcessContext context) {
batchSize = context.getProperty(MongoProps.BATCH_SIZE).asInteger();
boolean ordered = context.getProperty(MongoProps.ORDERED).asBoolean();
writeOptions = new BulkWriteOptions().ordered(ordered);
createMongoConnection(context);
ensureIndexes(context, collection);
}
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:10,代码来源:StoreInMongo.java
示例5: bulkWrite
import com.mongodb.client.model.BulkWriteOptions; //导入依赖的package包/类
@Test
public void bulkWrite()
{
List<WriteModel<Document>> list = insertOneWithBulk();
coll.deleteOne(Filters.eq("name", "DELETEME"));
coll.bulkWrite(list, new BulkWriteOptions());
coll.deleteMany(Filters.eq("name", "DELETEME"));
}
开发者ID:dd00f,项目名称:ibm-performance-monitor,代码行数:12,代码来源:ProfiledMongoClientTest.java
示例6: bulkInsert
import com.mongodb.client.model.BulkWriteOptions; //导入依赖的package包/类
public CompletableFuture<Integer> bulkInsert(final String collectionName, final Collection<?> entities, final BulkWriteOptions options) {
return asyncExecutor.execute(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
return dbExecutor.bulkInsert(collectionName, entities, options);
}
});
}
开发者ID:landawn,项目名称:AbacusUtil,代码行数:9,代码来源:AsyncMongoDBExecutor.java
示例7: bulkWrite
import com.mongodb.client.model.BulkWriteOptions; //导入依赖的package包/类
public CompletableFuture<BulkWriteResult> bulkWrite(final String collectionName, final List<? extends WriteModel<? extends Document>> requests,
final BulkWriteOptions options) {
return asyncExecutor.execute(new Callable<BulkWriteResult>() {
@Override
public BulkWriteResult call() throws Exception {
return dbExecutor.bulkWrite(collectionName, requests, options);
}
});
}
开发者ID:landawn,项目名称:AbacusUtil,代码行数:10,代码来源:AsyncMongoDBExecutor.java
示例8: bulkInsert
import com.mongodb.client.model.BulkWriteOptions; //导入依赖的package包/类
public int bulkInsert(final Collection<?> entities, final BulkWriteOptions options) {
final List<InsertOneModel<Document>> list = new ArrayList<>(entities.size());
for (Object entity : entities) {
if (entity instanceof Document) {
list.add(new InsertOneModel<Document>((Document) entity));
} else {
list.add(new InsertOneModel<Document>(MongoDBExecutor.toDocument(entity)));
}
}
return bulkWrite(list, options).getInsertedCount();
}
开发者ID:landawn,项目名称:AbacusUtil,代码行数:14,代码来源:MongoCollectionExecutor.java
示例9: bulkWrite
import com.mongodb.client.model.BulkWriteOptions; //导入依赖的package包/类
public BulkWriteResult bulkWrite(final List<? extends WriteModel<? extends Document>> requests, final BulkWriteOptions options) {
if (options == null) {
return coll.bulkWrite(requests);
} else {
return coll.bulkWrite(requests, options);
}
}
开发者ID:landawn,项目名称:AbacusUtil,代码行数:8,代码来源:MongoCollectionExecutor.java
示例10: bulkInsert
import com.mongodb.client.model.BulkWriteOptions; //导入依赖的package包/类
public CompletableFuture<Integer> bulkInsert(final Collection<?> entities, final BulkWriteOptions options) {
return asyncExecutor.execute(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
return collExecutor.bulkInsert(entities, options);
}
});
}
开发者ID:landawn,项目名称:AbacusUtil,代码行数:9,代码来源:AsyncMongoCollectionExecutor.java
示例11: bulkWrite
import com.mongodb.client.model.BulkWriteOptions; //导入依赖的package包/类
public CompletableFuture<BulkWriteResult> bulkWrite(final List<? extends WriteModel<? extends Document>> requests, final BulkWriteOptions options) {
return asyncExecutor.execute(new Callable<BulkWriteResult>() {
@Override
public BulkWriteResult call() throws Exception {
return collExecutor.bulkWrite(requests, options);
}
});
}
开发者ID:landawn,项目名称:AbacusUtil,代码行数:9,代码来源:AsyncMongoCollectionExecutor.java
示例12: importJsonFile
import com.mongodb.client.model.BulkWriteOptions; //导入依赖的package包/类
public MongoAdminClient importJsonFile(String fileNamePath) {
int count = 0;
int batch = 100;
List<InsertOneModel<Document>> docs = new ArrayList<>();
try (BufferedReader br = new BufferedReader(new FileReader(fileNamePath))) {
String line;
while ((line = br.readLine()) != null) {
docs.add(new InsertOneModel<>(Document.parse(line)));
count++;
if (count == batch) {
this.collection.bulkWrite(docs, new BulkWriteOptions().ordered(false));
docs.clear();
count = 0;
}
}
} catch (IOException fnfe) {
fnfe.printStackTrace();
}
if (count > 0) {
collection.bulkWrite(docs, new BulkWriteOptions().ordered(false));
}
return this;
}
开发者ID:datafibers-community,项目名称:df_data_service,代码行数:28,代码来源:MongoAdminClient.java
示例13: importJsonInputStream
import com.mongodb.client.model.BulkWriteOptions; //导入依赖的package包/类
public MongoAdminClient importJsonInputStream(InputStream fileInputStream) {
int count = 0;
int batch = 100;
List<InsertOneModel<Document>> docs = new ArrayList<>();
try (BufferedReader br = new BufferedReader(new InputStreamReader(fileInputStream))) {
String line;
while ((line = br.readLine()) != null) {
docs.add(new InsertOneModel<>(Document.parse(line)));
count++;
if (count == batch) {
this.collection.bulkWrite(docs, new BulkWriteOptions().ordered(false));
docs.clear();
count = 0;
}
}
} catch (IOException fnfe) {
fnfe.printStackTrace();
}
if (count > 0) {
collection.bulkWrite(docs, new BulkWriteOptions().ordered(false));
}
return this;
}
开发者ID:datafibers-community,项目名称:df_data_service,代码行数:28,代码来源:MongoAdminClient.java
示例14: bulkWrite
import com.mongodb.client.model.BulkWriteOptions; //导入依赖的package包/类
@Override
public Observable<BulkWriteResult> bulkWrite(final List<? extends WriteModel<? extends TDocument>> requests,
final BulkWriteOptions options) {
return RxObservables.create(Observables.observe(new Block<SingleResultCallback<BulkWriteResult>>() {
@Override
public void apply(final SingleResultCallback<BulkWriteResult> callback) {
wrapped.bulkWrite(requests, options, callback);
}
}), observableAdapter);
}
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:11,代码来源:MongoCollectionImpl.java
示例15: bulkWrite
import com.mongodb.client.model.BulkWriteOptions; //导入依赖的package包/类
@Override
public Publisher<BulkWriteResult> bulkWrite(final List<? extends WriteModel<? extends TDocument>> requests,
final BulkWriteOptions options) {
return new ObservableToPublisher<BulkWriteResult>(observe(new Block<SingleResultCallback<BulkWriteResult>>(){
@Override
public void apply(final SingleResultCallback<BulkWriteResult> callback) {
wrapped.bulkWrite(requests, options, callback);
}
}));
}
开发者ID:mongodb,项目名称:mongo-java-driver-reactivestreams,代码行数:11,代码来源:MongoCollectionImpl.java
示例16: bulkInsert
import com.mongodb.client.model.BulkWriteOptions; //导入依赖的package包/类
public int bulkInsert(final String collectionName, final Collection<?> entities, final BulkWriteOptions options) {
return collExecutor(collectionName).bulkInsert(entities, options);
}
开发者ID:landawn,项目名称:AbacusUtil,代码行数:4,代码来源:MongoDBExecutor.java
示例17: bulkWrite
import com.mongodb.client.model.BulkWriteOptions; //导入依赖的package包/类
public BulkWriteResult bulkWrite(final String collectionName, final List<? extends WriteModel<? extends Document>> requests,
final BulkWriteOptions options) {
return collExecutor(collectionName).bulkWrite(requests, options);
}
开发者ID:landawn,项目名称:AbacusUtil,代码行数:5,代码来源:MongoDBExecutor.java
示例18: bulkWrite
import com.mongodb.client.model.BulkWriteOptions; //导入依赖的package包/类
/**
* Executes a mix of inserts, updates, replaces, and deletes.
*
* @param requests the writes to execute
* @param options the options to apply to the bulk write operation
* @return an Observable with a single element the BulkWriteResult
*/
Observable<BulkWriteResult> bulkWrite(List<? extends WriteModel<? extends TDocument>> requests, BulkWriteOptions options);
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:9,代码来源:MongoCollection.java
示例19: bulkWrite
import com.mongodb.client.model.BulkWriteOptions; //导入依赖的package包/类
/**
* Executes a mix of inserts, updates, replaces, and deletes.
*
* @param requests the writes to execute
* @param options the options to apply to the bulk write operation
* @return a publisher with a single element the BulkWriteResult
*/
Publisher<BulkWriteResult> bulkWrite(List<? extends WriteModel<? extends TDocument>> requests, BulkWriteOptions options);
开发者ID:mongodb,项目名称:mongo-java-driver-reactivestreams,代码行数:9,代码来源:MongoCollection.java
注:本文中的com.mongodb.client.model.BulkWriteOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论