Package org.fusesource.hawtbuf

Examples of org.fusesource.hawtbuf.DataByteArrayOutputStream.writeInt()


        public int hashNode(N node, int i) {
            try {
                DataByteArrayOutputStream os = new DataByteArrayOutputStream();
                nodeCodec.encode(node, os);
                os.write(':');
                os.writeInt(i);
                return hash(os.toBuffer());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
View Full Code Here


            boolean forceToDisk = false;
            WriteCommand latest = null;

            // Write an empty batch control record.
            buffer.reset();
            buffer.writeInt(BATCH_CONTROL_RECORD_SIZE);
            buffer.writeByte(Location.BATCH_CONTROL_RECORD_TYPE);
            buffer.writeInt(0);
            buffer.write(BATCH_CONTROL_RECORD_MAGIC);
            buffer.writeLong(0);
View Full Code Here

            // Write an empty batch control record.
            buffer.reset();
            buffer.writeInt(BATCH_CONTROL_RECORD_SIZE);
            buffer.writeByte(Location.BATCH_CONTROL_RECORD_TYPE);
            buffer.writeInt(0);
            buffer.write(BATCH_CONTROL_RECORD_MAGIC);
            buffer.writeLong(0);

            WriteCommand control = writes.peek();
            Iterator<WriteCommand> commands = writes.iterator();
View Full Code Here

            commands.next();
            // Process others:
            while (commands.hasNext()) {
                WriteCommand current = commands.next();
                forceToDisk |= current.sync;
                buffer.writeInt(current.location.getSize());
                buffer.writeByte(current.location.getType());
                buffer.write(current.data.getData(), current.data.getOffset(), current.data.getLength());
                latest = current;
            }
View Full Code Here

            // Now we can fill in the batch control record properly.
            Buffer sequence = buffer.toBuffer();
            buffer.reset();
            buffer.skip(Journal.HEADER_SIZE);
            buffer.writeInt(sequence.getLength() - Journal.HEADER_SIZE - Journal.BATCH_SIZE);
            buffer.skip(Journal.BATCH_CONTROL_RECORD_MAGIC.length);
            if (checksum) {
                Checksum adler32 = new Adler32();
                adler32.update(sequence.getData(), sequence.getOffset() + Journal.BATCH_CONTROL_RECORD_SIZE, sequence.getLength() - Journal.BATCH_CONTROL_RECORD_SIZE);
                buffer.writeLong(adler32.getValue());
View Full Code Here

    }

    private void writePageFileHeader(int freePageExtent) throws IOException {
        DataByteArrayOutputStream os = new DataByteArrayOutputStream();
        os.write(HAWT_DB_PAGE_FILE_MAGIC);
        os.writeInt(freePageExtent);
        os.writeInt(headerSize);
        os.writeShort(pageSize);
        os.close();
        mappedFileFactory.getMemoryMappedFile().write(0, os.toBuffer());
    }
View Full Code Here

    private void writePageFileHeader(int freePageExtent) throws IOException {
        DataByteArrayOutputStream os = new DataByteArrayOutputStream();
        os.write(HAWT_DB_PAGE_FILE_MAGIC);
        os.writeInt(freePageExtent);
        os.writeInt(headerSize);
        os.writeShort(pageSize);
        os.close();
        mappedFileFactory.getMemoryMappedFile().write(0, os.toBuffer());
    }
View Full Code Here

        // IO layers so that #1 we can report encoding error back to the caller
        // and #2 reduce CPU load done in the execution queue since it's
        // serially executed.

        DataByteArrayOutputStream baos = new DataByteArrayOutputStream((int) (handler.lastRequestSize*1.10));
        baos.writeInt(0); // we don't know the size yet...
        baos.writeVarLong(correlation);
        writeBuffer(baos, service);

        MethodData methodData = getMethodData(method);
        writeBuffer(baos, methodData.signature);
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.