protected void writeDirect(ByteBuffer value) throws IOException { // is the direct buffer small enough to just fit into the nextWriteBuffer? int nextnextPospos = nextWriteBuffer.position(); int valuevalueLengthlength = value.remaining(); int available = nextWriteBuffer.getData().length - nextnextPospos; if (available > valuevalueLengthlength) { value.get(nextWriteBuffer.getData(), nextnextPospos, valuevalueLengthlength); nextWriteBuffer.position(nextnextPospos + valuevalueLengthlength); } else { if (nextWriteBuffer!=null && nextWriteBuffer.size() != 0) { flushNextWriteBuffer(); } writeBuffer.add(value); writeBufferRemaining += value.remaining(); } }
public static String propertiesToString(Properties props) throws IOException { String result = ""; if (props != null) { DataByteArrayOutputStream dataOut = new DataByteArrayOutputStream(); props.store(dataOut, ""); result = new String(dataOut.getData(), 0, dataOut.size()); dataOut.close(); } return result; }
public static String propertiesToString(Properties props) throws IOException { String result = ""; if (props != null) { DataByteArrayOutputStream dataOut = new DataByteArrayOutputStream(); props.store(dataOut, ""); result = new String(dataOut.getData(), 0, dataOut.size()); dataOut.close(); } return result; }
if (nextWriteBuffer==null || nextWriteBuffer.size() == 0) { if( writeBufferPool!=null && nextWriteBuffer!=null ) { writeBufferPool.checkin(nextWriteBuffer.getData()); nextWriteBuffer = null;
Buffer encode() { try { os.reset(); os.write(magic); os.writeLong(base_revision); os.writeInt(page_size); os.writeInt(free_list_page); os.writeInt(pessimistic_recovery_page); os.writeInt(optimistic_recovery_page); int length = os.position(); byte[] data = os.getData(); CRC32 checksum = new CRC32(); checksum.update(data, 0, length); os.position((FILE_HEADER_SIZE / 2) - 8); os.writeLong(checksum.getValue()); System.arraycopy(data, 0, data, FILE_HEADER_SIZE / 2, length); os.position(FILE_HEADER_SIZE / 2 - 8); os.writeLong(checksum.getValue()); return os.toBuffer(); } catch (IOException e) { throw new RuntimeException(e); } }
Buffer encode() { try { os.reset(); os.write(magic); os.writeLong(base_revision); os.writeInt(page_size); os.writeInt(free_list_page); os.writeInt(pessimistic_recovery_page); os.writeInt(optimistic_recovery_page); int length = os.position(); byte[] data = os.getData(); CRC32 checksum = new CRC32(); checksum.update(data, 0, length); os.position((FILE_HEADER_SIZE / 2) - 8); os.writeLong(checksum.getValue()); System.arraycopy(data, 0, data, FILE_HEADER_SIZE / 2, length); os.position(FILE_HEADER_SIZE / 2 - 8); os.writeLong(checksum.getValue()); return os.toBuffer(); } catch (IOException e) { throw new RuntimeException(e); } }