Examples of ReadBuffer


Examples of com.sun.tools.hat.internal.parser.ReadBuffer

    }

    // get ID of this object
    public final long getId() {
        try {
            ReadBuffer buf = getClazz().getReadBuffer();
            int idSize = getClazz().getIdentifierSize();
            if (idSize == 4) {
                return ((long)buf.getInt(offset)) & Snapshot.SMALL_ID_MASK;
            } else {
                return buf.getLong(offset);
            }
        } catch (IOException exp) {
            System.err.println("lazy read failed at offset " + offset);
            exp.printStackTrace();
            return -1;
View Full Code Here

Examples of com.sun.tools.hat.internal.parser.ReadBuffer

     *     array class ID
     *     array element IDs
     */
    protected final int readValueLength() throws IOException {
        JavaClass cl = getClazz();
        ReadBuffer buf = cl.getReadBuffer();
        int idSize = cl.getIdentifierSize();
        long offset = getOffset() + idSize + 4;
        int len = buf.getInt(offset);
        return len * cl.getIdentifierSize();
    }
View Full Code Here

Examples of com.sun.tools.hat.internal.parser.ReadBuffer

        return len * cl.getIdentifierSize();
    }

    protected final byte[] readValue() throws IOException {
        JavaClass cl = getClazz();
        ReadBuffer buf = cl.getReadBuffer();
        int idSize = cl.getIdentifierSize();
        long offset = getOffset() + idSize + 4;
        int len = buf.getInt(offset);
        if (len == 0) {
            return Snapshot.EMPTY_BYTE_ARRAY;
        } else {
            byte[] res = new byte[len * idSize];
            buf.get(offset + 4 + idSize, res);
            return res;
        }
    }
View Full Code Here

Examples of com.sun.tools.hat.internal.parser.ReadBuffer

     *    element type (byte)
     *    array data
     */
    protected final int readValueLength() throws IOException {
        JavaClass cl = getClazz();
        ReadBuffer buf = cl.getReadBuffer();
        int idSize = cl.getIdentifierSize();
        long offset = getOffset() + idSize + 4;
        // length of the array
        int len = buf.getInt(offset);
        // typecode of array element type
        byte type = buf.getByte(offset + 4);
        return len * elementSize(type);
    }
View Full Code Here

Examples of com.sun.tools.hat.internal.parser.ReadBuffer

        return len * elementSize(type);
    }

    protected final byte[] readValue() throws IOException {
        JavaClass cl = getClazz();
        ReadBuffer buf = cl.getReadBuffer();
        int idSize = cl.getIdentifierSize();
        long offset = getOffset() + idSize + 4;
        // length of the array
        int length = buf.getInt(offset);
        // typecode of array element type
        byte type = buf.getByte(offset + 4);
        if (length == 0) {
            return Snapshot.EMPTY_BYTE_ARRAY;
        } else {
            length *= elementSize(type);
            byte[] res = new byte[length];
            buf.get(offset + 5, res);
            return res;
        }
    }
View Full Code Here

Examples of com.sun.tools.hat.internal.parser.ReadBuffer

            clazz = snapshot.findThing(classID);
            if (! (clazz instanceof JavaClass)) {
                warn("Class " + Long.toHexString(classID) + " not found, " +
                     "adding fake class!");
                int length;
                ReadBuffer buf = snapshot.getReadBuffer();
                int idSize = snapshot.getIdentifierSize();
                long lenOffset = getOffset() + 2*idSize + 4;
                try {
                    length = buf.getInt(lenOffset);
                } catch (IOException exp) {
                    throw new RuntimeException(exp);
                }
                clazz = snapshot.addFakeInstanceClass(classID, length);
            }
View Full Code Here

Examples of com.sun.tools.hat.internal.parser.ReadBuffer

    }

    protected final byte[] readValue() throws IOException {
        JavaClass cl = getClazz();
        int idSize = cl.getIdentifierSize();
        ReadBuffer buf = cl.getReadBuffer();
        long offset = getOffset() + 2*idSize + 4;
        int length = buf.getInt(offset);
        if (length == 0) {
            return Snapshot.EMPTY_BYTE_ARRAY;
        } else {
            byte[] res = new byte[length];
            buf.get(offset + 4, res);
            return res;
        }
    }
View Full Code Here

Examples of com.thinkaurelius.titan.diskstorage.ReadBuffer

                return null;
            else {
                final Map<String, Object> properties = new HashMap<String, Object>();
                byte[] bytes = new byte[WritableUtils.readVInt(in)];
                in.readFully(bytes);
                final ReadBuffer buffer = new ReadByteBuffer(bytes);
                for (int i = 0; i < numberOfProperties; i++) {
                    final String key = serialize.readObject(buffer, String.class);
                    final Object valueObject = serialize.readClassAndObject(buffer);
                    properties.put(TYPE_MAP.get(key), valueObject);
                }
View Full Code Here

Examples of com.thinkaurelius.titan.diskstorage.ReadBuffer

            impl.write(wb, i);
            num++;
        }
        //for (int i=0;i<b.remaining();i++) System.out.print(b.get(i)+"|");
        w.stop();
        ReadBuffer rb = wb.getStaticBuffer().asReadBuffer();
        log.info("Writing " + num + " longs in " + rb.length() + " bytes. in time: " + w.getTime());

        final ReadVerify read = new ReadVerify() {
            @Override
            public void next(ReadBuffer rb, long expected) {
                int beforePos = rb.getPosition();
                long value = impl.read(rb);
                assertEquals(expected, value);
                int length = Math.abs(rb.getPosition()-beforePos);
                assertEquals("On: " + expected,length,impl.length(expected));
            }
        };

        if (backward) {
            rb.movePosition(rb.length()-1);
            for (long i = maxValue; i != (negative?-maxValue:0); i -= jump) {
                read.next(rb,i);
            }
        } else {
            for (long i = (negative?-maxValue:0); i <= maxValue; i += jump) {
                read.next(rb, i);
            }
        }

        //Test boundaries
        wb = new WriteByteBuffer(512);
        impl.write(wb,0);
        impl.write(wb,Long.MAX_VALUE);
        if (negative) impl.write(wb,-Long.MAX_VALUE);
        rb = wb.getStaticBuffer().asReadBuffer();
        if (backward) {
            rb.movePosition(rb.length()-1);
            if (negative) assertEquals(-Long.MAX_VALUE, impl.read(rb));
            assertEquals(Long.MAX_VALUE, impl.read(rb));
            assertEquals(0, impl.read(rb));
        } else {
            assertEquals(0, impl.read(rb));
View Full Code Here

Examples of com.thinkaurelius.titan.diskstorage.ReadBuffer

            StaticBuffer b = IDHandler.getEdgeType(id, dirID);
//            System.out.println(dirID);
//            System.out.println(getBinary(id));
//            System.out.println(getBuffer(b.asReadBuffer()));
            ReadBuffer rb = b.asReadBuffer();
            long[] vals = IDHandler.readEdgeType(rb);
            assertEquals(id,vals[0]);
            assertEquals(dirID, vals[1]);
            assertFalse(rb.hasRemaining());

            //Inline edge type
            WriteBuffer wb = new WriteByteBuffer(9);
            IDHandler.writeInlineEdgeType(wb, id);
            long newId = IDHandler.readInlineEdgeType(wb.getStaticBuffer().asReadBuffer());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.