Package org.exist.storage.btree

Examples of org.exist.storage.btree.Value


            long pos;
            short tid;
            DataPage page;
            int offset;
            int l;
            Value v;
            byte[] data;
            try {
                switch (mode) {
                    case VALUES:
                        pos = StorageAddress.pageFromPointer(pointer);
                        tid = StorageAddress.tidFromPointer(pointer);
                        page = getDataPage(pos);
                        dataCache.add(page.getFirstPage());
                        offset = page.findValuePosition(tid);
                        data = page.getData();
                        l = ByteConversion.byteToInt(data, offset);
                        v = new Value(data, offset + 4, l);
                        v.setAddress(pointer);
                        if (callback == null)
                            {values.add(v);}
                        else
                            {return callback.indexInfo(value, v);}
                        return true;
                    case KEYS:
                        value.setAddress(pointer);
                        if (callback == null)
                            {values.add(value);}
                        else
                            {return callback.indexInfo(value, null);}
                        return true;
                    case BOTH:
                        final Value[] entry = new Value[2];
                        entry[0] = value;
                        pos = StorageAddress.pageFromPointer(pointer);
                        tid = StorageAddress.tidFromPointer(pointer);
                        page = getDataPage(pos);
                        if (page.getPageHeader().getStatus() == MULTI_PAGE) {
                            data = page.getData();
                        }
                        dataCache.add(page.getFirstPage());
                        offset = page.findValuePosition(tid);
                        data = page.getData();
                        l = ByteConversion.byteToInt(data, offset);
                        v = new Value(data, offset + 4, l);
                        v.setAddress(pointer);
                        entry[1] = v;
                        if (callback == null) {
                            values.add(entry[0]);
                            values.add(entry[1]);
                        } else
View Full Code Here


        }

        @Override
        public void write() throws IOException {
            //LOG.debug(getFile().getName() + " writing page " + getPageNum());
            writeValue(page, new Value(data));
            setDirty(false);
        }
View Full Code Here

            final byte[] b1 = ValueIndexFactory.serialize(dtv, 0);
            print(dtv, b1);
            final DateTimeValue dtv2 = new DateTimeValue("1960-03-19T19:03:59.782+01:00");
            final byte[] b2 = ValueIndexFactory.serialize(dtv2, 0);
            print(dtv2, b2);
            System.out.println(new Value(b1).compareTo(new Value(b2)));
            final DateTimeValue dtv2_ = (DateTimeValue) ValueIndexFactory.deserialize(b2, 0, b2.length);
            if (!dtv2.equals(dtv2_))
                {System.out.println("ERROR! "+dtv2.toString()+" ne "+dtv2_.toString());}
            //******** DateValue ********
            final DateValue dv = new DateValue("1960-03-19Z");
            final byte[] b3 = ValueIndexFactory.serialize(dv, 0);
            print(dv, b3);
            final DateValue dv_ = (DateValue) ValueIndexFactory.deserialize(b3, 0, b3.length);
            if (!dv.equals(dv_))
                {System.out.println("ERROR! "+dv.toString()+" ne "+dv_.toString());}
            //******** IntegerValue ********
            final IntegerValue iv = new IntegerValue(753);
            final byte[] i1 = ValueIndexFactory.serialize(iv, 0);
            print(iv, i1);
            final IntegerValue iv2 = new IntegerValue(1960);
            final byte[] i2 = ValueIndexFactory.serialize(iv2, 0);
            print(iv2, i2);
            System.out.println(new Value(i1).compareTo(new Value(i2)));
        } catch (final Exception e) {
            e.printStackTrace();
        }
    }
View Full Code Here

                //Write (variable) length of node IDs
                os.writeFixedInt( nodeIDsLength, os.position() - nodeIDsLength - LENGTH_NODE_IDS );

                try {
                    lock.acquire( Lock.WRITE_LOCK );
                    Value v;

                    if( section == IDX_GENERIC ) {
                        v = new SimpleValue( collectionId, ( Indexable )key );
                    } else {
                        final QNameKey qnk = ( QNameKey )key;
View Full Code Here

                try {
                    lock.acquire( Lock.WRITE_LOCK );

                    //Compute a key for the value
                    Value searchKey;

                    if( section == IDX_GENERIC ) {
                        searchKey = new SimpleValue( collectionId, ( Indexable )key );
                    } else {
                        final QNameKey qnk = ( QNameKey )key;
                        searchKey = new QNameValue( collectionId, qnk.qname, qnk.value, broker.getBrokerPool().getSymbols() );
                    }
                    final Value value = dbValues.get( searchKey );

                    //Does the value already has data in the index ?
                    if( value != null ) {

                        //Add its data to the new list
                        final VariableByteArrayInput is = new VariableByteArrayInput( value.getData() );

                        while( is.available() > 0 ) {
                            final int storedDocId = is.readInt();
                            final int gidsCount   = is.readInt();
                            final int size        = is.readFixedInt();

                            if( storedDocId != this.doc.getDocId() ) {

                                // data are related to another document:
                                // append them to any existing data
                                os.writeInt( storedDocId );
                                os.writeInt( gidsCount );
                                os.writeFixedInt( size );
                                is.copyRaw( os, size );
                            } else {

                                // data are related to our document:
                                // feed the new list with the GIDs
                                NodeId previous = null;

                                for( int j = 0; j < gidsCount; j++ ) {
                                    NodeId nodeId = broker.getBrokerPool().getNodeFactory().createFromStream( previous, is );
                                    previous = nodeId;

                                    // add the node to the new list if it is not
                                    // in the list of removed nodes
                                    if( !containsNode( storedGIDList, nodeId ) ) {
                                        newGIDList.add( nodeId );
                                    }
                                }
                            }
                        }

                        //append the data from the new list
                        if( newGIDList.size() > 0 ) {
                            final int gidsCount = newGIDList.size();

                            //Don't forget this one
                            FastQSort.sort( newGIDList, 0, gidsCount - 1 );
                            os.writeInt( this.doc.getDocId() );
                            os.writeInt( gidsCount );

                            //Mark position
                            final int nodeIDsLength = os.position();

                            //Dummy value : actual one will be written below
                            os.writeFixedInt( 0 );
                            NodeId previous = null;

                            for( final NodeId nodeId : newGIDList ) {
                                try {
                                    previous = nodeId.write( previous, os );
                                }
                                catch( final IOException e ) {
                                    LOG.warn( "IO error while writing range index: " + e.getMessage(), e );
                                    //TODO : throw exception ?
                                }
                            }

                            //Write (variable) length of node IDs
                            os.writeFixedInt( nodeIDsLength, os.position() - nodeIDsLength - LENGTH_NODE_IDS );
                        }

//                        if(os.data().size() == 0)
//                            dbValues.remove(value);
                        if( dbValues.update( value.getAddress(), searchKey, os.data() ) == BFile.UNKNOWN_ADDRESS ) {
                            LOG.error( "Could not update index data for value '" + searchKey + "'" );
                            //TODO: throw exception ?
                        }
                    } else {
View Full Code Here

        try {
            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 ) );
View Full Code Here

                for( final Map.Entry<Object, List<NodeId>> entry : pending[section].entrySet() ) {
                    final Object    key   = entry.getKey();

                    //Compute a key for the indexed value in the collection
                    Value     v;

                    if( section == IDX_GENERIC ) {
                        v = new SimpleValue( collectionId, ( Indexable )key );
                    } else {
                        final QNameKey qnk = ( QNameKey )key;
                        v = new QNameValue( collectionId, qnk.qname, qnk.value, broker.getBrokerPool().getSymbols() );
                    }
                    final Value value = dbValues.get( v );

                    if( value == null ) {
                        continue;
                    }
                    final VariableByteArrayInput is      = new VariableByteArrayInput( value.getData() );
                    boolean                changed = false;
                    os.clear();

                    while( is.available() > 0 ) {
                        final int storedDocId = is.readInt();
View Full Code Here

        final Lock           lock = dbValues.getLock();

        for( final Iterator<Collection> iter = docs.getCollectionIterator(); iter.hasNext(); ) {
            final int collectionId = iter.next().getId();
            final int idxOp        = checkRelationOp( relation );
            Value     searchKey;
            Value     prefixKey;

            watchDog.proceed(null);

            if( qnames == null ) {
View Full Code Here

        final MatcherCallback cb   = new MatcherCallback( docs, contextSet, result, matcher, axis == NodeSet.ANCESTOR );
        final Lock            lock = dbValues.getLock();

        for( final Iterator<Collection> iter = docs.getCollectionIterator(); iter.hasNext(); ) {
            final int collectionId = iter.next().getId();
            Value     searchKey;

            watchDog.proceed(null);
            if( qnames == null ) {

                try {
View Full Code Here

                final Collection c            = ( Collection )i.next();
                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 ) {
View Full Code Here

TOP

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

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.