本文整理了Java中com.google.cloud.datastore.Datastore.newBatch()
方法的一些代码示例,展示了Datastore.newBatch()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Datastore.newBatch()
方法的具体详情如下:
包路径:com.google.cloud.datastore.Datastore
类名称:Datastore
方法名:newBatch
[英]Returns a new Batch for processing multiple write operations in one request.
Example of starting a new batch.
String keyName1 = "my_key_name_1";
[中]返回用于在一个请求中处理多个写入操作的新批处理。
启动新批处理的示例。
String keyName1 = "my_key_name_1";
代码示例来源:origin: googleapis/google-cloud-java
/** Example of starting a new batch. */
// [TARGET newBatch()]
// [VARIABLE "my_key_name_1"]
// [VARIABLE "my_key_name_2"]
public Batch newBatch(String keyName1, String keyName2) {
// [START newBatch]
Key key1 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName1);
Key key2 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName2);
Batch batch = datastore.newBatch();
Entity entity1 = Entity.newBuilder(key1).set("name", "John").build();
Entity entity2 = Entity.newBuilder(key2).set("title", "title").build();
batch.add(entity1);
batch.add(entity2);
batch.submit();
// [END newBatch]
return batch;
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testNewBatch() {
Batch batch = datastore.newBatch();
Entity entity1 = Entity.newBuilder(ENTITY1).clear().build();
Entity entity2 = Entity.newBuilder(ENTITY2).clear().setNull("bla").build();
batch = datastore.newBatch();
batch.delete(entity4.getKey(), entity5.getKey());
batch.update(ENTITY1, ENTITY2, ENTITY3);
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testNewBatch() {
Batch batch = DATASTORE.newBatch();
Entity entity1 = Entity.newBuilder(ENTITY1).clear().build();
Entity entity2 = Entity.newBuilder(ENTITY2).clear().setNull("bla").build();
batch = DATASTORE.newBatch();
batch.delete(entity4.getKey(), entity5.getKey(), entity6.getKey());
batch.update(ENTITY1, ENTITY2, ENTITY3);
代码示例来源:origin: spotify/styx
@Override
public Batch newBatch() {
return InstrumentedBatch.of(stats, delegate.newBatch());
}
代码示例来源:origin: sai-pullabhotla/catatumbo
/**
* Creates a new instance of <code>DefaultDatastoreBatch</code>.
*
* @param entityManager
* a reference to the entity manager
*/
public DefaultDatastoreBatch(DefaultEntityManager entityManager) {
this.entityManager = entityManager;
this.datastore = entityManager.getDatastore();
this.nativeBatch = datastore.newBatch();
this.writer = new DefaultDatastoreWriter(this);
}
内容来源于网络,如有侵权,请联系作者删除!