Search in sources :

Example 1 with BplusMetaIo

use of org.apache.ignite.internal.pagememory.tree.io.BplusMetaIo in project ignite-3 by apache.

the class BplusTree method treeMeta.

/**
 * Returns tree meta data.
 *
 * @param metaPageAddr Meta page address. If equals {@code 0}, it means that we should do read lock on meta page and get meta page
 *      address. Otherwise we will not do the lock and will use the given address.
 * @throws IgniteInternalCheckedException If failed.
 */
private TreeMetaData treeMeta(final long metaPageAddr) throws IgniteInternalCheckedException {
    TreeMetaData meta0 = treeMeta;
    if (meta0 != null) {
        return meta0;
    }
    final long metaPage = acquirePage(metaPageId);
    try {
        long pageAddr;
        if (metaPageAddr == 0L) {
            pageAddr = readLock(metaPageId, metaPage);
            assert pageAddr != 0 : "Failed to read lock meta page [metaPageId=" + hexLong(metaPageId) + ']';
        } else {
            pageAddr = metaPageAddr;
        }
        try {
            BplusMetaIo io = metaIos.forPage(pageAddr);
            int rootLvl = io.getRootLevel(pageAddr);
            long rootId = io.getFirstPageId(pageAddr, rootLvl);
            treeMeta = meta0 = new TreeMetaData(rootLvl, rootId);
        } finally {
            if (metaPageAddr == 0L) {
                readUnlock(metaPageId, metaPage, pageAddr);
            }
        }
    } finally {
        releasePage(metaPageId, metaPage);
    }
    return meta0;
}
Also used : BplusMetaIo(org.apache.ignite.internal.pagememory.tree.io.BplusMetaIo)

Example 2 with BplusMetaIo

use of org.apache.ignite.internal.pagememory.tree.io.BplusMetaIo in project ignite-3 by apache.

the class BplusTree method getFirstPageIds.

/**
 * Returns first page IDs.
 *
 * @param pageAddr Meta page address.
 */
protected Iterable<Long> getFirstPageIds(long pageAddr) {
    List<Long> res = new ArrayList<>();
    BplusMetaIo mio = metaIos.forPage(pageAddr);
    for (int lvl = mio.getRootLevel(pageAddr); lvl >= 0; lvl--) {
        res.add(mio.getFirstPageId(pageAddr, lvl));
    }
    return res;
}
Also used : BplusMetaIo(org.apache.ignite.internal.pagememory.tree.io.BplusMetaIo) IgniteUtils.hexLong(org.apache.ignite.internal.util.IgniteUtils.hexLong) AtomicLong(java.util.concurrent.atomic.AtomicLong) ArrayList(java.util.ArrayList)

Aggregations

BplusMetaIo (org.apache.ignite.internal.pagememory.tree.io.BplusMetaIo)2 ArrayList (java.util.ArrayList)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 IgniteUtils.hexLong (org.apache.ignite.internal.util.IgniteUtils.hexLong)1