You can take an implementation of a regular heap data structure
<https://en.wikipedia.org/wiki/Heap_(data_structure)> and replace an array
with an Ignite cache.
There are a few point to take into account though:

   - The cache should be transactional and each operation should happen
   inside a transaction. Otherwise concurrent operations will break the heap
   structure.
   - You should make sure, that all keys are accessed in a certain order,
   e.g. by increasing key value. This is important to avoid deadlocks.
   You should calculate the values, that you are going to need during the
   transaction, and get their values after that in a sorted order. This way
   deadlocks will be eliminated.

Each modification operation will require O(log N) cache operations, where N
is the number of values stored in the cache.
Values may be stored in batches to minimize the number of entries to be
accessed under a single operation.
Don't make the batches too big though. Because if you do, then it will
increase contention and more unneeded information will be transferred over
network during each transaction.

Another option is to have a replicated regular priority queue stored as a
single value.
This priority queue would contain a set of keys, that may be used to access
a cache to get the actual values.
This approach may be used only if you have a small set of keys. Otherwise
the priority queue will grow huge, and storing it as a single value will be
unreasonable.
Also it will create a contention point between concurrent operations.

And the last option that I see would be to store values in a cache, and
make each node have its own local priority queue on keys.
The priority queue may be updated on continuous query
<https://apacheignite.readme.io/docs/continuous-queries> events, triggered
in the cache.
This is also applicable only for key sets, that may fit into memory of each
node.
And queue updates may be delayed, so you may get inconsistent results.

Denis

пт, 2 нояб. 2018 г. в 13:00, Luckyman <dmitriybandu...@gmail.com>:

> how we can implement distributed priority QUEUE with apache ignite?
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Reply via email to