Package com.mobixess.jodb.soda.api

Examples of com.mobixess.jodb.soda.api.Query


            sessionContainer = getContainerForFile(testFile);
        }
       
       
       
        Query query = sessionContainer.query();
        query.constrain(ObjectA.class);
        if(ascending){
            query.descend("_val2").orderAscending();
        }else{
            query.descend("_val2").orderDescending();
        }
       
        JODBQueryList list = (JODBQueryList) query.execute();
        if(list.size() != maxObjects){
            throw new RuntimeException();
        }
       
        ObjectA prev = null;
        for (int i = 0; i < list.size(); i++) {
            ObjectA current = (ObjectA) list.get(i);
            //System.err.println("Indexing Random test iter #="+i);
            if(prev!=null){
                if(ascending){
                    if( prev.getVal2() > current.getVal2() ){
                        throw new RuntimeException();
                    }
                }else if(prev.getVal2() < current.getVal2() ){
                    JODBIndexingAgent indexingAgent = sessionContainer.getIndexingAgent(ObjectA.class.getDeclaredField("_val2") );
                    long prevID = sessionContainer.getPersistenceStatistics(prev).getObjectID();
                    long currentID = sessionContainer.getPersistenceStatistics(current).getObjectID();
                    int prevPosition = indexingAgent.linearIdSearch(prevID);
                    int currentPosition = indexingAgent.linearIdSearch(currentID);
                    throw new RuntimeException(""+prevID+"  "+prevPosition+"  "+ currentID+"  "+currentPosition);
                }
            }
            prev = current;
        }
       
       
        //System.err.println("_________________________________________________________");
        //sessionContainer.printFileMap();
       
        list = sessionContainer.getAllObjects();
       
        int total = list.size();
        for (int i = 0; i < total; i++) {
            ObjectA nextObj = (ObjectA) list.get(i);
            nextObj.setVal2((short) i);
            sessionContainer.set(nextObj);
        }
       
        sessionContainer.commit();
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
       
        query = sessionContainer.query();
        query.constrain(ObjectA.class);
        if(ascending){
            query.descend("_val2").orderAscending();
        }else{
            query.descend("_val2").orderDescending();
        }
       
        list = (JODBQueryList) query.execute();
        if(list.size() == 0){
            throw new RuntimeException();
        }
       
        prev = null;
View Full Code Here


       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
        Query query = sessionContainer.query();
        query.constrain(ObjectA.class);
        if(ascending){
            query.descend("_val1").orderAscending();
        }else{
            query.descend("_val1").orderDescending();
        }
        if(ascending){
            query.descend("_val2").orderAscending();
        }else{
            query.descend("_val2").orderDescending();
        }
        JODBConfig.setCacheOnSortOperations(false);
        List list = query.execute();
        if(list.size() == 0){
            throw new RuntimeException();
        }
       
        ObjectA prev = null;
        for (int i = 0; i < list.size(); i++) {
            ObjectA current = (ObjectA) list.get(i);
            if(prev!=null){
                if(ascending){
                    if( prev.getVal2() > current.getVal2() ){
                        throw new RuntimeException();
                    }
                }else if(prev.getVal2() < current.getVal2() ){
                    throw new RuntimeException();
                }
            }
            prev = current;
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        query.constrain(ObjectA.class);
        if(ascending){
            query.descend("_val2").orderAscending();
        }else{
            query.descend("_val2").orderDescending();
        }
       
        JODBConfig.setCacheOnSortOperations(true);
        list = query.execute();
        if(list.size() == 0){
            throw new RuntimeException();
        }
       
        prev = null;
View Full Code Here

        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        Query query = sessionContainer.query();
        query.constrain(ObjectA.class);

        query.descend("_val2").constrain(0).smaller();
       
       
        long queryStart = System.currentTimeMillis();
        JODBQueryList list = (JODBQueryList) query.execute();
        long noneIndexQuery = System.currentTimeMillis() - queryStart;
        System.err.println("noneIndexQuery="+noneIndexQuery);
       
        if(list.size() != negatives){
            throw new RuntimeException();
        }
       
        sessionContainer.configureIndex(ObjectA.class, "_val2", true);
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
       
        query = sessionContainer.query();
        query.constrain(ObjectA.class);

        query.descend("_val2").constrain(0).smaller();
       
        queryStart = System.currentTimeMillis();
        list = (JODBQueryList) query.execute();
        long queryWithIndex = System.currentTimeMillis() - queryStart;
        System.err.println("queryWithIndex="+queryWithIndex);
       
        if(list.size() != negatives){
            throw new RuntimeException();
View Full Code Here

        if (reopen) {
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
//        List classes = sessionContainer.getAllObjects();
        Query query = sessionContainer.query();
        query.constrain(initialObject.getClass());
        List classes = query.execute();
        if (classes.size() != 1) {
            throw new RuntimeException();
        }
        Object obj = classes.get(0);
        if(obj.getClass() != initialObject.getClass()){
View Full Code Here

        if(closeAfterCommit){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        Query query = sessionContainer.query();
       
        query.constrain(innerClassObject.getInnerClass().getClass());
       
        List list = query.execute();
       
        if(list.size()!=1 || list.get(0).getClass() != innerClassObject.getInnerClass().getClass()){
            throw new RuntimeException(" +++"+list.size());
        }
       
View Full Code Here

    public <T> ObjectSet<T> get(Object template) throws IOException, IllegalClassTypeException {
        if(template == null){
            return _session.getAllObjects();
        }else{
            Query query = query();
            query.constrain(template);
            return query.execute();
        }
    }
View Full Code Here

    public Query query() {
        return new QueryNode("",_session, null);
    }

    public <Type> ObjectSet<Type> query(Class<Type> clazz) throws IOException, IllegalClassTypeException {
        Query query = query();
        query.constrain(clazz);
        return query.execute();
    }
View Full Code Here

            enableIndex(objectContainer);
        }
        fillTestData(objectContainer);
        benchmarkResults._refillTime = System.currentTimeMillis() - startTime;
        //form query for all elements
        Query query = objectContainer.query();
        query.constrain(BenchmarkObject.class);
        query.descend("_val1").constrain(Integer.MIN_VALUE).greater();
        query.descend("_val1").constrain(Integer.MAX_VALUE).smaller();
        if(sort){
            benchmarkResults._sorted = true;
            query.descend("_val1").orderAscending();
        }
       
        startTime = System.currentTimeMillis();
        ObjectSet objectSet = query.execute();
        benchmarkResults._queryTime = System.currentTimeMillis() - startTime;
       
        startTime = System.currentTimeMillis();
        int total = objectSet.size();
        if(total < MAX_OBJECTS){
View Full Code Here

TOP

Related Classes of com.mobixess.jodb.soda.api.Query

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.