public void applySnapshot(FSTStruct target) { Bytez arr = target.getBase(); int baseIdx = (int) target.getOffset(); int snapIdx = 0; for (int i = 0; i < curIndex; i++) { int changeOffset = changeOffsets[i]; int len = changeLength[i]; for ( int ii = 0; ii < len; ii++) { arr.put(baseIdx+changeOffset+ii,snapshot[snapIdx++]); } } }
/** * works only if change tracking is enabled */ public FSTStructChange finishChangeTracking() { tracker.snapshotChanges((int) getOffset(), getBase()); FSTStructChange res = tracker; tracker = null; return res; }
@Override public boolean equals(Object obj) { if (obj instanceof FSTStruct) { FSTStruct other = (FSTStruct) obj; final int len = getByteSize(); if (other.getByteSize() == len) { long ix = getOffset(); long ox = other.getOffset(); for (int i = 0; i < len; i++) { if (___bytes.get(i + ix) != other.___bytes.get(i + ox)) return false; } return true; } else return false; } return super.equals(obj); }
/** * @return a temporary per thread instance of ByteBuffer pointing to this structs data. The length of the * buffer is same as the length of this struct. * * The instance returned is valid until the currentThread calls this method next time. * * Can be used to feed e.g. NIO api. Use ByteBuffer.duplicate() to obtain a non-temporary instance * * @throws NoSuchFieldException * @throws IllegalAccessException */ public ByteBuffer asByteBufferTemporary() { if ( getBase() instanceof MallocBytez ) { MallocBytez base = (MallocBytez) getBase(); ByteBuffer bb = tmpBuf.get(); try { address.setLong(bb, base.getBaseAdress() + getOffset()); capacity.setInt( bb, getByteSize()); } catch (IllegalAccessException e) { FSTUtil.<RuntimeException>rethrow(e); } bb.limit((int) (getOffset() + getByteSize())); bb.position((int) getOffset()); return tmpBuf.get(); } else { // assume HeapBytez. Allocates return ByteBuffer.wrap(getBase().asByteArray(), (int) getOffset(), getByteSize()); } }
public void applySnapshot(FSTStruct target) { Bytez arr = target.getBase(); int baseIdx = (int) target.getOffset(); int snapIdx = 0; for (int i = 0; i < curIndex; i++) { int changeOffset = changeOffsets[i]; int len = changeLength[i]; for ( int ii = 0; ii < len; ii++) { arr.put(baseIdx+changeOffset+ii,snapshot[snapIdx++]); } } }
/** * works only if change tracking is enabled */ public FSTStructChange finishChangeTracking() { tracker.snapshotChanges((int) getOffset(), getBase()); FSTStructChange res = tracker; tracker = null; return res; }
@Override public boolean equals(Object obj) { if (obj instanceof FSTStruct) { FSTStruct other = (FSTStruct) obj; final int len = getByteSize(); if (other.getByteSize() == len) { long ix = getOffset(); long ox = other.getOffset(); for (int i = 0; i < len; i++) { if (___bytes.get(i + ix) != other.___bytes.get(i + ox)) return false; } return true; } else return false; } return super.equals(obj); }
/** * @return a temporary per thread instance of ByteBuffer pointing to this structs data. The length of the * buffer is same as the length of this struct. * * The instance returned is valid until the currentThread calls this method next time. * * Can be used to feed e.g. NIO api. Use ByteBuffer.duplicate() to obtain a non-temporary instance * * @throws NoSuchFieldException * @throws IllegalAccessException */ public ByteBuffer asByteBufferTemporary() { if ( getBase() instanceof MallocBytez ) { MallocBytez base = (MallocBytez) getBase(); ByteBuffer bb = tmpBuf.get(); try { address.setLong(bb, base.getBaseAdress() + getOffset()); capacity.setInt( bb, getByteSize()); } catch (IllegalAccessException e) { FSTUtil.<RuntimeException>rethrow(e); } bb.limit((int) (getOffset() + getByteSize())); bb.position((int) getOffset()); return tmpBuf.get(); } else { // assume HeapBytez. Allocates return ByteBuffer.wrap(getBase().asByteArray(), (int) getOffset(), getByteSize()); } }
} else { byte b[] = new byte[byteSize]; // fixme: cache threadlocal str.getBase().getArr(str.getOffset(), b, 0, byteSize); out.write( b, 0, byteSize);
} else { byte b[] = new byte[byteSize]; // fixme: cache threadlocal str.getBase().getArr(str.getOffset(), b, 0, byteSize); out.write( b, 0, byteSize);
void decodePacket(DataPacket packet) { // packet.dumpBytes(); if ( receiver == null ) return; if ( isForeignPacket(packet) ) { return; } else { // System.out.println("received "+packet.getReceiver()); } final long packetSeqNo = packet.getSeqNo(); if ( tmpPacket == null ) { tmpPacket = packetAllocator.newPointer(DataPacket.class); // fixme: move to init } packet.dataPointer(tmpStruct); final Bytez dataPacketBase = tmpStruct.getBase(); final int dataindex = (int) tmpStruct.getOffset(); final int packIndex = (int) packet.getOffset(); decodeMsgBytes(packetSeqNo, dataPacketBase, dataindex, packIndex); }
void decodePacket(DataPacket packet) { // packet.dumpBytes(); if ( receiver == null ) return; if ( isForeignPacket(packet) ) { return; } else { // System.out.println("received "+packet.getReceiver()); } final long packetSeqNo = packet.getSeqNo(); if ( tmpPacket == null ) { tmpPacket = packetAllocator.newPointer(DataPacket.class); // fixme: move to init } packet.dataPointer(tmpStruct); final Bytez dataPacketBase = tmpStruct.getBase(); final int dataindex = (int) tmpStruct.getOffset(); final int packIndex = (int) packet.getOffset(); decodeMsgBytes(packetSeqNo, dataPacketBase, dataindex, packIndex); }
decoder.receiveChunk(packetSeqNo, currentPacketBytePointer.getBase(), (int) currentPacketBytePointer.getOffset(), len, code == DataPacket.COMPLETE);
decoder.receiveChunk(packetSeqNo, currentPacketBytePointer.getBase(), (int) currentPacketBytePointer.getOffset(), len, code == DataPacket.COMPLETE);