Azure Cosmos DB pagination using azure-documentdb-java - azure-cosmosdb

I am trying to understand how to implement pagination using azure-documentdb-java. As I see continuation token allows me retrieve only the next page from a query executed earlier.
Is there a way how I can return the concrete page and previous page effortlessly?

No, Cosmos DB doesn't support (efficient) offset-based pagination. You can use OFFSET LIMIT but it's not efficient. The only efficient pagination mode is token-based. You can get previously fetched pages by memorizing the previous continuation tokens (but if the underlying data has changed, the previous pages will also change).

Related

Magnolia Headless Delivery API and personalized pages with filter query

We are using the personalization module to setup page variants (page-level) using a headless approach (JS Frontend).
Reading the docs, I understood that there is either a Query nodes or Get children scenario. It looks like that page variants are only handled when not using the Query nodes case. Unfortunately, I can not order nor filter the results in that case.
Is there any chance to use filter and orderBy params but also returning page variants based on my request traits? How would such a request look like?
For performance reasons, the variants filtering on queries is not supported. Hence, short of writing your own EP, there is no solution.
As alternative/workaround, you can perhaps run query and then on the path of each result make a call to retrieve a variant of that result via individual node retrieval EP, but that's also slow and waste of bandwidth ... perhaps getting list of nodes you want via GQL EP and then getting variant for each is tiny bit better (but not much).

Pagination with Firestore

I've been using Google Cloud for a client's project. I've used App Engine + Firestore, and I had to implement pagination for a big table of logs.
I have to say, it's been really challenging and I'm still not happy with it. In my use case I need to:
Paginate without any filter
Paginate the results of a query
In the first case, I just need to have a counter store somewhere that is increased every time a new log is added to the collection. Weird but easy enough.
In the second case, I need to have the number of items in the query's result, and I had to create another "aggregation" field that saves a counter for each of the values that the field can have. And I'd have to do this for each field!
I'm wondering if I'm missing something here, or if Firestore is just not good for my use case.
How did you approach pagination with Firestore?

Deal with I/O capacities in dynamodb

We are using the dynogels library to query a dynamoDB table. Unfortunately, as dynamoDB do not have a pagination feature, for a specific need, we are retrieving all data from the table through a loadAll to get all items of the table (18K items) and we are facing a error due to exceed of the I/O read capacity.
Except this query that retrieve all the content of the table, we only have very small read usage of the table. We also tried to dynamically update the I/O unity but we are limited to 4 changes/per hour.
Can you suggest as a solution? Do you know how to use the pagination in dynamodB ? is-it possible to use DAX as a local dynamoDB cache?
Thank you
Unfortunately, as dynamoDB do not have a pagination feature, for a specific need,
DynamoDB does have pagination feature where you can specify the limit on number of pages to query and as part of the result, DynamoDB query / scan API returns a nextStartKey which can be used as the exclusiveStartKey to retrieve next, and do this until the nextStartKey is null which indicates the end of results: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.Pagination
Don't they have support of pagination in the dynogels library?

How Meteor Framework partition data?

From what I know it seems that Meteor Framework stores part of data on the client. It's clear how to do it for personal todo list - because it's small and you can just copy everything.
But how it works in case of let's say Q&A site similar to this? The collection of questions are huge, you can't possibly copy it to the client. And you need to have filtering by tags and sorting by date and popularity.
How Meteor Framework handles such case? How it partition data? Does it make sense to use Meteor for such use case?
Have a look at the meteor docs, in particular the publish and subscribe section. Here's a short example:
Imagine your database contains one million posts. But your client only needs something like:
the top 10 posts by popularity
the posts your friends made in the last hour
the posts for the group you are in
In other words, some subset of the larger collection. In order to get to that subset, the client starts a subscription. For example: Meteor.subscribe('popularPosts'). Then on the server, there will be a corresponding publish function like: Meteor.publish('popularPosts', function(){...}.
As the client moves around the app (changes routes), different subscriptions may be started and stopped.
The subset of documents are sent to the client and cached in memory in a mongodb-like store called minimongo. The client can then retrieve the documents as needed in order to render the page.

Datasource best practices question

This is probably not a difficult project, but I'm not sure of the best way to handle it.
I have an ASP.Net page that needs to query a db for some info (a list of about 12 email addresses) that are used throughout the single-page application (basically a set of 8 buttons, each of which puts an entry into another DB table which includes a message [different for each button] and the email address [from the first db] the message should be sent to).
The list of addresses rarely changes. At what point should my application query the DB for the addresses? Doing it at the button press seems like a waste, since I'll be making the same query and obtaining the same results over and over. I was thinking of opening my datasource and using a SqlDataReader and storing the list of email addresses into a string array, but where is the best place to do that so the data is persisted, yet not queried repeatedly (as you may be able to tell, I am not great at ASP, and I'm still fuzzy on what the lifetime of variables are - application, session, or just while the page is processing).
Any help is appreciated.
Thanks
Adam
Use Cache. Look for GetProductData() method implementation in this page
In your data layer, put the results of the query into the cache.
In the method, you first check if the cache entry exists, if not, you call the DB and populate the cache with the results. If it does, you return the cached values.
You need to looking into using the Cache.
The Cache is most likely what you need:
http://msdn.microsoft.com/en-us/library/6hbbsfk6.aspx
Short version is that you can stick an object in there and set expiration conditions. Such as having it expire after a fixed amount of time, after a certain amount of time goes by without it being accessed, when another value in the cache changes, or when the underlying data in the database changes.
I usually wrap my caching in properties/methods that will attempt to get the value from cache if it is present and then go back to the database if it is not (either has never been read before or has expired).

Resources