使用 Java 协议缓冲区的批量 Google 数据存储查询
Bulk Google Datastore Queries using Java Protocol Buffers
谁能告诉我如何使用 Protocol Buffers 在 Java 中执行 Bulk/Multiple 数据存储区查询。
Python 有批量获取和放置。但是如何在 Java?
Java 的云客户端库解决了我所有的问题。
Datastore datastore;
DatastoreOptions options = DatastoreOptions.newBuilder().setProjectId("yourprojectID").setCredentials(GoogleCredentials.fromStream( new FileInputStream("localKeyFile.json"))).build();
dataStore = options.getService();
List<Key> queryKeys = new ArrayList<>();
Key key = datastore.newKeyFactory().setKind("SomeKind").newKey(1234L);
queryKeys.add(key);
// Add more keys if you need to the List..then start query!
Iterable<Key> keyIterable = queryKeys;
List<Entity> entities = null;
// Get Results
entities = dataStore.fetch(keyIterable);
请参阅下面的链接以下载库和文档。
请投票并享受!
http://googlecloudplatform.github.io/google-cloud-java/0.21.1/index.html
还有文档-
https://github.com/GoogleCloudPlatform/google-cloud-java
谁能告诉我如何使用 Protocol Buffers 在 Java 中执行 Bulk/Multiple 数据存储区查询。
Python 有批量获取和放置。但是如何在 Java?
Java 的云客户端库解决了我所有的问题。
Datastore datastore;
DatastoreOptions options = DatastoreOptions.newBuilder().setProjectId("yourprojectID").setCredentials(GoogleCredentials.fromStream( new FileInputStream("localKeyFile.json"))).build();
dataStore = options.getService();
List<Key> queryKeys = new ArrayList<>();
Key key = datastore.newKeyFactory().setKind("SomeKind").newKey(1234L);
queryKeys.add(key);
// Add more keys if you need to the List..then start query!
Iterable<Key> keyIterable = queryKeys;
List<Entity> entities = null;
// Get Results
entities = dataStore.fetch(keyIterable);
请参阅下面的链接以下载库和文档。
请投票并享受!
http://googlecloudplatform.github.io/google-cloud-java/0.21.1/index.html
还有文档- https://github.com/GoogleCloudPlatform/google-cloud-java