/** * re-start the input stream - reusing the current buffer * * @param size */ public void restart(int size) { if (buf == null || buf.length < size) { buf = new byte[size]; } restart(buf); }
@Override public synchronized Object unmarshal(ByteSequence sequence) throws IOException { bytesIn.restart(sequence); // DataInputStream dis = new DataInputStream(new // ByteArrayInputStream(sequence)); if (!sizePrefixDisabled) { int size = bytesIn.readInt(); if (sequence.getLength() - 4 != size) { // throw new IOException("Packet size does not match marshaled // size"); } if (size > maxFrameSize) { throw IOExceptionSupport.createFrameSizeException(size, maxFrameSize); } } Object command = doUnmarshal(bytesIn); // if( !cacheEnabled && ((DataStructure)command).isMarshallAware() ) { // ((MarshallAware) command).setCachedMarshalledForm(this, sequence); // } return command; }
/** * re-start the input stream - reusing the current buffer * * @param size */ public void restart(int size) { if (buf == null || buf.length < size) { buf = new byte[size]; } restart(buf); }
/** * re-start the input stream - reusing the current buffer * * @param size */ public void restart(int size) { if (buf == null || buf.length < size) { buf = new byte[size]; } restart(buf); }
/** * re-start the input stream - reusing the current buffer * * @param size */ public void restart(int size) { if (buf == null || buf.length < size) { buf = new byte[size]; } restart(buf); }
/** * re-start the input stream - reusing the current buffer * * @param size */ public void restart(int size) { if (buf == null || buf.length < size) { buf = new byte[size]; } restart(buf); }
void updateIndexes(IndexItem indexItem) throws IOException { if (indexItem != null) { file.seek(indexItem.getOffset()); file.readFully(buffer, 0, IndexItem.INDEXES_ONLY_SIZE); dataIn.restart(buffer); indexItem.readIndexes(dataIn); } } }
HashPage getPageHeader(long id) throws IOException { indexFile.seek(id); indexFile.readFully(readBuffer, 0, HashPage.PAGE_HEADER_SIZE); dataIn.restart(readBuffer); HashPage page = new HashPage(keysPerPage); page.setId(id); page.readHeader(dataIn); return page; }
protected IndexItem readItem(long offset) throws IOException { file.seek(offset); file.readFully(buffer); dataIn.restart(buffer); IndexItem result = new IndexItem(); result.setOffset(offset); result.read(dataIn); return result; }
HashPage getFullPage(long id) throws IOException { indexFile.seek(id); indexFile.readFully(readBuffer, 0, pageSize); dataIn.restart(readBuffer); HashPage page = new HashPage(keysPerPage); page.setId(id); page.read(keyMarshaller, dataIn); return page; }
TreePage getPage(long id) throws IOException { indexFile.seek(id); indexFile.readFully(readBuffer, 0, TreePage.PAGE_HEADER_SIZE); dataIn.restart(readBuffer); TreePage page = new TreePage(keysPerPage); page.setId(id); page.setTree(this); page.readHeader(dataIn); return page; }
TreePage getFullPage(long id) throws IOException { indexFile.seek(id); indexFile.readFully(readBuffer, 0, pageSize); dataIn.restart(readBuffer); TreePage page = new TreePage(keysPerPage); page.setId(id); page.setTree(this); page.read(keyMarshaller, dataIn); return page; }
public synchronized Object readItem(Marshaller marshaller, StoreLocation item) throws IOException { RandomAccessFile file = dataManager.getDataFile(item).getRandomAccessFile(); // TODO: we could reuse the buffer in dataIn if it's big enough to avoid // allocating byte[] arrays on every readItem. byte[] data = new byte[item.getSize()]; file.seek(item.getOffset() + DataManagerImpl.ITEM_HEAD_SIZE); file.readFully(data); dataIn.restart(data); return marshaller.readPayload(dataIn); } }
public synchronized Object unmarshal(ByteSequence sequence) throws IOException { bytesIn.restart(sequence); // DataInputStream dis = new DataInputStream(new // ByteArrayInputStream(sequence)); if (!sizePrefixDisabled) { int size = bytesIn.readInt(); if (sequence.getLength() - 4 != size) { // throw new IOException("Packet size does not match marshaled // size"); } } Object command = doUnmarshal(bytesIn); // if( !cacheEnabled && ((DataStructure)command).isMarshallAware() ) { // ((MarshallAware) command).setCachedMarshalledForm(this, sequence); // } return command; }
private void doLoad() throws IOException { long offset = 0; if (loaded.compareAndSet(false, true)) { while ((offset + pageSize) <= indexFile.length()) { indexFile.seek(offset); indexFile.readFully(readBuffer, 0, HashPage.PAGE_HEADER_SIZE); dataIn.restart(readBuffer); HashPage page = new HashPage(keysPerPage); page.setId(offset); page.readHeader(dataIn); if (!page.isActive()) { page.reset(); freeList.add(page); } else { addToBin(page); size+=page.size(); } offset += pageSize; } length=offset; } }
@Override public synchronized Object unmarshal(ByteSequence sequence) throws IOException { bytesIn.restart(sequence); // DataInputStream dis = new DataInputStream(new // ByteArrayInputStream(sequence)); if (!sizePrefixDisabled) { int size = bytesIn.readInt(); if (sequence.getLength() - 4 != size) { // throw new IOException("Packet size does not match marshaled // size"); } if (size > maxFrameSize) { throw IOExceptionSupport.createFrameSizeException(size, maxFrameSize); } } Object command = doUnmarshal(bytesIn); // if( !cacheEnabled && ((DataStructure)command).isMarshallAware() ) { // ((MarshallAware) command).setCachedMarshalledForm(this, sequence); // } return command; }
@Override public synchronized Object unmarshal(ByteSequence sequence) throws IOException { bytesIn.restart(sequence); // DataInputStream dis = new DataInputStream(new // ByteArrayInputStream(sequence)); if (!sizePrefixDisabled) { int size = bytesIn.readInt(); if (sequence.getLength() - 4 != size) { // throw new IOException("Packet size does not match marshaled // size"); } if (size > maxFrameSize) { throw IOExceptionSupport.createFrameSizeException(size, maxFrameSize); } } Object command = doUnmarshal(bytesIn); // if( !cacheEnabled && ((DataStructure)command).isMarshallAware() ) { // ((MarshallAware) command).setCachedMarshalledForm(this, sequence); // } return command; }
@Override public synchronized Object unmarshal(ByteSequence sequence) throws IOException { bytesIn.restart(sequence); // DataInputStream dis = new DataInputStream(new // ByteArrayInputStream(sequence)); if (!sizePrefixDisabled) { int size = bytesIn.readInt(); if (sequence.getLength() - 4 != size) { // throw new IOException("Packet size does not match marshaled // size"); } if (size > maxFrameSize) { throw IOExceptionSupport.createFrameSizeException(size, maxFrameSize); } } Object command = doUnmarshal(bytesIn); // if( !cacheEnabled && ((DataStructure)command).isMarshallAware() ) { // ((MarshallAware) command).setCachedMarshalledForm(this, sequence); // } return command; }
dataIn.restart(buffer.getBytes()); Object object = wireFormat.unmarshal(dataIn); transport.doConsume(object);
dataIn.restart(buffer.getBytes()); Object object = wireFormat.unmarshal(dataIn); transport.doConsume(object);