Inheritance diagram for org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery:
Use the SODA API (http://http://odbms.org/soda) as a base API. From Soda specification the differences are : * only query on FODB collection : use query.constrain(MyCollectionObject.class) to declare it. * only query using index. use query.descend("IndexedFieldName") to specify an index.
Exemple of use: Data class :TestSearchData class signature public final class TestSearchData implements Serializable { public int getKey(); public int getDizaine(); }
FODB creation : db = FastObjectDB.open(dbdir, "testdb"); if (!FODBCollection.isCollectionExist(db, "TESTSEARCH")) { // if not created create it. db.createCollection("TESTSEARCH", TestSearchData.class); FODBUniqueIntIndexDescriptor KeyDescriptor = new FODBUniqueIntIndexDescriptor("KEY", "getKey()", 5); db.addIndex("TESTSEARCH", KeyDescriptor); FODBMultipleIntIndexDescriptor debKeyDescriptor = new FODBMultipleIntIndexDescriptor("DIZ", "getDizaine()", 5, 5); db.addIndex("TESTSEARCH", debKeyDescriptor); }
The collection TestData where keys are in the interval [0..30]. for (int i=0; i<NB_SEARCH_CREATED_DATA; i++) { db.add("TESTSEARCH", new TestSearchData(i)); }
Exemple of query : //query SELECT * FROM TESTSEARCH Query q = db.query(); q.constrain(TestSearchData.class); Query subq = q.descend("getKey()"); //specify an index to request. ObjectSet set = q.execute();
//query SELECT * FROM TESTSEARCH where getKey<14 q = db.query(); q.constrain(TestSearchData.class); subq = q.descend("getKey()"); subq.constrain(new Integer(14)).smaller(); set = q.execute();
//query SELECT * FROM TESTSEARCH where getKey>16 AND getKey<23 q = db.query(); q.constrain(TestSearchData.class); subq = q.descend("getKey()"); Constraint c = subq.constrain(new Integer(16)).greater(); Constraint d = subq.constrain(new Integer(23)).smaller(); c.and(d); set = q.execute();
//query SELECT * FROM TESTSEARCH where getKey>16 AND getDizaine=2 q = db.query(); q.constrain(TestSearchData.class); subq = q.descend("getKey()"); c = subq.constrain(new Integer(16)).greater(); Query subq2 = subq.descend("getDizaine()"); d = subq2.constrain(new Integer(2)).equal(); c.and(d); set = q.execute();
Definition at line 117 of file FODBSodaQuery.java.
Public Member Functions | |
FODBSodaQuery (CollectionManager colManager, FastObjectDB db) | |
Constraint | constrain (Object constraint) |
adds a constraint to this node. | |
Constraints | constraints () |
returns a Constraints object that holds an array of all constraints on this node. | |
ObjectSet | execute () |
executes the Query. | |
Query | descend (String fieldName) |
returns a reference to a descendant node in the query graph. | |
Query | orderAscending () |
adds an ascending ordering criteria to this node of the query graph. | |
Query | orderDescending () |
adds a descending order criteria to this node of the query graph. | |
Package Functions | |
Constraint | or (Constraint with) |
void | setCollection (FODBCollection collection) |
void | setFirstConstraint (FODBSodaConstraint constraint) |
FODBSodaConstraint | getFirstConstraint () |
|
adds a constraint to this node.
Implements org.odbms.Query. Definition at line 137 of file FODBSodaQuery.java. References org.openmobileis.database.fastobjectdb.db.CollectionManager.getCollectionByName(), org.openmobileis.database.fastobjectdb.db.CollectionManager.getCollectionByType(), org.openmobileis.database.fastobjectdb.db.FODBCollection.getIndexByMember(), org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaConstraint.getIndexMember(), org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaConstraint.hasOperande, org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaConstraint.setIndex(), and org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaConstraint.setOperand(). |
|
returns a Constraints object that holds an array of all constraints on this node.
Implements org.odbms.Query. Definition at line 175 of file FODBSodaQuery.java. |
|
|
executes the Query.
Implements org.odbms.Query. Definition at line 182 of file FODBSodaQuery.java. References org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaObjectSet.addCollectionPtrs(), org.openmobileis.database.fastobjectdb.db.transaction.TransactionManager.begin(), org.openmobileis.database.fastobjectdb.db.transaction.TransactionManager.commit(), org.openmobileis.database.fastobjectdb.db.transaction.TransactionManager.enterTransaction(), org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaConstraint.execute(), org.openmobileis.database.fastobjectdb.db.FODBCollection.getName(), org.openmobileis.database.fastobjectdb.FastObjectDB.getTransactionManager(), and org.openmobileis.common.util.collection.LongArray.toArray(). |
|
adds an ascending ordering criteria to this node of the query graph. Multiple ordering criteria will be applied in the order they were called.
Implements org.odbms.Query. Definition at line 240 of file FODBSodaQuery.java. |
|
adds a descending order criteria to this node of the query graph. Multiple ordering criteria will be applied in the order they were called.
Implements org.odbms.Query. Definition at line 248 of file FODBSodaQuery.java. |
|
Definition at line 264 of file FODBSodaQuery.java. Referenced by org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.descend(). |
|
Definition at line 271 of file FODBSodaQuery.java. Referenced by org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.descend(). |