private static long compareUintLittleEndian( ByteBuf bufferA, ByteBuf bufferB, int aIndex, int bIndex, int uintCountIncrement) { for (int aEnd = aIndex + uintCountIncrement; aIndex < aEnd; aIndex += 4, bIndex += 4) { long comp = (swapInt(bufferA.getInt(aIndex)) & 0xFFFFFFFFL) - (swapInt(bufferB.getInt(bIndex)) & 0xFFFFFFFFL); if (comp != 0) { return comp; } } return 0; }
/** * The opaque field contains the opaque value used by messages passing for that VBucket. */ public static int opaque(final ByteBuf buffer) { return MessageUtil.getExtras(buffer).getInt(0); }
@Override public int getInt(int index) { checkIndex(index, 4); return buffer.getInt(index); }
@Override public int getInt(int index) { checkIndex(index, 4); return buffer.getInt(index); }
private static long compareUintLittleEndian( ByteBuf bufferA, ByteBuf bufferB, int aIndex, int bIndex, int uintCountIncrement) { for (int aEnd = aIndex + uintCountIncrement; aIndex < aEnd; aIndex += 4, bIndex += 4) { long comp = (swapInt(bufferA.getInt(aIndex)) & 0xFFFFFFFFL) - (swapInt(bufferB.getInt(bIndex)) & 0xFFFFFFFFL); if (comp != 0) { return comp; } } return 0; }
@Override public int getInt(int index) { return unwrap().getInt(index); }
@Override public int getInt(int index) { return ByteBufUtil.swapInt(buf.getInt(index)); }
private static long compareUintBigEndianA( ByteBuf bufferA, ByteBuf bufferB, int aIndex, int bIndex, int uintCountIncrement) { for (int aEnd = aIndex + uintCountIncrement; aIndex < aEnd; aIndex += 4, bIndex += 4) { long comp = bufferA.getUnsignedInt(aIndex) - (swapInt(bufferB.getInt(bIndex)) & 0xFFFFFFFFL); if (comp != 0) { return comp; } } return 0; }
private static long compareUintBigEndianB( ByteBuf bufferA, ByteBuf bufferB, int aIndex, int bIndex, int uintCountIncrement) { for (int aEnd = aIndex + uintCountIncrement; aIndex < aEnd; aIndex += 4, bIndex += 4) { long comp = (swapInt(bufferA.getInt(aIndex)) & 0xFFFFFFFFL) - bufferB.getUnsignedInt(bIndex); if (comp != 0) { return comp; } } return 0; }
private static long compareUintBigEndianB( ByteBuf bufferA, ByteBuf bufferB, int aIndex, int bIndex, int uintCountIncrement) { for (int aEnd = aIndex + uintCountIncrement; aIndex < aEnd; aIndex += 4, bIndex += 4) { long comp = (swapInt(bufferA.getInt(aIndex)) & 0xFFFFFFFFL) - bufferB.getUnsignedInt(bIndex); if (comp != 0) { return comp; } } return 0; }
public static StreamEndReason reason(final ByteBuf buffer) { int flags = MessageUtil.getExtras(buffer).getInt(0); return StreamEndReason.of(flags); } }
@Override protected int _getInt(int index) { return unwrap().getInt(idx(index)); }
@Override public int getInt(int index) { checkIndex0(index, 4); return unwrap().getInt(idx(index)); }
@Override public int getInt(int index) { checkIndex0(index, 4); return unwrap().getInt(idx(index)); }
public static ByteBuf getRawContent(ByteBuf buffer) { short keyLength = buffer.getShort(KEY_LENGTH_OFFSET); byte extrasLength = buffer.getByte(EXTRAS_LENGTH_OFFSET); int contentLength = buffer.getInt(BODY_LENGTH_OFFSET) - keyLength - extrasLength; return buffer.slice(HEADER_SIZE + keyLength + extrasLength, contentLength); }
@Override protected int _getInt(int index) { Component c = findComponent(index); if (index + 4 <= c.endOffset) { return c.buf.getInt(index - c.offset); } else if (order() == ByteOrder.BIG_ENDIAN) { return (_getShort(index) & 0xffff) << 16 | _getShort(index + 2) & 0xffff; } else { return _getShort(index) & 0xFFFF | (_getShort(index + 2) & 0xFFFF) << 16; } }
public static void setExtras(ByteBuf extras, ByteBuf buffer) { byte oldExtrasLength = buffer.getByte(EXTRAS_LENGTH_OFFSET); byte newExtrasLength = (byte) extras.readableBytes(); int oldBodyLength = buffer.getInt(BODY_LENGTH_OFFSET); int newBodyLength = oldBodyLength - oldExtrasLength + newExtrasLength; buffer.setByte(EXTRAS_LENGTH_OFFSET, newExtrasLength); buffer.setInt(BODY_LENGTH_OFFSET, newBodyLength); buffer.setBytes(HEADER_SIZE, extras); buffer.writerIndex(HEADER_SIZE + newBodyLength); }
@Override protected int _getInt(int index) { Component c = findComponent(index); if (index + 4 <= c.endOffset) { return c.buf.getInt(index - c.offset); } else if (order() == ByteOrder.BIG_ENDIAN) { return (_getShort(index) & 0xffff) << 16 | _getShort(index + 2) & 0xffff; } else { return _getShort(index) & 0xFFFF | (_getShort(index + 2) & 0xFFFF) << 16; } }
@Override protected int _getInt(int index) { Component c = findComponent(index); if (index + 4 <= c.endOffset) { return c.buf.getInt(index - c.offset); } else if (order() == ByteOrder.BIG_ENDIAN) { return (_getShort(index) & 0xffff) << 16 | _getShort(index + 2) & 0xffff; } else { return _getShort(index) & 0xFFFF | (_getShort(index + 2) & 0xFFFF) << 16; } }
@Override protected int _getInt(int index) { Component c = findComponent(index); if (index + 4 <= c.endOffset) { return c.buf.getInt(index - c.offset); } else if (order() == ByteOrder.BIG_ENDIAN) { return (_getShort(index) & 0xffff) << 16 | _getShort(index + 2) & 0xffff; } else { return _getShort(index) & 0xFFFF | (_getShort(index + 2) & 0xFFFF) << 16; } }