deyles-zz / sculejs

SculeJS - data structures for the web
165 stars 24 forks source link

Index selection fails in Ti build if attribute ordering in query does not match index definition #3

Closed deyles-zz closed 11 years ago

deyles-zz commented 11 years ago

Queries against indexed collections in Ti are failing when the ordering of attributes within queries is not the same as the index definition. Example provided below:

var collection = scule.factoryCollection('scule+dummy://test');
collection.ensureHashIndex('a,b,c');
for(var i=0; i < 1000; i++) {
   collection.save({
      a:i,
      b:i*2.
      c:i*3
   });
}
var o1 = collection.find({c:15, a:5, b:10}); // returns null
var o2 = collection.find({a:5, b:10, c:15}); // returns [{a:5, b:10, c:15}]

The above queries should be equivalent.

deyles-zz commented 11 years ago

expresso * interval HashMap.Hash lasted 3ms interval HashMap.Insert lasted 41ms interval HashMap.Seek lasted 11ms

interval collection - {i:{$gte:5000}, n:{$lte:80}} lasted 141ms interval collection - {i:{$gte:5000}, n:{$lte:80}} lasted 56ms interval collection - {i:{$in:[1, 2, 3, 4, 5]}} lasted 46ms interval collection - {i:{$in:[1, 2, 3, 4, 5]}} lasted 31ms interval collection - {s:{$size:3}} lasted 46ms interval collection - {s:{$size:3}} lasted 28ms interval collection - {o:{$size:5}} lasted 69ms interval collection - {o:{$size:5}} lasted 48ms interval collection - {n:{$exists:false}} lasted 54ms interval collection - {n:{$exists:false}} lasted 36ms interval collection - {n:{$exists:true}} lasted 51ms interval collection - {n:{$exists:true}} lasted 37ms interval collection - {i:{$gte:70}} lasted 137ms interval collection - {i:{$gte:70}} lasted 101ms interval collection - {s:/^T/} lasted 39ms interval collection - {s:/^T/} lasted 25ms interval collection - {$or:[{n:{$lt:40}}, {i:{$gt:50}}]} lasted 54ms interval collection - {$or:[{n:{$lt:40}}, {i:{$gt:50}}]} lasted 104ms interval collection - {$or:[{n:{$lt:40}}, {i:{$gt:50}}]}, {$sort:{i:-1}, $limit:30} lasted 129ms interval collection - {$or:[{n:{$lt:40}}, {i:{$gt:50}}]}, {$sort:{i:-1}, $limit:30} lasted 81ms interval collection - {i:{$lte:90}}, {$set:{n:10, s:'Steve'}} lasted 21ms interval collection - {i:10}, {$push:{foo:'bar3'}} lasted 12ms interval collection - {i:10}, {$pushAll:{foo:['bar3', 'bar4']}} lasted 1ms interval InsertDocuments lasted 198ms interval CreateIndexes lasted 216ms interval CompileQuery lasted 1ms interval ExecuteQuery lasted 3ms interval ManualQuery lasted 1ms interval CompileQuery lasted 1ms interval ExecuteQuery lasted 4ms interval CompileQuery lasted 0ms interval ExecuteQuery lasted 3ms interval CompileQuery lasted 0ms interval ExecuteQuery lasted 2ms

100% 190 tests