[elephant-devel] Design issue: sorting secondary cursor values

Ian Eslick eslick at csail.mit.edu
Tue Feb 13 22:57:18 UTC 2007


Robert and I have been discussing whether we will support sorting of  
duplicate values when traversing secondary indices.  For release  
0.6.1 we will not guarantee any particular sorting order for  
duplicate values.

Doing so makes no sense for get-instances-by-range, for example:

class1/instance1: slot1 = 2 slot2 = 1
class1/instance2: slot1 = 2 slot2 = 2
class1/instance3: slot1 = 1 slot2 = 3
class1/instance4: slot1 = 1 slot2 = 4

If you declare a secondary index on slot1 (:index t in class  
definition) you would get the following possible lists for the query:  
(get-instances-by-range 'class1 'slot1 1 2)

class1/instance3: slot1 = 1 slot2 = 3
class1/instance4: slot1 = 1 slot2 = 4
class1/instance1: slot1 = 2 slot2 = 1
class1/instance2: slot1 = 2 slot2 = 2

class1/instance4: slot1 = 1 slot2 = 4
class1/instance3: slot1 = 1 slot2 = 3
class1/instance2: slot1 = 2 slot2 = 2
class1/instance1: slot1 = 2 slot2 = 1

and so on.  Results are partially ordered by slot1 value, but not by  
slot2 value or instance creation order, etc.

Duplicate sorting might make sense for your own indexed-btrees where  
duplicate sets are sorted by the primary key order of the main  
index.  We may look at this for future releases, but only if there is  
a compelling application (such as optimizing object queries).

Cheers,
Ian




More information about the elephant-devel mailing list