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 () |
Constraint org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.constrain | ( | Object | constraint | ) |
adds a constraint to this node.
If the constraint contains attributes that are not yet present in the query graph, the query graph is extended accordingly.
Special behaviour for:
constraint | the constraint to be added to this Query. |
null
for objects implementing the Evaluation interface. 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().
Constraints org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.constraints | ( | ) |
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.
ObjectSet org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.execute | ( | ) |
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().
Query org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.descend | ( | String | fieldName | ) |
returns a reference to a descendant node in the query graph.
If the node does not exist, it will be created.
All classes represented in the query node are tested, whether they contain a field with the specified field name. The descendant Query node will be created from all possible candidate classes.
field | path to the descendant. |
Implements org.odbms.Query.
Definition at line 205 of file FODBSodaQuery.java.
References org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.FODBSodaQuery(), org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.getFirstConstraint(), org.openmobileis.database.fastobjectdb.db.FODBCollection.getIndexByMember(), org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaConstraint.hasIndex(), org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.setCollection(), org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.setError(), org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.setFirstConstraint(), and org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaConstraint.setIndex().
Query org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.orderAscending | ( | ) |
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.
Query org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.orderDescending | ( | ) |
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.