使用Google Cloud Dataflow将属性设置为null';数据存储的Java API?

使用Google Cloud Dataflow将属性设置为null';数据存储的Java API?,java,google-cloud-datastore,google-cloud-dataflow,apache-beam,Java,Google Cloud Datastore,Google Cloud Dataflow,Apache Beam,大多数google的Java数据存储文档中提到的com.google.cloud.datastore包提供了一个Builder类,该类具有setNull方法,用于将任何属性值设置为null,例如 FullEntity.Builder<IncompleteKey> builder = FullEntity.newBuilder(); builder.setNull("propertyName"); FullEntity.Builder=FullEntity.newBuilder();

大多数google的Java数据存储文档中提到的
com.google.cloud.datastore
包提供了一个Builder类,该类具有
setNull
方法,用于将任何属性值设置为
null
,例如

FullEntity.Builder<IncompleteKey> builder = FullEntity.newBuilder();
builder.setNull("propertyName");
FullEntity.Builder=FullEntity.newBuilder();
builder.setNull(“propertyName”);

Google Cloud Dataflow/Apache Beam的DataStoreo类需要包
com.Google.datastore.v1
中的实体,并且构建器方法不包括类似的
setNull
方法。如何使用V1 Java API将属性设置为
null

如果使用
com.google.datastore.V1
包实体和值,这就是如何设置null值(使用Apache Beam/google数据流):


(回答我自己的问题,因为我花了很长时间才弄明白!)

如果使用
com.google.datastore.v1
包实体和值,这就是如何设置空值(使用Apache Beam/google数据流):

(回答我自己的问题,因为我花了很长时间才弄明白!)

import com.google.datastore.v1.Entity;
import com.google.datastore.v1.Entity.Builder;
import com.google.datastore.v1.Value;
import com.google.protobuf.NullValue;

Value nullValue = Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build();
Entity.Builder builder = Entity.newBuilder();
builder.putProperties("propertyName", nullValue);