/** * @param pageAddr Page address. * @param crc Checksum. */ public static void setCrc(long pageAddr, int crc) { PageUtils.putInt(pageAddr, CRC_OFF, crc); }
/** * Sets last allocated pages count, used to save and observe previous allocated count * * @param pageAddr Meta Page address. * @param pageCnt Last allocated pages count to set */ public void setLastAllocatedPageCount(final long pageAddr, final int pageCnt) { PageUtils.putInt(pageAddr, LAST_PAGE_COUNT_OFF, pageCnt); }
/** * Sets MVCC operation counter value. * * @param pageAddr Page address. * @param dataOff Data offset. * @param opCntr MVCC counter value. */ public void mvccOperationCounter(long pageAddr, int dataOff, int opCntr) { long addr = pageAddr + dataOff; PageUtils.putInt(addr, 16, opCntr); }
/** * Sets MVCC new operation counter value. * * @param pageAddr Page address. * @param dataOff Data offset. * @param opCntr MVCC operation counter value. */ public void newMvccOperationCounter(long pageAddr, int dataOff, int opCntr) { long addr = pageAddr + dataOff; // Skip xid_min. addr += 20; PageUtils.putInt(addr, 16, opCntr); }
/** * @param pageAddr Page address. * @param pageCnt Last page count. */ public boolean setCandidatePageCount(long pageAddr, int pageCnt) { if (getCandidatePageCount(pageAddr) == pageCnt) return false; PageUtils.putInt(pageAddr, CANDIDATE_PAGE_COUNT_OFF, pageCnt); return true; }
/** * @param addr Address. * @param mvccCrd Mvcc coordinator. * @param mvccCntr Mvcc counter. */ private void updateVersion(long addr, long mvccCrd, long mvccCntr, int mvccOpCntr) { PageUtils.putLong(addr, 0, mvccCrd); PageUtils.putLong(addr, 8, mvccCntr); PageUtils.putInt(addr, 16, mvccOpCntr); }
/** * Marks row removed. * * @param addr Address. * @param mvccCrd Mvcc coordinator. * @param mvccCntr Mvcc counter. */ private void updateNewVersion(long addr, long mvccCrd, long mvccCntr, int mvccOpCntr) { // Skip xid_min. addr += 20; PageUtils.putLong(addr, 0, mvccCrd); PageUtils.putLong(addr, 8, mvccCntr); PageUtils.putInt(addr, 16, mvccOpCntr); }
/** * @param addr Write address. * @param type Object type. * @param valBytes Value bytes array. * @param valOff Value bytes array offset. * @return Offset shift compared to initial address. */ public static int putValue(long addr, byte type, byte[] valBytes, int valOff) { int off = 0; PageUtils.putInt(addr, off, valBytes.length); off += 4; PageUtils.putByte(addr, off, type); off++; PageUtils.putBytes(addr, off, valBytes, valOff); off += valBytes.length - valOff; return off; }
/** {@inheritDoc} */ @Override public void storeByOffset(long pageAddr, int off, PendingRow row) throws IgniteCheckedException { assert row.link != 0; assert row.expireTime != 0; PageUtils.putLong(pageAddr, off, row.expireTime); PageUtils.putLong(pageAddr, off + 8, row.link); if (storeCacheId()) { assert row.cacheId != CU.UNDEFINED_CACHE_ID; PageUtils.putInt(pageAddr, off + 16, row.cacheId); } }
/** {@inheritDoc} */ @Override public void storeByOffset(long pageAddr, int off, PendingRow row) throws IgniteCheckedException { assert row.link != 0; assert row.expireTime != 0; PageUtils.putLong(pageAddr, off, row.expireTime); PageUtils.putLong(pageAddr, off + 8, row.link); if (storeCacheId()) { assert row.cacheId != CU.UNDEFINED_CACHE_ID; PageUtils.putInt(pageAddr, off + 16, row.cacheId); } }
/** * @param addr Write address. * @param ver Version to write. * @param allowNull Is {@code null} version allowed. */ public static void write(long addr, GridCacheVersion ver, boolean allowNull) { if (ver == null) { if (allowNull) PageUtils.putByte(addr, 0, NULL_PROTO_VER); else throw new IllegalStateException("Cache version is null"); } else if (ver instanceof GridCacheVersionEx) { byte protoVer = 2; // Version of serialization protocol. PageUtils.putByte(addr, 0, protoVer); PageUtils.putInt(addr, 1, ver.topologyVersion()); PageUtils.putInt(addr, 5, ver.nodeOrderAndDrIdRaw()); PageUtils.putLong(addr, 9, ver.order()); PageUtils.putInt(addr, 17, ver.conflictVersion().topologyVersion()); PageUtils.putInt(addr, 21, ver.conflictVersion().nodeOrderAndDrIdRaw()); PageUtils.putLong(addr, 25, ver.conflictVersion().order()); } else { byte protoVer = 1; // Version of serialization protocol. PageUtils.putByte(addr, 0, protoVer); PageUtils.putInt(addr, 1, ver.topologyVersion()); PageUtils.putInt(addr, 5, ver.nodeOrderAndDrIdRaw()); PageUtils.putLong(addr, 9, ver.order()); } }
/** {@inheritDoc} */ @Override protected void writeRowData( long pageAddr, int dataOff, int payloadSize, MetastorageDataRow row, boolean newRow ) throws IgniteCheckedException { long addr = pageAddr + dataOff; if (newRow) PageUtils.putShort(addr, 0, (short)payloadSize); PageUtils.putInt(addr, 2, row.value().length); PageUtils.putBytes(addr, 6, row.value()); }
/** {@inheritDoc} */ @Override public final void storeByOffset(long pageAddr, int off, CacheSearchRow row) { assert row.link() != 0; PageUtils.putLong(pageAddr, off, row.link()); off += 8; PageUtils.putInt(pageAddr, off, row.hash()); off += 4; if (storeCacheId()) { assert row.cacheId() != CU.UNDEFINED_CACHE_ID : row; PageUtils.putInt(pageAddr, off, row.cacheId()); off += 4; } if (storeMvccVersion()) { long mvccCrd = row.mvccCoordinatorVersion(); long mvccCntr = row.mvccCounter(); int opCntr = row.mvccOperationCounter(); assert mvccVersionIsValid(mvccCrd, mvccCntr, opCntr); PageUtils.putLong(pageAddr, off, mvccCrd); off += 8; PageUtils.putLong(pageAddr, off, mvccCntr); off += 8; PageUtils.putInt(pageAddr, off, opCntr); } }
/** {@inheritDoc} */ @Override public void store(long dstPageAddr, int dstIdx, BPlusIO<PendingRow> srcIo, long srcPageAddr, int srcIdx) throws IgniteCheckedException { int dstOff = offset(dstIdx); long link = ((PendingRowIO)srcIo).getLink(srcPageAddr, srcIdx); long expireTime = ((PendingRowIO)srcIo).getExpireTime(srcPageAddr, srcIdx); PageUtils.putLong(dstPageAddr, dstOff, expireTime); PageUtils.putLong(dstPageAddr, dstOff + 8, link); if (storeCacheId()) { int cacheId = ((PendingRowIO)srcIo).getCacheId(srcPageAddr, srcIdx); assert cacheId != CU.UNDEFINED_CACHE_ID; PageUtils.putInt(dstPageAddr, dstOff + 16, cacheId); } }
/** {@inheritDoc} */ @Override public void storeByOffset(long pageAddr, int off, CacheSearchRow row) { assert row.link() != 0; PageUtils.putLong(pageAddr, off, row.link()); off += 8; PageUtils.putInt(pageAddr, off, row.hash()); off += 4; if (storeCacheId()) { assert row.cacheId() != CU.UNDEFINED_CACHE_ID; PageUtils.putInt(pageAddr, off, row.cacheId()); off += 4; } if (storeMvccVersion()) { long mvccCrdVer = row.mvccCoordinatorVersion(); long mvccCntr = row.mvccCounter(); int mvccOpCntr = row.mvccOperationCounter(); assert mvccVersionIsValid(mvccCrdVer, mvccCntr, mvccOpCntr); PageUtils.putLong(pageAddr, off, mvccCrdVer); off += 8; PageUtils.putLong(pageAddr, off, mvccCntr); off += 8; PageUtils.putInt(pageAddr, off, mvccOpCntr); off += 4; // Lock version the same as mvcc version, a new row is // always locked by Tx, in scope of which it was created. PageUtils.putLong(pageAddr, off, mvccCrdVer); off += 8; PageUtils.putLong(pageAddr, off, mvccCntr); } }
/** {@inheritDoc} */ @Override public void store(long dstPageAddr, int dstIdx, BPlusIO<PendingRow> srcIo, long srcPageAddr, int srcIdx) throws IgniteCheckedException { int dstOff = offset(dstIdx); long link = ((PendingRowIO)srcIo).getLink(srcPageAddr, srcIdx); long expireTime = ((PendingRowIO)srcIo).getExpireTime(srcPageAddr, srcIdx); PageUtils.putLong(dstPageAddr, dstOff, expireTime); PageUtils.putLong(dstPageAddr, dstOff + 8, link); if (storeCacheId()) { int cacheId = ((PendingRowIO)srcIo).getCacheId(srcPageAddr, srcIdx); assert cacheId != CU.UNDEFINED_CACHE_ID; PageUtils.putInt(dstPageAddr, dstOff + 16, cacheId); } }
/** * @param row Row. * @param pageAddr Page address. * @param off Offset. * @param storeMvcc {@code True} to store mvcc data. */ static void storeRow(GridH2Row row, long pageAddr, int off, boolean storeMvcc) { assert row.link() != 0; PageUtils.putLong(pageAddr, off, row.link()); if (storeMvcc) { long mvccCrdVer = row.mvccCoordinatorVersion(); long mvccCntr = row.mvccCounter(); int mvccOpCntr = row.mvccOperationCounter(); assert MvccUtils.mvccVersionIsValid(mvccCrdVer, mvccCntr, mvccOpCntr); PageUtils.putLong(pageAddr, off + 8, mvccCrdVer); PageUtils.putLong(pageAddr, off + 16, mvccCntr); PageUtils.putInt(pageAddr, off + 24, mvccOpCntr); } }
PageUtils.putInt(dstPageAddr, dstOff + 24, mvccOpCntr);
PageUtils.putInt(addr, 16, row.mvccOperationCounter() | (row.mvccTxState() << MVCC_HINTS_BIT_OFF) | (keyAbsentBeforeFlag << MVCC_KEY_ABSENT_BEFORE_OFF)); PageUtils.putInt(addr, 36, row.newMvccOperationCounter() | (row.newMvccTxState() << MVCC_HINTS_BIT_OFF) | (keyAbsentBeforeFlag << MVCC_KEY_ABSENT_BEFORE_OFF)); PageUtils.putInt(addr, 0, row.cacheId());