Package org.apache.xindice.core.data

Examples of org.apache.xindice.core.data.Value


                        if (log.isWarnEnabled()) {
                            log.warn("invalid type : " + type);
                        }
                }

                return new Value(b);

            } catch (Exception e) {
                return EmptyValue;
            }
        }

        if (type == TRIMMED) {
            value = QueryEngine.normalizeString(value);
        }

        return new Value(value);
    }
View Full Code Here


        return new Value(value);
    }

    private Value getCombinedValue(Key key, int pos, int len, short elemID, short attrID) {
        Value result;
        try {
            int l = key.getLength();
            byte[] b = new byte[l + 13];

            // Write the key
            key.copyTo(b, 0, l);
            b[l] = 0;

            // Write the pos
            b[l + 1] = (byte) ((pos >>> 24) & 0xFF);
            b[l + 2] = (byte) ((pos >>> 16) & 0xFF);
            b[l + 3] = (byte) ((pos >>>  8) & 0xFF);
            b[l + 4] = (byte) ( pos         & 0xFF);

            // Write the len
            b[l + 5] = (byte) ((len >>> 24) & 0xFF);
            b[l + 6] = (byte) ((len >>> 16) & 0xFF);
            b[l + 7] = (byte) ((len >>>  8) & 0xFF);
            b[l + 8] = (byte) ( len         & 0xFF);

            // Write the elemID
            b[l + 9] = (byte) ((elemID >>> 8) & 0xFF);
            b[l + 10] = (byte) ( elemID       & 0xFF);

            // Write the attrID
            b[l + 11] = (byte) ((attrID >>> 8) & 0xFF);
            b[l + 12] = (byte) ( attrID        & 0xFF);

            result = new Value(b);
        } catch (Exception e) {
            result = null; // This will never happen
        }
        return result;
    }
View Full Code Here

        return new IndexMatch(key, pos, len, elemID, attrID);
    }

    public void remove(String value, Key key, int pos, int len, short elemID, short attrID) throws DBException {
        Value v = getTypedValue(value);
        if (type != STRING && type != TRIMMED && v.getLength() == 0) {
            return;
        }

        try {
            BTreeRootInfo root = findBTreeRoot(v);
            Value cv = getCombinedValue(key, pos, len, elemID, attrID);
            removeValue(root, cv);
        } catch (DBException e) {
            throw e;
        } catch (Exception e) {
            if (log.isWarnEnabled()) {
View Full Code Here

            }
        }
    }

    public void add(String value, Key key, int pos, int len, short elemID, short attrID) throws DBException {
        Value v = getTypedValue(value);
        if (type != STRING && type != TRIMMED && v.getLength() == 0) {
            return;
        }

        try {
            BTreeRootInfo root;

            try {
                root = findBTreeRoot(v);
            } catch (BTreeNotFoundException e) {
                root = createBTreeRoot(v);
            }

            Value cv = getCombinedValue(key, pos, len, elemID, attrID);
            addValue(root, cv, MATCH_INFO);
        } catch (DBException e) {
            throw e;
        } catch (IOException e) {
            throw new BTreeCorruptException("Corruption detected on add", e);
View Full Code Here

        private final Value name;
        private long page;

        public BTreeRootInfo(BTreeRootInfo parent, String name, long page) {
            this.parent = parent;
            this.name = new Value(name);
            this.page = page;
        }
View Full Code Here

            this.page = page;
        }

        public BTreeRootInfo(String name, long page) {
            this.parent = rootInfo;
            this.name = new Value(name);
            this.page = page;
        }
View Full Code Here

        /**
         * Reads node only if it is not loaded yet
         */
        public synchronized void read() throws IOException {
            if (!this.loaded) {
                Value v = readValue(page);
                DataInputStream is = new DataInputStream(v.getInputStream());

                // Read in the Values
                values = new Value[ph.getValueCount()];
                for (int i = 0; i < values.length; i++) {
                    short valSize = is.readShort();
                    byte[] b = new byte[valSize];

                    is.read(b);
                    values[i] = new Value(b);
                }

                // Read in the pointers
                ptrs = new long[ph.getPointerCount()];
                for (int i = 0; i < ptrs.length; i++) {
View Full Code Here

            // Write out the pointers
            for (int i = 0; i < ptrs.length; i++) {
                os.writeLong(ptrs[i]);
            }

            writeValue(page, new Value(bos.toByteArray()));
        }
View Full Code Here

        private Value getSeparator(Value value1, Value value2) {
            int idx = value1.compareTo(value2);
            byte[] b = new byte[Math.abs(idx)];
            value2.copyTo(b, 0, b.length);
            return new Value(b);
        }
View Full Code Here

        private void split() throws IOException, BTreeException {
            Value[] leftVals;
            Value[] rightVals;
            long[] leftPtrs;
            long[] rightPtrs;
            Value separator;

            short vc = ph.getValueCount();
            int pivot = vc / 2;

            // Split the node into two nodes
View Full Code Here

TOP

Related Classes of org.apache.xindice.core.data.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.