@Test public void testDereferenceLeafOfTree() throws TTIOException { int[] offsets = new int[5]; IBackendReader reader = getFakedStructure(offsets); long key = BucketReadTrx.dereferenceLeafOfTree(reader, 1, 0)[IConstants.INDIRECT_BUCKET_COUNT.length]; assertEquals(6, key); offsets[4] = 127; reader = getFakedStructure(offsets); key = BucketReadTrx.dereferenceLeafOfTree(reader, 1, 127)[IConstants.INDIRECT_BUCKET_COUNT.length]; assertEquals(133, key); offsets[3] = 1; offsets[4] = 0; reader = getFakedStructure(offsets); key = BucketReadTrx.dereferenceLeafOfTree(reader, 1, 128)[IConstants.INDIRECT_BUCKET_COUNT.length]; assertEquals(7, key); offsets[3] = 127; offsets[4] = 127; reader = getFakedStructure(offsets); key = BucketReadTrx.dereferenceLeafOfTree(reader, 1, 16383)[IConstants.INDIRECT_BUCKET_COUNT.length]; assertEquals(260, key); offsets[2] = 1; offsets[3] = 0; offsets[4] = 0; reader = getFakedStructure(offsets); key = BucketReadTrx.dereferenceLeafOfTree(reader, 1, 16384)[IConstants.INDIRECT_BUCKET_COUNT.length]; assertEquals(7, key); offsets[2] = 127; offsets[3] = 127; offsets[4] = 127; reader = getFakedStructure(offsets); key = BucketReadTrx.dereferenceLeafOfTree(reader, 1, 2097151)[IConstants.INDIRECT_BUCKET_COUNT.length]; assertEquals(387, key); offsets[1] = 1; offsets[2] = 0; offsets[3] = 0; offsets[4] = 0; reader = getFakedStructure(offsets); key = BucketReadTrx.dereferenceLeafOfTree(reader, 1, 2097152)[IConstants.INDIRECT_BUCKET_COUNT.length]; assertEquals(7, key); offsets[1] = 127; offsets[2] = 127; offsets[3] = 127; offsets[4] = 127; reader = getFakedStructure(offsets); key = BucketReadTrx.dereferenceLeafOfTree(reader, 1, 268435455)[IConstants.INDIRECT_BUCKET_COUNT.length]; assertEquals(514, key); offsets[0] = 1; offsets[1] = 0; offsets[2] = 0; offsets[3] = 0; offsets[4] = 0; reader = getFakedStructure(offsets); key = BucketReadTrx.dereferenceLeafOfTree(reader, 1, 268435456)[IConstants.INDIRECT_BUCKET_COUNT.length]; assertEquals(7, key); offsets[0] = 127; offsets[1] = 127; offsets[2] = 127; offsets[3] = 127; offsets[4] = 127; reader = getFakedStructure(offsets); key = BucketReadTrx.dereferenceLeafOfTree(reader, 1, 34359738367l)[IConstants.INDIRECT_BUCKET_COUNT.length]; assertEquals(641, key); offsets[0] = 0; reader = getFakedStructure(offsets); key = BucketReadTrx.dereferenceLeafOfTree(reader, 1, 34359738367l)[IConstants.INDIRECT_BUCKET_COUNT.length]; assertEquals(-1, key); }
protected static final long[] dereferenceLeafOfTree(final IBackendReader pReader, final long pStartKey, final long pSeqBucketKey) throws TTIOException { final long[] orderNumber = getOrderNumbers(pSeqBucketKey); final long[] keys = new long[IConstants.INDIRECT_BUCKET_COUNT.length + 1]; IndirectBucket bucket = null; keys[0] = pStartKey; for (int level = 0; level < orderNumber.length; level++) { bucket = (IndirectBucket)pReader.read(keys[level]); keys[level + 1] = bucket.getReferenceKeys()[dataBucketOffset(orderNumber[level])]; if (keys[level + 1] == 0) { Arrays.fill(keys, -1); return keys; } } return keys; }
BucketReadTrx implements IBucketReadTrx { protected static final long[] dereferenceLeafOfTree(final IBackendReader pReader, final long pStartKey, final long pSeqBucketKey) throws TTIOException { final long[] orderNumber = getOrderNumbers(pSeqBucketKey); final long[] keys = new long[IConstants.INDIRECT_BUCKET_COUNT.length + 1]; IndirectBucket bucket = null; keys[0] = pStartKey; for (int level = 0; level < orderNumber.length; level++) { bucket = (IndirectBucket)pReader.read(keys[level]); keys[level + 1] = bucket.getReferenceKeys()[dataBucketOffset(orderNumber[level])]; if (keys[level + 1] == 0) { Arrays.fill(keys, -1); return keys; } } return keys; } }
BucketReadTrx implements IBucketReadTrx { protected static final long[] dereferenceLeafOfTree(final IBackendReader pReader, final long pStartKey, final long pSeqBucketKey) throws TTIOException { final long[] orderNumber = getOrderNumbers(pSeqBucketKey); final long[] keys = new long[IConstants.INDIRECT_BUCKET_COUNT.length + 1]; IndirectBucket bucket = null; keys[0] = pStartKey; for (int level = 0; level < orderNumber.length; level++) { bucket = (IndirectBucket)pReader.read(keys[level]); keys[level + 1] = bucket.getReferenceKeys()[dataBucketOffset(orderNumber[level])]; if (keys[level + 1] == 0) { Arrays.fill(keys, -1); return keys; } } return keys; } protected  BucketReadTrx(final ISession pSession, final UberBucket pUberBucket,
        final RevisionRootBucket pRevBucket, final MetaBucket pMetaBucket, final IBackendReader pReader); }
BucketReadTrx implements IBucketReadTrx { protected static final long[] dereferenceLeafOfTree(final IBackendReader pReader, final long pStartKey, final long pSeqBucketKey) throws TTIOException { final long[] orderNumber = getOrderNumbers(pSeqBucketKey); final long[] keys = new long[IConstants.INDIRECT_BUCKET_COUNT.length + 1]; IndirectBucket bucket = null; keys[0] = pStartKey; for (int level = 0; level < orderNumber.length; level++) { bucket = (IndirectBucket)pReader.read(keys[level]); keys[level + 1] = bucket.getReferenceKeys()[dataBucketOffset(orderNumber[level])]; if (keys[level + 1] == 0) { Arrays.fill(keys, -1); return keys; } } return keys; } protected  BucketReadTrx(final ISession pSession, final UberBucket pUberBucket,
        final RevisionRootBucket pRevBucket, final MetaBucket pMetaBucket, final IBackendReader pReader); IData getData(final long pDataKey); boolean close(); long getRevision(); @Override boolean isClosed(); @Override MetaBucket getMetaBucket(); @Override String toString(); }
BucketReadTrx implements IBucketReadTrx { protected static final long[] dereferenceLeafOfTree(final IBackendReader pReader, final long pStartKey, final long pSeqBucketKey) throws TTIOException { final long[] orderNumber = getOrderNumbers(pSeqBucketKey); final long[] keys = new long[IConstants.INDIRECT_BUCKET_COUNT.length + 1]; IndirectBucket bucket = null; keys[0] = pStartKey; for (int level = 0; level < orderNumber.length; level++) { bucket = (IndirectBucket)pReader.read(keys[level]); keys[level + 1] = bucket.getReferenceKeys()[dataBucketOffset(orderNumber[level])]; if (keys[level + 1] == 0) { Arrays.fill(keys, -1); return keys; } } return keys; } protected  BucketReadTrx(final ISession pSession, final UberBucket pUberBucket,
        final RevisionRootBucket pRevBucket, final MetaBucket pMetaBucket, final IBackendReader pReader); IData getData(final long pDataKey); boolean close(); long getRevision(); @Override boolean isClosed(); @Override MetaBucket getMetaBucket(); @Override String toString();  }