[ZODB-Dev] BTree ranges

John Belmonte jvb at prairienet.org
Mon Oct 6 21:31:55 EDT 2003


Tim Peters wrote:
> Range searches are often used to develop query results.  In any inverse
> index keyed on a finite discrete coded set (e.g., 1="hated it" thru
> 10="loved it"), there's no natural value "after the largest one".  If you
> want to find everyone who "didn't hate it", inventing an artificial key of
> 11 just so you can get at 2 thru 10 via index.values(2, 11) seems contorted
> to me.

It's not necessary for the programmer to invent a key.  The containers 
in any library that use half-open ranges will gladly provide the 
necessary end marker.  Even BTrees do this, just specify None as the end 
of the range.

Note also that with closed ranges, there is no way to specify an empty 
range.  This increases the complexity of the program, because you can't 
just pass around start and end values.  You have to pass around start, 
end, and is_empty.  Then you must be careful not to call any functions 
that take a closed range if is_empty is true.



-- 
http:// if   le.o  /




More information about the ZODB-Dev mailing list