Question

In my input I have a key , a lower bound of range R1, a upper bound of range R1. and some data.I have to insert this data only after getting ensured that my input range R1 should not overlap any other present ranges already present in cassandra.

So with before each insert i have to fire a select query

   key | lowerbound | upperbound | data
------+------------+------------+------------------------------------------------------------------------
1024 | 1000 | 1100 | <blob>
1024 | 1500 | 1900 | <blob> 
1024 | 2000 | 2900 | <blob> 
1024 | 3000 | 3900 | <blob> 
1024 | 4000 | 4500 | <blob> 

Case1 Given Range R(S,E)=(1,999)
This is a positive case hence system should Insert the data   

Case2:  Given Range R(S,E)=(1001,1010)
this is a Negative case hence system should discard the data

I have a solution with one Range query and one programmatic check solution

please let me know whether this kind of problem statement have solution in Cassandra if yes can it be optimized to get a better performance

Was it helpful?

Solution

You don't have a better solution for your problem: this is the only way. Possibly in future Lightweight Transactions might help also for these situations but now the only solution you have is to read before writing. One more consideration: ensure to avoid double insertion in concurrency situation (if this can happen in your application).

Cheers, Carlo

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top