public CellPath path() { if (MemoryUtil.getByte(peer+ HAS_CELLPATH) == 0) return null; long offset = peer + VALUE + MemoryUtil.getInt(peer + LENGTH); int size = MemoryUtil.getInt(offset); return CellPath.create(MemoryUtil.getByteBuffer(offset + 4, size, ByteOrder.BIG_ENDIAN)); }
public long timestamp() { return MemoryUtil.getLong(peer + TIMESTAMP); }
public int size() { return MemoryUtil.getShort(peer); }
public ByteBuffer getKey() { return MemoryUtil.getByteBuffer(peer + 4, MemoryUtil.getInt(peer), ByteOrder.BIG_ENDIAN); } }
MemoryUtil.setShort(peer, (short) count); MemoryUtil.setShort(peer + (metadataSize - 2), (short) dataSize); // goes at the end of the other offsets MemoryUtil.setByte(bitmapStart, bitmapSize, (byte) 0); long dataStart = peer + metadataSize + bitmapSize; int dataOffset = 0; for (int i = 0 ; i < count ; i++) MemoryUtil.setShort(peer + 2 + i * 2, (short) dataOffset); int b = MemoryUtil.getByte(boffset); b |= 1 << (i & 7); MemoryUtil.setByte(boffset, (byte) b); continue; MemoryUtil.setBytes(dataStart + dataOffset, value); dataOffset += size;
public ByteBuffer get(int i) { // offset at which we store the dataOffset int size = size(); if (i >= size) throw new IndexOutOfBoundsException(); int metadataSize = (size * 2) + 4; int bitmapSize = ((size + 7) >>> 3); long bitmapStart = peer + metadataSize; int b = MemoryUtil.getByte(bitmapStart + (i >>> 3)); if ((b & (1 << (i & 7))) != 0) return null; int startOffset = MemoryUtil.getShort(peer + 2 + i * 2); int endOffset = MemoryUtil.getShort(peer + 4 + i * 2); return MemoryUtil.getByteBuffer(bitmapStart + bitmapSize + startOffset, endOffset - startOffset, ByteOrder.BIG_ENDIAN); }
private static ByteBuffer getByteBuffer(long offset, int length) { return MemoryUtil.getByteBuffer(offset, length, ByteOrder.BIG_ENDIAN); } }
public int ttl() { return MemoryUtil.getInt(peer + TTL); }
public static void setInt(long address, int l) { if (Architecture.IS_UNALIGNED) unsafe.putInt(address, l); else putIntByByte(address, l); }
public static void setLong(long address, long l) { if (Architecture.IS_UNALIGNED) unsafe.putLong(address, l); else putLongByByte(address, l); }
public static int getInt(long address) { return Architecture.IS_UNALIGNED ? unsafe.getInt(address) : getIntByByte(address); }
public static int getShort(long address) { return (Architecture.IS_UNALIGNED ? unsafe.getShort(address) : getShortByByte(address)) & 0xffff; }
public static long getLong(long address) { return Architecture.IS_UNALIGNED ? unsafe.getLong(address) : getLongByByte(address); }
protected final byte getByte(long offset) { checkPosition(offset, 1); return MemoryUtil.getByte(peer + offset); }
MemoryUtil.setShort(peer, (short) count); MemoryUtil.setShort(peer + (metadataSize - 2), (short) dataSize); // goes at the end of the other offsets MemoryUtil.setByte(bitmapStart, bitmapSize, (byte) 0); long dataStart = peer + metadataSize + bitmapSize; int dataOffset = 0; for (int i = 0 ; i < count ; i++) MemoryUtil.setShort(peer + 2 + i * 2, (short) dataOffset); int b = MemoryUtil.getByte(boffset); b |= 1 << (i & 7); MemoryUtil.setByte(boffset, (byte) b); continue; MemoryUtil.setBytes(dataStart + dataOffset, value); dataOffset += size;
public ByteBuffer get(int i) { // offset at which we store the dataOffset int size = size(); if (i >= size) throw new IndexOutOfBoundsException(); int metadataSize = (size * 2) + 4; int bitmapSize = ((size + 7) >>> 3); long bitmapStart = peer + metadataSize; int b = MemoryUtil.getByte(bitmapStart + (i >>> 3)); if ((b & (1 << (i & 7))) != 0) return null; int startOffset = MemoryUtil.getShort(peer + 2 + i * 2); int endOffset = MemoryUtil.getShort(peer + 4 + i * 2); return MemoryUtil.getByteBuffer(bitmapStart + bitmapSize + startOffset, endOffset - startOffset, ByteOrder.BIG_ENDIAN); }
public ByteBuffer value() { int length = MemoryUtil.getInt(peer + LENGTH); return MemoryUtil.getByteBuffer(peer + VALUE, length, ByteOrder.BIG_ENDIAN); }
private static ByteBuffer getByteBuffer(long offset, int length) { return MemoryUtil.getByteBuffer(offset, length, ByteOrder.BIG_ENDIAN); } }
public int ttl() { return MemoryUtil.getInt(peer + TTL); }
public static void setInt(long address, int l) { if (Architecture.IS_UNALIGNED) unsafe.putInt(address, l); else putIntByByte(address, l); }