user3075386
user3075386

Reputation: 31

Use of shared counter in Datastore?

I need to maintain the data in hierarchical way. for example we just consider the following names are my property of my table. AccountNo,ConnectionId,ContractId,InteractionId,book count

But the structure of that record is like in hierarchical way. Like

One AccountNo may have multiple ConnectionId as well as one ConnectionId may have multiple ContractId, as well as InteractionId. One more condition, in InteractionId is having count of number of books. Ok now

AccountNo1 -> ConnectionId1 -> ContractId1 -> InteractionId1 ->total book count is 10 AccountNo1 -> ConnectionId1 -> ContractId1 -> InteractionId2 ->total book count is 20 AccountNo1 -> ConnectionId1 -> ContractId2 -> InteractionId1 ->total book count is 4 AccountNo1 -> ConnectionId1 -> ContractId2 -> InteractionId2 ->total book count is 67 AccountNo1 -> ConnectionId2 -> ContractId1 -> InteractionId1 ->total book count is 30 . . . If i want to retrieve the data by using query like where AccountNo = 1 and ConnectionId = 1 It should display 10+20+4+67=101.

If i give query like where AccountNo = 1 and ContractId = 2 It should display 4+67.

Like that i want.

My trainer said that i can do this stuff using shared counter.But i didn't get the proper idea in that datastore website.

Upvotes: 1

Views: 248

Answers (1)

Mario
Mario

Reputation: 1230

Probably your instructor meant to use sharded counters, which is a way to split a counter among several kinds to be able to update it in parallel.

There's an example of Sharded Counters in Datastore that will allow you to understand it better.

Upvotes: 1

Related Questions