Yes, but then you just do a test on the entity you got from the query (one
test on one entity, fast)

so add a last step.. using previous logic you end up with x2=71 y2=75
final step will be    is (z of 76) < (y2 of 75)   if no... no results..   if
yes... have 1 result

that should solve that part

On Tue, May 4, 2010 at 02:04, romesh soni <soni.rom...@gmail.com> wrote:

> Hi Tristan,
>
> Really appreciate the logic you suggested.  But consider this case:
>
> There are only two intervals in db: x1 = 4   y1 = 70   and  x2 = 71   y2 =
> 75.
>
> I want to search by 76. The 76 doesn't fall in any category but still the
> query will return the second interval, which is not correct.
> Instead the query should say that there is no matching interval. Am I
> correct?
>
> Regards
> Romesh
>
>
> On Tue, May 4, 2010 at 11:09 AM, Tristan Slominski <
> tristan.slomin...@gmail.com> wrote:
>
>> in that case the solution to your dilemma is as follows
>>
>> query.addFilter("x", FilterOptions.LESS_THAN, z);
>> query.addSort("x", SortOrder.DESC);
>>
>> then execute the query with a limit of 1
>> that is the answer you seek
>>
>> in other words...
>>
>> assume you have two intervals    x1 = 4   y1 = 70   and  x2 = 71   y2 =
>> 75.
>> you want to find interval that matches your condition of    x < 74 < y
>>
>> add filter for x less than 74 will give you two results where x1=4 in
>> first result and x2=71 in second result
>> now sort these results descending so that x2 is the first result   x2=71
>> x1=4
>> set limit of 1 gives your query a result of x2
>>
>> you don't need property y
>>
>> does that work for you?
>>
>> On Mon, May 3, 2010 at 22:45, romesh soni <soni.rom...@gmail.com> wrote:
>>
>>> Hi Tristan,
>>>
>>> You got a good catch. But the code which populates the data will never
>>> let this happen. If there is a pair x = 4 and y = 10, then there will be no
>>> such other pair which consist values between 4 and 10. there will be one and
>>> only one set for values 4,5,6,7,8,9,10 and that will be (4,10). I hope my
>>> explanation is helpful. So it is guaranteed of having one solution per
>>> query.
>>>
>>> On Mon, May 3, 2010 at 7:31 PM, Tristan Slominski <
>>> tristan.slomin...@gmail.com> wrote:
>>>
>>>> Hey, so I've been thinking about the problem description... you
>>>> mentioned that there will ever only be one solution for the query, but that
>>>> doesn't seem like a valid constraint. For example, let x = 4 and y = 10, 
>>>> let
>>>> x2 = 5 and y2 = 11.  The value of z = 6 will result in two solutions.
>>>>
>>>> The reason I am asking, is that the contraint of only one solution
>>>> existing suggest a different mapping of solutions than the one you 
>>>> suggested
>>>> (not sure what that different approach would be yet, but it could be
>>>> something along the lines of enumerating the intervals).
>>>>
>>>> Can you guarantee the constraint of only one solution per query?
>>>>
>>>> On May 3, 2010 3:01 AM, "romesh soni" <soni.rom...@gmail.com> wrote:
>>>>
>>>> Hi Thomas,
>>>>
>>>> the possible value of x and y can be 202000000000 and 203204206207.
>>>> do you see that it is possible to make such thing in 5000 element
>>>> limitation. Are you talking of ArrayList?
>>>>
>>>> Your solution is good for small list, but I am afraid that it will not
>>>> suit my requirement..
>>>>
>>>>
>>>>
>>>>
>>>> On Mon, May 3, 2010 at 1:00 PM, Thomas <mylee...@gmail.com> wrote:
>>>> >
>>>> > Hi romesh:
>>>> >
>>>> >    Datastor...
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Google App Engine for Java" group.
>>>> To post to this group, send email to
>>>> google-appengine-j...@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> google-appengine-java+unsubscr...@googlegroups.com<google-appengine-java%2bunsubscr...@googlegroups.com>
>>>> .
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Google App Engine for Java" group.
>>> To post to this group, send email to
>>> google-appengine-j...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> google-appengine-java+unsubscr...@googlegroups.com<google-appengine-java%2bunsubscr...@googlegroups.com>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Google App Engine for Java" group.
>> To post to this group, send email to
>> google-appengine-j...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-appengine-java+unsubscr...@googlegroups.com<google-appengine-java%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-appengine-java?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com<google-appengine-java%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to