com.google.datastore.v1和com.google.cloud.datastore/缺少用于禁用索引的选项之间的区别 [英] Difference between com.google.datastore.v1 and com.google.cloud.datastore / Missing option to disable index

查看:88
本文介绍了com.google.datastore.v1和com.google.cloud.datastore/缺少用于禁用索引的选项之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在构建Google Cloud Dataflow作业,该作业可解析XML文件并使用Google Datastore保存条目,但不同的Java库似乎非常令人困惑.

I'm currently building a Google Cloud Dataflow job which parses XML files and saves the entries using Google Datastore, bu the different Java libraries seem to be very confusing.

首先,我找到了com.google.datastore.v1,它可以与Dataflow一起很好地工作,但是后来我意识到,缺少将字段排除在索引之外的选项. (我的大多数字段都不需要索引,并且永远不会在查询中使用.)

First I found com.google.datastore.v1, which works great with Dataflow, but later on I realized that the option to excludes fields from being indexed is missing. (Most of my fields do not need an index and will never be used in a query.)

然后,我找到了com.google.cloud.datastore,它具有一个名为"setExcludeFromIndexes"的方法,可以完全实现我想要的功能,但是Dataflow无法保存使用此库生成的实体.

Then I found com.google.cloud.datastore, which has a method named "setExcludeFromIndexes" to achieve exactly what I was looking for, but Dataflow is not able to save entities generated using this library.

其中一个库是较新的还是完全有区别? 有没有一种方法可以使用v1-library禁用单个字段的索引?

Is one of the libraries the newer one or what is the difference at all? And is there a way to disable indexes for single fields using the v1-library?

推荐答案

v1-library 是一个薄层,提供了生成的原始源和一些辅助函数.
google-cloud-datastore 是一个包装程序,使用旨在使用户更加友好的v1-library.
为了允许不同的Datastore客户端库与Dataflow交互,我们使用v1库,因为它是最小公分母.

v1-library is a thin layer that provides generated proto sources and some helper functions.
google-cloud-datastore is a wrapper that uses v1-library aimed to be more user friendly.
To allow different Datastore client libraries to interface with Dataflow, we use the v1 library as it is the least common denominator.

理想情况下,您将使用google-cloud-datastore库,但是根据版本的不同,v1-library和google-cloud-datastore可能具有冲突的依赖项(特别是protobuf 3.0.0 v 3.0.0-beta-1)在这种情况下,您要么必须选择兼容版本,要么直接使用v1-library.

Ideally you would use the google-cloud-datastore library, but depending on the versions, v1-library and google-cloud-datastore might have conflicting dependencies (protobuf 3.0.0 v 3.0.0-beta-1 in particular) in which case you either have to pick the compatible versions or use v1-library directly.

v1库帮助程序功能可能不足以从索引中排除字段,但是您始终可以通过直接处理原型消息来创建自己的帮助程序.在这种情况下,您将创建自己的Value并设置

The v1-library helper functions might not be enough to exclude fields from indexing but you could always create your own helpers by dealing with proto messages directly. In this particular case, you would be creating your own Value and setting exclude_from_indexes explicitly.

这篇关于com.google.datastore.v1和com.google.cloud.datastore/缺少用于禁用索引的选项之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆