Package org.modeshape.jcr.api.query

Examples of org.modeshape.jcr.api.query.Query


        Node newNode = session.getRootNode().addNode("SOMENODE", typeName);
        newNode.setProperty("sysName", "X");

        // BEFORE SAVING, issue a query that will NOT use the index. The query should not see the transient node ...
        String queryStr = "select BASE.* FROM [" + typeName + "] as BASE WHERE NAME(BASE) = 'SOMENODE'";
        Query query = jcrSql2Query(queryStr);
        validateQuery().rowCount(0L).useNoIndexes().validate(query, query.execute());

        // Now issue a query that will use the index. The query should not see the transient node...
        queryStr = "select BASE.* FROM [" + typeName + "] as BASE WHERE BASE.sysName='X'";
        query = jcrSql2Query(queryStr);
        validateQuery().rowCount(0L).useIndex("ntsome2sysname").validate(query, query.execute());

        // Save the transient data ...
        session.save();

        waitForIndexes();

        // Issue a query that will NOT use the index ...
        queryStr = "select BASE.* FROM [" + typeName + "] as BASE WHERE NAME(BASE) = 'SOMENODE'";
        query = jcrSql2Query(queryStr);
        validateQuery().rowCount(1L).useNoIndexes().validate(query, query.execute());

        // Now issue a query that will use the index.
        queryStr = "select BASE.* FROM [" + typeName + "] as BASE WHERE BASE.sysName='X'";
        query = jcrSql2Query(queryStr);
        validateQuery().rowCount(1L).useIndex("ntsome2sysname").validate(query, query.execute());

        registerValueIndex("ntusysname", "nt:unstructured", null, "*", "sysName", PropertyType.STRING);

        waitForIndexes();

        Node newNode2 = session.getRootNode().addNode("SOMENODE2", "nt:unstructured");
        newNode2.setProperty("sysName", "X");
        session.save();

        waitForIndexes();

        // print = true;

        queryStr = "select BASE.* FROM [nt:unstructured] as BASE WHERE BASE.sysName='X'";
        query = jcrSql2Query(queryStr);
        validateQuery().rowCount(2L).validate(query, query.execute());
    }
View Full Code Here


        session.save();
        waitForIndexes();

        for (int i = 0; i != 5; ++i) {
            // Compute a query plan that should use this index ...
            Query query = jcrSql2Query("SELECT * FROM [mix:title]");
            for (int j = 0; j != 5; ++j) {
                validateQuery().rowCount(2L).useIndex("titleNodes").validate(query, query.execute());
            }
        }

        final int numThreads = 10;
        final int numQueriesEachThread = 100;
        final int numIndexes = 4;
        final CountDownLatch startLatch = new CountDownLatch(1);
        final CountDownLatch stopLatch = new CountDownLatch(numThreads);
        final Runnable queryRunner = new Runnable() {

            @Override
            public void run() {
                JcrSession session = null;
                try {
                    session = repository().login();
                    Query query = jcrSql2Query(session, "SELECT * FROM [mix:title]");
                    startLatch.await();
                    for (int i = 0; i != numQueriesEachThread; ++i) {
                        // Compute a query plan that should use this index, UNLESS the index is currently undergoing rebuilding...
                        validateQuery()./*rowCount(2L).useIndex("titleNodes")*/validate(query, query.execute());
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    fail(e.getMessage());
                } finally {
View Full Code Here

        // print = true;

        // Compute a query plan that should use this index ...
        final String uuid = nodeA.getIdentifier();
        Query query = jcrSql2Query("SELECT [jcr:path] FROM [nt:unstructured] WHERE [jcr:uuid] = '" + uuid + "'");
        validateQuery()
                .rowCount(1L)
                .considerIndexes(IndexPlanners.NODE_BY_ID_INDEX_NAME, explicitNodesById)
                .useIndex(IndexPlanners.NODE_BY_ID_INDEX_NAME)
                .validate(query, query.execute());

        query = jcrSql2Query("SELECT [jcr:path] FROM [nt:unstructured] WHERE [jcr:path] = '/nodeA'");
        validateQuery()
                .rowCount(1L)
                .considerIndexes(IndexPlanners.NODE_BY_PATH_INDEX_NAME, explicitNodesByPath)
                .useIndex(IndexPlanners.NODE_BY_PATH_INDEX_NAME)
                .validate(query, query.execute());

    }
View Full Code Here

        session().save();

        // print = true;

        // Compute a query plan that should use this index ...
        Query query = jcrSql2Query("SELECT [jcr:path] FROM [nt:unstructured] AS node WHERE ISDESCENDANTNODE(node, '/nodeA') AND node.[foo]='X'");
        validateQuery()
                .rowCount(1L)
                .considerIndexes(IndexPlanners.DESCENDANTS_BY_PATH_INDEX_NAME, explicitIndex)
                .useIndex(explicitIndex)
                .validate(query, query.execute());
    }
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.api.query.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.