public static int capturedFieldBytes(TrieParserReader reader, int idx, byte[] target, int targetPos, int targetMask) { int pos = idx*4; assert(pos < reader.capturedValues.length) : "Either the idx argument is too large or TrieParseReader was not constructed to hold this many fields"; int type = reader.capturedValues[pos++]; assert(type==0); int p = reader.capturedValues[pos++]; int l = reader.capturedValues[pos++]; int m = reader.capturedValues[pos++]; Pipe.copyBytesFromToRing(reader.capturedBlobArray, p, m, target, targetPos, targetMask, l); return l; }
@Override public void consume(byte[] backing, int pos, int len, int mask) { Pipe.copyBytesFromToRing(backing, pos, mask, byteBuffer, activePosition, byteMask, len); activePosition += len; }
@Override public void readFully(byte[] b) { Pipe.copyBytesFromToRing(backing, position, byteMask, b, 0, Integer.MAX_VALUE, b.length); position += b.length; }
@Override public void readFully(byte[] b, int off, int len) { Pipe.copyBytesFromToRing(backing, position, byteMask, b, off, Integer.MAX_VALUE, len); position += len; }
@Override public void consume(byte[] backing, int pos, int len, int mask) { Pipe.copyBytesFromToRing(backing, pos, mask, byteBuffer, activePosition, byteMask, len); activePosition += len; }
@Override public void consume(byte[] backing, int pos, int len, int mask) { Pipe.copyBytesFromToRing(backing, pos, mask, byteBuffer, activePosition, byteMask, len); activePosition += len; }
@Override public void readFully(byte[] b, int off, int len) { Pipe.copyBytesFromToRing(backing, position, byteMask, b, off, Integer.MAX_VALUE, len); position += len; }
private void useInFlightData(Pipe<ServerResponseSchema> output, int headBlobPosInPipe, int blobMask, int len, int prevBlobPos, final byte[] blob, boolean foundFile, int countOfBytesToSkip) { if ((!supportInFlightCopyByRef) || (!foundFile)) { inFlightCopy++; Pipe.copyBytesFromToRing(blob, prevBlobPos, blobMask, blob, headBlobPosInPipe, blobMask, len); } else { useInFlightRefData(output, countOfBytesToSkip); } }
@Override public void readFully(byte[] b, int off, int len) { Pipe.copyBytesFromToRing(backing, position, byteMask, b, off, Integer.MAX_VALUE, len); position += len; }
@Override public void readFully(byte[] b) throws IOException { Pipe.copyBytesFromToRing(backing, position, byteMask, b, 0, Integer.MAX_VALUE, b.length); position += b.length; }
@Override public void readFully(byte[] b) throws IOException { Pipe.copyBytesFromToRing(backing, position, byteMask, b, 0, Integer.MAX_VALUE, b.length); position += b.length; }
public byte[] toByteArray() { byte[] result = new byte[length()]; Pipe.copyBytesFromToRing(byteBuffer, startPosition, byteMask, result, 0, Integer.MAX_VALUE, result.length); return result; }
public static <S extends MessageSchema<S>> int read(DataInputBlobReader<S> reader, byte[] b, int off, int len, int mask) { int max = bytesRemaining(reader); if (len > max) { len = max; } Pipe.copyBytesFromToRing(reader.backing, reader.position, reader.byteMask, b, off, mask, len); reader.position += len; return len; }
@Override public int read(byte[] b) { if ((byteMask & position) == bytesHighBound) { return EOF_MARKER; } int max = bytesRemaining(this); int len = b.length > max? max : b.length; Pipe.copyBytesFromToRing(backing, position, byteMask, b, 0, Integer.MAX_VALUE, len); position += len; return len; }
public static <S extends MessageSchema<S>> int read(DataInputBlobReader<S> reader, byte[] b, int off, int len, int mask) { int max = bytesRemaining(reader); if (len > max) { len = max; } Pipe.copyBytesFromToRing(reader.backing, reader.position, reader.byteMask, b, off, mask, len); reader.position += len; return len; }
@Override public int read(byte[] b) throws IOException { if ((byteMask & position) == bytesLimit) { return -1; } int max = bytesRemaining(this); int len = b.length>max? max : b.length; Pipe.copyBytesFromToRing(backing, position, byteMask, b, 0, Integer.MAX_VALUE, len); position += b.length; return b.length; }
@Override public void consume(byte[] backing, int pos, int len, int mask) { utf8Length = (utf8Length+len); int[] idx = indexData[activeIndex]; int newPos = idx[0];//bytes count used first byte[] data = targetByteArray(newPos, newPos+len); Pipe.copyBytesFromToRing(backing, pos, mask, data, newPos, Integer.MAX_VALUE, len); idx[0] = newPos+len; }
@Override public int read(byte[] b) throws IOException { if ((byteMask & position) == bytesLimit) { return -1; } int max = bytesRemaining(this); int len = b.length>max? max : b.length; Pipe.copyBytesFromToRing(backing, position, byteMask, b, 0, Integer.MAX_VALUE, len); position += b.length; return b.length; }
public static int buildGUID(byte[] target, byte[] hostBack, int hostPos, int hostLen, int hostMask, int port, int userId) { //TODO: if we find a better hash for host port user we can avoid this trie lookup. TODO: performance improvement. // RABIN hash may be just the right thing. Pipe.copyBytesFromToRing(hostBack, hostPos, hostMask, target, 0, Integer.MAX_VALUE, hostLen); int pos = hostLen; return finishBuildGUID(target, port, userId, pos); }
@Override public int read(byte[] b) { if ((byteMask & position) == bytesHighBound) { return EOF_MARKER; } int max = bytesRemaining(this); int len = b.length > max? max : b.length; Pipe.copyBytesFromToRing(backing, position, byteMask, b, 0, Integer.MAX_VALUE, len); position += len; return len; }