Package org.exist.storage.btree

Examples of org.exist.storage.btree.IndexQuery


            String start, String end) throws PermissionDeniedException {
        final IndexScanCallback cb = new IndexScanCallback(docs, contextSet, false);
        final Lock lock = dbTokens.getLock();
        for (final Iterator<Collection> i = docs.getCollectionIterator(); i.hasNext();) {
            final int collectionId = (i.next()).getId();
            final IndexQuery query;
            if (start == null) {
                final Value startRef = new WordRef(collectionId);
                query = new IndexQuery(IndexQuery.TRUNC_RIGHT, startRef);
            } else if (end == null) {
                final Value startRef = new WordRef(collectionId, start.toLowerCase());
                query = new IndexQuery(IndexQuery.TRUNC_RIGHT, startRef);
            } else {
                final Value startRef = new WordRef(collectionId,  start.toLowerCase());
                final Value endRef = new WordRef(collectionId, end.toLowerCase());
                query = new IndexQuery(IndexQuery.BW, startRef, endRef);
            }
            try {
                lock.acquire(Lock.READ_LOCK);
                dbTokens.query(query, cb);
            } catch (final LockException e) {
View Full Code Here


        final Lock lock = dbTokens.getLock();
        final IndexScanCallback cb = new IndexScanCallback(docs, contextSet, true);
        for (int q = 0; q < qnames.length; q++) {
            for (final Iterator<Collection> i = docs.getCollectionIterator(); i.hasNext();) {
                final int collectionId = (i.next()).getId();
                final IndexQuery query;
                if (start == null) {
                    final Value startRef = new QNameWordRef(collectionId, qnames[q],
                        broker.getBrokerPool().getSymbols());
                    query = new IndexQuery(IndexQuery.TRUNC_RIGHT, startRef);
                } else if (end == null) {
                    final Value startRef = new QNameWordRef(collectionId, qnames[q],
                        start.toLowerCase(), broker.getBrokerPool().getSymbols());
                    query = new IndexQuery(IndexQuery.TRUNC_RIGHT, startRef);
                } else {
                    final Value startRef = new QNameWordRef(collectionId, qnames[q], start.toLowerCase(),
                        broker.getBrokerPool().getSymbols());
                    final Value endRef = new QNameWordRef(collectionId, qnames[q], end.toLowerCase(),
                        broker.getBrokerPool().getSymbols());
                    query = new IndexQuery(IndexQuery.BW, startRef, endRef);
                }
                try {
                    lock.acquire(Lock.READ_LOCK);
                    dbTokens.query(query, cb);
                } catch (final LockException e) {
View Full Code Here

        final Lock lock = index.btree.getLock();
        try {
            lock.acquire(Lock.READ_LOCK);
            byte[] fromKey = computeKey(id);
            byte[] toKey = computeKey((short) (id + 1));
            final IndexQuery query = new IndexQuery(IndexQuery.RANGE, new Value(fromKey), new Value(toKey));
            index.btree.remove(query, null);

            removeId(name);
        } catch (BTreeException e) {
            throw new EXistException("Exception caught while deleting sort index: " + e.getMessage(), e);
View Full Code Here

        final Lock lock = index.btree.getLock();
        try {
            lock.acquire(Lock.READ_LOCK);
            byte[] fromKey = computeKey(id, doc.getDocId());
            byte[] toKey = computeKey(id, doc.getDocId() + 1);
            final IndexQuery query = new IndexQuery(IndexQuery.RANGE, new Value(fromKey), new Value(toKey));
            index.btree.remove(query, null);
        } catch (BTreeException e) {
            throw new EXistException("Exception caught while deleting sort index: " + e.getMessage(), e);
        } catch (IOException e) {
            throw new EXistException("Exception caught while deleting sort index: " + e.getMessage(), e);
View Full Code Here

        byte[] endKey = new byte[] { 2 };

        final Lock lock = index.btree.getLock();
        try {
            lock.acquire(Lock.READ_LOCK);
            IndexQuery query = new IndexQuery(IndexQuery.RANGE, new Value(fromKey), new Value(endKey));
            FindIdCallback callback = new FindIdCallback(true);
            index.btree.query(query, callback);

            for (long id : callback.allIds) {
                remove(doc, (short) id);
View Full Code Here

    private short getOrRegisterId(String name) throws EXistException, LockException {
        short id = getId(name);
        if (id < 0) {
            byte[] fromKey = { 1 };
            byte[] endKey = { 2 };
            IndexQuery query = new IndexQuery(IndexQuery.RANGE, new Value(fromKey), new Value(endKey));
            final Lock lock = index.btree.getLock();
            try {
                lock.acquire(Lock.READ_LOCK);
                FindIdCallback callback = new FindIdCallback(false);
                index.btree.query(query, callback);
View Full Code Here

            domDb.closeDocument();
           
            // remove all
            NativeBroker.NodeRef ref = new NativeBroker.NodeRef(500);
            assertNotNull(ref);
            IndexQuery idx = new IndexQuery(IndexQuery.TRUNC_RIGHT, ref);
            assertNotNull(idx);
            domDb.remove(txn, idx, null);
            domDb.removeAll(txn, firstToRemove);
           
            // put some more
            for (int i = 1; i <= 10000; i++) {
                byte[] data = ("Value" + i).getBytes();
                @SuppressWarnings("unused")
        long addr = domDb.put(txn, new NativeBroker.NodeRef(500, idFact.createInstance(i)), data);
//              TODO : test addr ?
            }
           
            domDb.closeDocument();
            mgr.commit(txn);
            System.out.println("Transaction commited ...");
           
            txn = mgr.beginTransaction();
            System.out.println("Transaction started ...");
           
            // put 1000 new values into the btree
            for (int i = 1; i <= 1000; i++) {
                byte[] data = ("Value" + i).getBytes();
                long addr = domDb.put(txn, new NativeBroker.NodeRef(501, idFact.createInstance(i)), data);
//              TODO : test addr ?               
                if (i == 1)
                    firstToRemove = addr;
            }           
           
            domDb.closeDocument();
            mgr.commit(txn);
            System.out.println("Transaction commited ...");
           
            // the following transaction is not committed and will be rolled back during recovery
            txn = mgr.beginTransaction();
            System.out.println("Transaction started ...");
           
            for (int i = 1; i <= 200; i++) {
                domDb.remove(txn, new NativeBroker.NodeRef(500, idFact.createInstance(i)));
            }

            idx = new IndexQuery(IndexQuery.TRUNC_RIGHT, new NativeBroker.NodeRef(501));
            domDb.remove(txn, idx, null);
            domDb.removeAll(txn, firstToRemove);
           
//          Don't commit...
            mgr.commit(txn);
View Full Code Here

           
            DOMFile domDb = ((NativeBroker) broker).getDOMFile();
            assertNotNull(domDb);
            domDb.setOwnerObject(this);
           
            IndexQuery query = new IndexQuery(IndexQuery.GT, new NativeBroker.NodeRef(500));
            assertNotNull(query);
            List<?> keys = domDb.findKeys(query);
            assertNotNull(keys);
            int count = 0;
            for (Iterator<?> i = keys.iterator(); i.hasNext(); count++) {
View Full Code Here

            for (int i = 1; i < 1001; i++) {
              id = idFact.createInstance(i);
                domDb.addValue(txn, new NativeBroker.NodeRef(500, id), i);
            }
           
            IndexQuery idx = new IndexQuery(IndexQuery.GT, new NativeBroker.NodeRef(500, idFact.createInstance(800)));
            domDb.remove(txn, idx, null);
           
            mgr.commit(txn);
           
            // start a dirty, uncommitted transaction. This will be rolled back by the recovery.
            txn = mgr.beginTransaction();
           
            for (int i = 801; i < 2001; i++) {
                domDb.addValue(txn, new NativeBroker.NodeRef(500, idFact.createInstance(i)), i);
            }
           
            for (int i = 101; i < 301; i++) {
                domDb.addValue(txn, new NativeBroker.NodeRef(500, idFact.createInstance(i)), i * 3);
            }
           
            idx = new IndexQuery(IndexQuery.GT, new NativeBroker.NodeRef(500, idFact.createInstance(600)));
            domDb.remove(txn, idx, null);
           
            mgr.getJournal().flushToLog(true);
           
            Writer writer = new StringWriter();
View Full Code Here

            broker = pool.get(pool.getSecurityManager().getSystemSubject());
           
            DOMFile domDb = ((NativeBroker) broker).getDOMFile();
            domDb.setOwnerObject(this);
           
            IndexQuery query = new IndexQuery(IndexQuery.GEQ, new NativeBroker.NodeRef(500, idFact.createInstance(1)));
            domDb.query(query, new IndexCallback());
            System.out.println("Found: " + count);
            assertEquals(count, 800);
           
            Writer writer = new StringWriter();
View Full Code Here

TOP

Related Classes of org.exist.storage.btree.IndexQuery

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.