Package org.exist.storage.btree

Examples of org.exist.storage.btree.IndexQuery


        final Lock lock = index.db.getLock();
        try {
            lock.acquire(Lock.WRITE_LOCK);
            // remove generic index
            Value value = new NGramQNameKey(collection.getId());
            index.db.removeAll(null, new IndexQuery(IndexQuery.TRUNC_RIGHT, value));
        } catch (LockException e) {
            LOG.warn("Failed to acquire lock for '" + index.db.getFile().getName() + "'", e);
        } catch (BTreeException e) {
            LOG.error(e.getMessage(), e);
        } catch (IOException e) {
View Full Code Here


                final Lock lock = index.db.getLock();
                try {
                    lock.acquire(Lock.READ_LOCK);
                    SearchCallback cb = new SearchCallback(contextId, query, ngram, docs, contextSet, context, result, axis == NodeSet.ANCESTOR);
                    int op = query.codePointCount(0, query.length()) < getN() ? IndexQuery.TRUNC_RIGHT : IndexQuery.EQ;
                    index.db.query(new IndexQuery(op, key), cb);
                } catch (LockException e) {
                    LOG.warn("Failed to acquire lock for '" + index.db.getFile().getName() + "'", e);
                } catch (IOException e) {
                    LOG.error(e.getMessage() + " in '" + index.db.getFile().getName() + "'", e);
                } catch (BTreeException e) {
View Full Code Here

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

        }
        return wp;
    }

    public ArrayList<Value> getEntries() throws IOException, BTreeException, TerminatedException {
        final IndexQuery query = new IndexQuery(IndexQuery.ANY, "");
        final FindCallback cb = new FindCallback(FindCallback.BOTH);
        query(query, cb);
        return cb.getValues();
    }
View Full Code Here

        query(query, cb);
        return cb.getValues();
    }

    public ArrayList<Value> getKeys() throws IOException, BTreeException, TerminatedException {
        final IndexQuery query = new IndexQuery(IndexQuery.ANY, "");
        final FindCallback cb = new FindCallback(FindCallback.KEYS);
        query(query, cb);
        return cb.getValues();
    }
View Full Code Here

        query(query, cb);
        return cb.getValues();
    }

    public ArrayList<Value> getValues() throws IOException, BTreeException, TerminatedException {
        final IndexQuery query = new IndexQuery(IndexQuery.ANY, "");
        final FindCallback cb = new FindCallback(FindCallback.VALUES);
        query(query, cb);
        return cb.getValues();
    }
View Full Code Here

            lock.acquire( Lock.WRITE_LOCK );

            //TODO : flush ? -pb
            // remove generic index
            Value ref = new SimpleValue( collection.getId() );
            dbValues.removeAll( null, new IndexQuery( IndexQuery.TRUNC_RIGHT, ref ) );

            // remove QName index
            ref = new QNameValue( collection.getId() );
            dbValues.removeAll( null, new IndexQuery( IndexQuery.TRUNC_RIGHT, ref ) );
        }
        catch( final LockException e ) {
            LOG.warn( "Failed to acquire lock for '" + dbValues.getFile().getName() + "'", e );
        }
        catch( final BTreeException e ) {
View Full Code Here

                try {
                    lock.acquire( Lock.READ_LOCK );
                    searchKey = new SimpleValue( collectionId, value );
                    prefixKey = new SimplePrefixValue( collectionId, value.getType() );
                    final IndexQuery query = new IndexQuery( idxOp, searchKey );

                    if( idxOp == IndexQuery.EQ ) {
                        dbValues.query( query, cb );
                    } else {
                        dbValues.query( query, prefixKey, cb );
                    }
                }
                catch( final EXistException e ) {
                    LOG.error( e.getMessage(), e );
                }
                catch( final LockException e ) {
                    LOG.warn( "Failed to acquire lock for '" + dbValues.getFile().getName() + "'", e );
                }
                catch( final IOException e ) {
                    LOG.error( e.getMessage(), e );
                }
                catch( final BTreeException e ) {
                    LOG.error( e.getMessage(), e );
                }
                finally {
                    lock.release( Lock.READ_LOCK );
                }
            } else {

                for( int i = 0; i < qnames.size(); i++ ) {
                    final QName qname = ( QName )qnames.get( i );

                    try {
                        lock.acquire( Lock.READ_LOCK );

                        //Compute a key for the value in the collection
                        searchKey = new QNameValue( collectionId, qname, value, broker.getBrokerPool().getSymbols() );
                        prefixKey = new QNamePrefixValue( collectionId, qname, value.getType(), broker.getBrokerPool().getSymbols() );

                        final IndexQuery query = new IndexQuery( idxOp, searchKey );

                        if( idxOp == IndexQuery.EQ ) {
                            dbValues.query( query, cb );
                        } else {
                            dbValues.query( query, prefixKey, cb );
View Full Code Here

                    } else {

                        //Compute a key for an arbitrary string in the collection
                        searchKey = new SimplePrefixValue( collectionId, Type.STRING );
                    }
                    final IndexQuery query = new IndexQuery( IndexQuery.TRUNC_RIGHT, searchKey );
                    dbValues.query( query, cb );
                }
                catch( final LockException e ) {
                    LOG.warn( "Failed to acquire lock for '" + dbValues.getFile().getName() + "'", e );
                }
                catch( final IOException e ) {
                    LOG.error( e.getMessage(), e );
                }
                catch( final BTreeException e ) {
                    LOG.error( e.getMessage(), e );
                }
                finally {
                    lock.release( Lock.READ_LOCK );
                }
            } else {

                for( int i = 0; i < qnames.size(); i++ ) {
                    final QName qname = ( QName )qnames.get( i );

                    try {
                        lock.acquire( Lock.READ_LOCK );

                        if( startTerm != null ) {
                            searchKey = new QNameValue( collectionId, qname, startTerm, broker.getBrokerPool().getSymbols() );
                        } else {
                            LOG.debug( "Searching with QName prefix" );
                            searchKey = new QNamePrefixValue( collectionId, qname, Type.STRING, broker.getBrokerPool().getSymbols() );
                        }
                        final IndexQuery query = new IndexQuery( IndexQuery.TRUNC_RIGHT, searchKey );
                        dbValues.query( query, cb );
                    }
                    catch( final LockException e ) {
                        LOG.warn( "Failed to acquire lock for '" + dbValues.getFile().getName() + "'", e );
                    }
View Full Code Here

                final int        collectionId = c.getId();

                //Compute a key for the start value in the collection
                if( stringType ) {
                    final Value startKey = new SimpleValue( collectionId, start );
                    final IndexQuery  query    = new IndexQuery( IndexQuery.TRUNC_RIGHT, startKey );
                    dbValues.query( query, cb );
                } else {
                    final Value      startKey  = new SimpleValue( collectionId, start );
                    final Value      prefixKey = new SimplePrefixValue( collectionId, start.getType() );
                    final IndexQuery query     = new IndexQuery( IndexQuery.GEQ, startKey );
                    dbValues.query( query, prefixKey, cb );
                }
            }
            catch( final EXistException e ) {
                LOG.error( e.getMessage(), e );
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.