/** * @param pageAddr Page address. * @return Rotated page ID part. */ public static int getRotatedIdPart(long pageAddr) { return PageUtils.getUnsignedByte(pageAddr, ROTATED_ID_PART_OFF); }
/** {@inheritDoc} */ @Override protected int compare(final BPlusIO<IndexItem> io, final long pageAddr, final int idx, final IndexItem row) throws IgniteCheckedException { final int off = ((IndexIO)io).getOffset(pageAddr, idx); int shift = 0; // Compare index names. final int len = PageUtils.getUnsignedByte(pageAddr, off + shift); shift += BYTE_LEN; for (int i = 0; i < len && i < row.idxName.length; i++) { final int cmp = Byte.compare(PageUtils.getByte(pageAddr, off + i + shift), row.idxName[i]); if (cmp != 0) return cmp; } return Integer.compare(len, row.idxName.length); }
/** * Read row from buffer. * * @param pageAddr Page address. * @param off Offset. * @return Read row. */ private static IndexItem readRow(final long pageAddr, int off) { // Index name length. final int len = PageUtils.getUnsignedByte(pageAddr, off) & 0xFF; off++; // Index name. final byte[] idxName = PageUtils.getBytes(pageAddr, off, len); off += len; // Page ID. final long pageId = PageUtils.getLong(pageAddr, off); return new IndexItem(idxName, pageId); }
/** * Copy row data. * * @param dstPageAddr Destination page address. * @param dstOff Destination buf offset. * @param srcPageAddr Source page address. * @param srcOff Src buf offset. */ private static void storeRow( final long dstPageAddr, int dstOff, final long srcPageAddr, int srcOff ) { // Index name length. final int len = PageUtils.getUnsignedByte(srcPageAddr, srcOff); srcOff++; PageUtils.putUnsignedByte(dstPageAddr, dstOff, len); dstOff++; PageHandler.copyMemory(srcPageAddr, srcOff, dstPageAddr, dstOff, len); srcOff += len; dstOff += len; // Page ID. PageUtils.putLong(dstPageAddr, dstOff, PageUtils.getLong(srcPageAddr, srcOff)); }
/** * @param pageAddr Page address. * @return Rotated page ID part. */ public static int getRotatedIdPart(long pageAddr) { return PageUtils.getUnsignedByte(pageAddr, ROTATED_ID_PART_OFF); }
/** {@inheritDoc} */ @Override protected int compare(final BPlusIO<IndexItem> io, final long pageAddr, final int idx, final IndexItem row) throws IgniteCheckedException { final int off = ((IndexIO)io).getOffset(pageAddr, idx); int shift = 0; // Compare index names. final int len = PageUtils.getUnsignedByte(pageAddr, off + shift); shift += BYTE_LEN; for (int i = 0; i < len && i < row.idxName.length; i++) { final int cmp = Byte.compare(PageUtils.getByte(pageAddr, off + i + shift), row.idxName[i]); if (cmp != 0) return cmp; } return Integer.compare(len, row.idxName.length); }
/** * Read row from buffer. * * @param pageAddr Page address. * @param off Offset. * @return Read row. */ private static IndexItem readRow(final long pageAddr, int off) { // Index name length. final int len = PageUtils.getUnsignedByte(pageAddr, off) & 0xFF; off++; // Index name. final byte[] idxName = PageUtils.getBytes(pageAddr, off, len); off += len; // Page ID. final long pageId = PageUtils.getLong(pageAddr, off); return new IndexItem(idxName, pageId); }
/** * Copy row data. * * @param dstPageAddr Destination page address. * @param dstOff Destination buf offset. * @param srcPageAddr Source page address. * @param srcOff Src buf offset. */ private static void storeRow( final long dstPageAddr, int dstOff, final long srcPageAddr, int srcOff ) { // Index name length. final int len = PageUtils.getUnsignedByte(srcPageAddr, srcOff); srcOff++; PageUtils.putUnsignedByte(dstPageAddr, dstOff, len); dstOff++; PageHandler.copyMemory(srcPageAddr, srcOff, dstPageAddr, dstOff, len); srcOff += len; dstOff += len; // Page ID. PageUtils.putLong(dstPageAddr, dstOff, PageUtils.getLong(srcPageAddr, srcOff)); }