本文整理汇总了Java中org.apache.ignite.internal.util.GridUnsafe.bufferAddress方法的典型用法代码示例。如果您正苦于以下问题:Java GridUnsafe.bufferAddress方法的具体用法?Java GridUnsafe.bufferAddress怎么用?Java GridUnsafe.bufferAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.internal.util.GridUnsafe
的用法示例。
在下文中一共展示了GridUnsafe.bufferAddress方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPageType
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
* @param record page snapshot record.
* @return string identifier of page (IO) type.
*/
private static String getPageType(PageSnapshot record) {
byte[] pageData = record.pageData();
ByteBuffer buf = ByteBuffer.allocateDirect(pageData.length);
try {
buf.order(ByteOrder.nativeOrder());
buf.put(pageData);
long addr = GridUnsafe.bufferAddress(buf);
int type = PageIO.getType(addr);
int ver = PageIO.getVersion(addr);
return PageIO.getPageIO(type, ver).getClass().getSimpleName();
}
catch (IgniteCheckedException ignored) {
}
finally {
GridUnsafe.cleanDirectBuffer(buf);
}
return "";
}
示例2: toString
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public String toString() {
ByteBuffer buf = ByteBuffer.allocateDirect(pageData.length);
buf.order(ByteOrder.nativeOrder());
buf.put(pageData);
long addr = GridUnsafe.bufferAddress(buf);
try {
return "PageSnapshot [fullPageId = " + fullPageId() + ", page = [\n"
+ PageIO.printPage(addr, pageData.length)
+ "],\nsuper = ["
+ super.toString() + "]]";
}
catch (IgniteCheckedException ignored) {
return "Error during call'toString' of PageSnapshot [fullPageId=" + fullPageId() +
", pageData = " + Arrays.toString(pageData) + ", super=" + super.toString() + "]";
}
finally {
GridUnsafe.cleanDirectBuffer(buf);
}
}
示例3: copyMemory
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
* @param src Source.
* @param srcOff Source offset in bytes.
* @param dst Destination.
* @param dstOff Destination offset in bytes.
* @param cnt Bytes count to copy.
*/
public static void copyMemory(ByteBuffer src, long srcOff, ByteBuffer dst, long dstOff, long cnt) {
byte[] srcArr = src.hasArray() ? src.array() : null;
byte[] dstArr = dst.hasArray() ? dst.array() : null;
long srcArrOff = src.hasArray() ? src.arrayOffset() + GridUnsafe.BYTE_ARR_OFF : 0;
long dstArrOff = dst.hasArray() ? dst.arrayOffset() + GridUnsafe.BYTE_ARR_OFF : 0;
long srcPtr = src.isDirect() ? GridUnsafe.bufferAddress(src) : 0;
long dstPtr = dst.isDirect() ? GridUnsafe.bufferAddress(dst) : 0;
GridUnsafe.copyMemory(srcArr, srcPtr + srcArrOff + srcOff, dstArr, dstPtr + dstArrOff + dstOff, cnt);
}