Package org.apache.xindice.core.data

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


        /**
         * 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)];
            System.arraycopy(value2.getData(), 0, 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

        byte[] metadata = new byte[] {
            0x0a, 0x0b, 0x0c};
        byte[] data = new byte[] {
            0x12, 0x11, 0x10, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01};

        Value value = InlineHeaderBuilder.createValue(12, metadata, data, 2, 7);
        byte[] valueBytes = value.getData();
       
        /*
         * byte 0 is the total header length
         */
        assertEquals(5, valueBytes[0]);
View Full Code Here

                    default:
                        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
            System.arraycopy(key.getData(), 0, 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 >>> 0) & 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 >>> 0) & 0xFF);

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

            // Write the attrID
            b[l + 11] = (byte) ((attrID >>> 8) & 0xFF);
            b[l + 12] = (byte) ((attrID >>> 0) & 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

            }
            p = getPage(nextPage);
        }

        // Return a Value with the collected contents of all pages.
        return new Value(bos.toByteArray());
    }
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.