/** {@inheritDoc} */ @Override public int partition() { return PageIdUtils.partId(pageId(link)); }
/** * @param pageId Page ID. * @param statHolder Statistics holder to track IO operations. * @return Page absolute pointer. * @throws IgniteCheckedException If failed. */ protected final long acquirePage(long pageId, IoStatisticsHolder statHolder) throws IgniteCheckedException { assert PageIdUtils.flag(pageId) == FLAG_IDX && PageIdUtils.partId(pageId) == INDEX_PARTITION || PageIdUtils.flag(pageId) == FLAG_DATA && PageIdUtils.partId(pageId) <= MAX_PARTITION_ID : U.hexLong(pageId) + " flag=" + PageIdUtils.flag(pageId) + " part=" + PageIdUtils.partId(pageId); return pageMem.acquirePage(grpId, pageId, statHolder); }
/** {@inheritDoc} */ @Override public long pageOffset(int grpId, long pageId) throws IgniteCheckedException { PageStore store = getStore(grpId, PageIdUtils.partId(pageId)); return store.pageOffset(pageId); }
/** * Extracts partition information from full page ID * * @param fullId page related to some cache * @return pair of cache ID and partition ID */ @NotNull public static GroupPartitionId createCachePartId(@NotNull final FullPageId fullId) { return new GroupPartitionId(fullId.groupId(), PageIdUtils.partId(fullId.pageId())); }
/** * Change page type. * * @param pageId Old page ID. * @param type New page type. * @return Changed page ID. */ public static long changeType(long pageId, byte type) { return pageId(partId(pageId), type, pageIndex(pageId)); }
/** * @param pageId Page id. */ public static String toDetailString(long pageId) { return "pageId=" + pageId + "(offset=" + itemId(pageId) + ", flags=" + Integer.toBinaryString(flag(pageId)) + ", partId=" + partId(pageId) + ", index=" + pageIndex(pageId) + ")" ; }
/** * @param io Row IO. * @param pageAddr Page address. * @param idx Item index. * @return {@code True} if row passes the filter. */ private boolean applyFilter(H2RowLinkIO io, long pageAddr, int idx) { assert filter != null; return filter.applyPartition(PageIdUtils.partId(pageId(io.getLink(pageAddr, idx)))); }
/** * @param link Link. * @param mvccCrdVer Mvcc coordinator version. * @param mvccCntr Mvcc counter. * @param mvccOpCntr Mvcc operation counter. * @return Row. * @throws IgniteCheckedException If failed. */ public GridH2Row getMvccRow(long link, long mvccCrdVer, long mvccCntr, int mvccOpCntr) throws IgniteCheckedException { int partId = PageIdUtils.partId(PageIdUtils.pageId(link)); MvccDataRow row = new MvccDataRow( cctx.group(), 0, link, partId, null, mvccCrdVer, mvccCntr, mvccOpCntr, true ); return rowDesc.createRow(row); } }
/** * @param record page snapshot record to handle. */ private void registerPageSnapshot(PageSnapshot record) { FullPageId fullPageId = record.fullPageId(); long pageId = fullPageId.pageId(); incrementStat(getPageType(record), record, pageSnapshotTypes); final int idx = PageIdUtils.pageIndex(pageId); final String idxAsStr = idx <= 100 ? Integer.toString(idx) : ">100"; incrementStat(idxAsStr, record, pageSnapshotIndexes); incrementStat(fullPageId.groupId(), record, pageSnapshotCacheGrp); incrementStat(PageIdUtils.partId(pageId), record, pageSnapshotPartId); }
@Override public void onPartitionDestroyed(int grpId, int partId, int tag) throws IgniteCheckedException { super.onPartitionDestroyed(grpId, partId, tag); cleanupPages(fullPageId -> fullPageId.groupId() == grpId && PageIdUtils.partId(fullPageId.pageId()) == partId); } };
/** {@inheritDoc} */ @Override public void insertDataRow(CacheDataRow row, IoStatisticsHolder statHolder) throws IgniteCheckedException { super.insertDataRow(row, statHolder); assert row.key().partition() == PageIdUtils.partId(row.link()) : "Constructed a link with invalid partition ID [partId=" + row.key().partition() + ", link=" + U.hexLong(row.link()) + ']'; }
/** * @param pageId Page id. * @param pageSize Page size. * @return Page id of tracking page which set pageId belongs to. */ public long trackingPageFor(long pageId, int pageSize) { assert PageIdUtils.pageIndex(pageId) > 0; int pageIdx = ((PageIdUtils.pageIndex(pageId) - COUNT_OF_EXTRA_PAGE) / countOfPageToTrack(pageSize)) * countOfPageToTrack(pageSize) + COUNT_OF_EXTRA_PAGE; long trackingPageId = PageIdUtils.pageId(PageIdUtils.partId(pageId), PageIdUtils.flag(pageId), pageIdx); assert PageIdUtils.pageIndex(trackingPageId) <= PageIdUtils.pageIndex(pageId); return trackingPageId; }
assert seg.writeLock().isHeldByCurrentThread(); int tag = seg.partGeneration(grpId, PageIdUtils.partId(pageId));
int partId = PageIdUtils.partId(pageId);
partGeneration( fullPageId.groupId(), PageIdUtils.partId(fullPageId.pageId())
/** * @param pageStore Page store. * @param cacheId Cache id. * @param page Page. */ private void eraseDataFromDisk( FilePageStoreManager pageStore, int cacheId, FullPageId page ) throws IgniteCheckedException, IOException { PageStore store = pageStore.getStore( cacheId, PageIdUtils.partId(page.pageId()) ); FilePageStore filePageStore = (FilePageStore)store; FileIO fileIO = U.field(filePageStore, "fileIO"); long size = fileIO.size(); fileIO.writeFully(ByteBuffer.allocate((int)size - filePageStore.headerSize()), filePageStore.headerSize()); fileIO.force(); }
/** * Will preserve crc in buffer if keepCrc is true. * * @param cacheId Cache ID. * @param pageId Page ID. * @param pageBuf Page buffer. * @param keepCrc Keep CRC flag. * @throws IgniteCheckedException If failed. */ public void read(int cacheId, long pageId, ByteBuffer pageBuf, boolean keepCrc) throws IgniteCheckedException { PageStore store = getStore(cacheId, PageIdUtils.partId(pageId)); try { store.read(pageId, pageBuf, keepCrc); assert keepCrc || PageIO.getCrc(pageBuf) == 0: store.size() - store.pageOffset(pageId); cctx.kernalContext().compress().decompressPage(pageBuf, store.getPageSize()); } catch (StorageException e) { cctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); throw e; } }
final long pageId = PageIdUtils.pageId(row.link); final int partition = PageIdUtils.partId(pageId);
if (partGen < partGeneration(fullId.groupId(), PageIdUtils.partId(fullId.pageId()))) return refreshOutdatedPage(this, fullId.groupId(), fullId.pageId(), true);