google-cloud-datastore

What is the cost difference between paging with a cursor or using offset?

[亡魂溺海] 提交于 2019-12-01 17:58:59
When creating a results page with [Next Page] and [Prev Page] buttons, what is the cost difference between using a cursor to do this or using offset? And what are the pros and cons of each technique? As a concrete example, what is the cost of reading results 100-110. I have seen claims that offset uses "small datastore operations" and some that claim it uses a full "read operation" for each entity skipped. Using cursors, I have read that they cannot page backwards, but I noticed a new Cursor.reverse() method for the first time today. I assume that the disadvantages of using a cursor are that

How to resolve “You have not started an Objectify context” in JUnit?

99封情书 提交于 2019-12-01 16:26:32
I've got some Objectify test code running in JUnit and I'm getting this error: java.lang.IllegalStateException: You have not started an Objectify context. You are probably missing the ObjectifyFilter. If you are not running in the context of an http request, see the ObjectifyService.run() method. at com.googlecode.objectify.ObjectifyService.ofy(ObjectifyService.java:44) at com.googlecode.objectify.impl.ref.LiveRef.<init>(LiveRef.java:31) at com.googlecode.objectify.Ref.create(Ref.java:26) at com.googlecode.objectify.Ref.create(Ref.java:32) at com.netbase.followerdownloader.repository

BadArgumentError: _MultiQuery with cursors requires __key__ order in ndb

限于喜欢 提交于 2019-12-01 16:19:46
问题 I can't understand what this error means and apparently, no one ever got the same error on the internet BadArgumentError: _MultiQuery with cursors requires __key__ order This happens here: return SocialNotification.query().order(-SocialNotification.date).filter(SocialNotification.source_key.IN(nodes_list)).fetch_page(10) The property source_key is obviously a key and nodes_list is a list of entity keys previously retrieved. What I need is to find all the SocialNotifications that have a field

Node.JS Datastore Query get Key

爷,独闯天下 提交于 2019-12-01 16:18:10
How can I get the key of an entity returned by a query? I tried to access it like the normal data, but when I print the entity itself there is no key. Is there even a way to do so? Thank you in advance for your help. Since version 0.5.0 of the @google-cloud/datastore v0.5.0 the key is now accesible by a Symbol. var datastore = require('@google-cloud/datastore')(); var query = datastore.createQuery('AnimalNamespace', 'Lion'); query.run(function(err, entities) { var keys = entities.map(function(entity) { // datastore.KEY is a Symbol return entity[datastore.KEY]; }); }); You could also use the

Node.JS Datastore Query get Key

大城市里の小女人 提交于 2019-12-01 15:25:08
问题 How can I get the key of an entity returned by a query? I tried to access it like the normal data, but when I print the entity itself there is no key. Is there even a way to do so? Thank you in advance for your help. 回答1: Since version 0.5.0 of the @google-cloud/datastore v0.5.0 the key is now accesible by a Symbol. var datastore = require('@google-cloud/datastore')(); var query = datastore.createQuery('AnimalNamespace', 'Lion'); query.run(function(err, entities) { var keys = entities.map

How to resolve “You have not started an Objectify context” in JUnit?

六月ゝ 毕业季﹏ 提交于 2019-12-01 15:09:26
问题 I've got some Objectify test code running in JUnit and I'm getting this error: java.lang.IllegalStateException: You have not started an Objectify context. You are probably missing the ObjectifyFilter. If you are not running in the context of an http request, see the ObjectifyService.run() method. at com.googlecode.objectify.ObjectifyService.ofy(ObjectifyService.java:44) at com.googlecode.objectify.impl.ref.LiveRef.<init>(LiveRef.java:31) at com.googlecode.objectify.Ref.create(Ref.java:26) at

Create-or-Err with Objectify

ⅰ亾dé卋堺 提交于 2019-12-01 12:48:15
I'm getting started with Google App Engine, and I'm using Objectify. How do I create a root entity in the data store, but err if it already exists? I didn't find anything built in for this (e.g. DatastoreService.put() and therefore ofy().save() will overwrite an existing entity instead of err). The simple technique I am used to is to do this in a transaction: Err if already exists Save However, that is not idempotent; it would err in step 1 if the transaction executes twice. Here is the best I've come up with so far, not in a transaction: Err if already exists Save Fetch Err if it's not the

How to jump to specific page using Query Cursor?

旧巷老猫 提交于 2019-12-01 12:10:24
I am developing my website in python(webapp2) and google data store in back end. I have added query cursor for pagination and it's working good but it has only next and previous functions for pagination, the question is that how i will jump to specific page like i am on page 1 and i want to jump to page 3, how i will manage it in Query Cursor? i have also visited below links but didn't find any solution https://www.the-swamp.info/blog/pagination-google-app-engine/ https://cloud.google.com/appengine/docs/standard/python/datastore/query-cursors You can't. Datastore doesn't know the number of

Google App Engine - About how much quota does a single datastore put use?

冷暖自知 提交于 2019-12-01 11:06:45
The latency for a datastore put is about 150ms - http://code.google.com/status/appengine/detail/datastore/2010/03/11#ae-trust-detail-datastore-put-latency . About how much CPUTime is used by a single datastore put with data size of 100 bytes, into an entity that has only 1 property, and no indexes? Also, does anyone know about how much extra overhead in CPUTime doing this datastore put through the task queue would be? I plan to do some testing with this later today to figure it out, but if anyone already knows that would help me out :). Note: This is kind of a follow up to this question:

How to jump to specific page using Query Cursor?

試著忘記壹切 提交于 2019-12-01 10:55:24
问题 I am developing my website in python(webapp2) and google data store in back end. I have added query cursor for pagination and it's working good but it has only next and previous functions for pagination, the question is that how i will jump to specific page like i am on page 1 and i want to jump to page 3, how i will manage it in Query Cursor? i have also visited below links but didn't find any solution https://www.the-swamp.info/blog/pagination-google-app-engine/ https://cloud.google.com