private long findHead(long address) { while (!isHead(address)) { address = storage.readLong(address + ELEMENT_HEADER_NEXT_OFFSET); } return address; }
@Override public ByteBuffer readBinaryValue(long chain) { // first get total element size and allocate buffer long element = chain + this.totalChainHeaderSize; int totalLength = DETACHED_CONTIGUOUS_CHAIN_HEADER_SIZE; do { totalLength += ELEMENT_HEADER_SIZE + readElementLength(element); element = storage.readLong(element + ELEMENT_HEADER_NEXT_OFFSET); } while (element != chain); final ByteBuffer detachedContiguousBuffer = ByteBuffer.allocate(totalLength); // one way for layers above to extract encoding is to put the encoding of the chain address in the value detachedContiguousBuffer.putLong(chain); // now add the elements to the buffer element = chain + this.totalChainHeaderSize; do { final int startPosition = detachedContiguousBuffer.position(); detachedContiguousBuffer.put(storage.readBuffer(element, ELEMENT_HEADER_SIZE + readElementLength(element))); detachedContiguousBuffer.mark(); detachedContiguousBuffer.putLong(startPosition + ELEMENT_HEADER_NEXT_OFFSET, -1L); detachedContiguousBuffer.reset(); element = storage.readLong(element + ELEMENT_HEADER_NEXT_OFFSET); } while (element != chain); return (ByteBuffer)detachedContiguousBuffer.flip(); }
private long parent(long p) { return storage.readLong(p + (6 * SIZE_T_SIZE)); }
private long forward(long p) { return storage.readLong(p + (2 * SIZE_T_SIZE)); }
private long prevFoot(long p) { return storage.readLong(p); }
private long head(long p) { return storage.readLong(p + SIZE_T_SIZE); }
private long backward(long p) { return storage.readLong(p + (3 * SIZE_T_SIZE)); }
private long head(long p) { return storage.readLong(p + SIZE_T_SIZE); }
private long forward(long p) { return storage.readLong(p + (2 * SIZE_T_SIZE)); }
private long backward(long p) { return storage.readLong(p + (3 * SIZE_T_SIZE)); }
private long prevFoot(long p) { return storage.readLong(p); }
private long parent(long p) { return storage.readLong(p + (6 * SIZE_T_SIZE)); }
@FindbugsSuppressWarnings("ICAST_INTEGER_MULTIPLY_CAST_TO_LONG") private long child(long p, int index) { return storage.readLong(p + ((4 + index) * SIZE_T_SIZE)); }
@FindbugsSuppressWarnings("ICAST_INTEGER_MULTIPLY_CAST_TO_LONG") private long child(long p, int index) { return storage.readLong(p + ((4 + index) * SIZE_T_SIZE)); }