本文整理汇总了Java中org.apache.ignite.internal.util.GridUnsafe.putLong方法的典型用法代码示例。如果您正苦于以下问题:Java GridUnsafe.putLong方法的具体用法?Java GridUnsafe.putLong怎么用?Java GridUnsafe.putLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.internal.util.GridUnsafe
的用法示例。
在下文中一共展示了GridUnsafe.putLong方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: borrowFreePage
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
* @return Relative pointer to a free page that was borrowed from the allocated pool.
*/
private long borrowFreePage() {
while (true) {
long freePageRelPtrMasked = GridUnsafe.getLong(freePageListPtr);
long freePageRelPtr = freePageRelPtrMasked & ADDRESS_MASK;
if (freePageRelPtr != INVALID_REL_PTR) {
long freePageAbsPtr = absolute(freePageRelPtr);
long nextFreePageRelPtr = GridUnsafe.getLong(freePageAbsPtr) & ADDRESS_MASK;
long cnt = ((freePageRelPtrMasked & COUNTER_MASK) + COUNTER_INC) & COUNTER_MASK;
if (GridUnsafe.compareAndSwapLong(null, freePageListPtr, freePageRelPtrMasked, nextFreePageRelPtr | cnt)) {
GridUnsafe.putLong(freePageAbsPtr, PAGE_MARKER);
return freePageRelPtr;
}
}
else
return INVALID_REL_PTR;
}
}
示例2: unsafeWriteLong
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void unsafeWriteLong(long val) {
long off = GridUnsafe.BYTE_ARR_OFF + pos;
if (BIG_ENDIAN)
GridUnsafe.putLongLE(data, off, val);
else
GridUnsafe.putLong(data, off, val);
shift(8);
}
示例3: serializeCacheSizes
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
* @param cacheSizes Cache sizes: cache Id in shared group mapped to its size. Not null.
* @return Serialized cache sizes or 0-byte length array if map was empty.
*/
public byte[] serializeCacheSizes(Map<Integer, Long> cacheSizes) {
byte[] data = new byte[cacheSizes.size() * ITEM_SIZE];
long off = GridUnsafe.BYTE_ARR_OFF;
for (Map.Entry<Integer, Long> entry : cacheSizes.entrySet()) {
GridUnsafe.putInt(data, off, entry.getKey()); off += CACHE_ID_SIZE;
GridUnsafe.putLong(data, off, entry.getValue()); off += CACHE_SIZE_SIZE;
}
return data;
}
示例4: initNew
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
* @param absPtr Absolute pointer to initialize.
* @param relative Relative pointer to write.
*/
private static void initNew(long absPtr, long relative) {
relative(absPtr, relative);
tempBufferPointer(absPtr, INVALID_REL_PTR);
GridUnsafe.putLong(absPtr, PAGE_MARKER);
GridUnsafe.putInt(absPtr + PAGE_PIN_CNT_OFFSET, 0);
}
示例5: setKeyAt
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
* @param index Entry index.
* @param grpId Cache group ID to write.
* @param pageId Page ID to write.
*/
private void setKeyAt(int index, int grpId, long pageId) {
long base = entryBase(index);
GridUnsafe.putInt(base, grpId);
GridUnsafe.putLong(base + 8, pageId);
}
示例6: releaseFreePage
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
* @param pageId Page ID to release.
*/
private void releaseFreePage(long pageId) {
int pageIdx = PageIdUtils.pageIndex(pageId);
// Clear out flags and file ID.
long relPtr = PageIdUtils.pageId(0, (byte)0, pageIdx);
Segment seg = segment(pageIdx);
long absPtr = seg.absolute(pageIdx);
// Second, write clean relative pointer instead of page ID.
writePageId(absPtr, relPtr);
// Third, link the free page.
while (true) {
long freePageRelPtrMasked = freePageListHead.get();
long freePageRelPtr = freePageRelPtrMasked & RELATIVE_PTR_MASK;
GridUnsafe.putLong(absPtr, freePageRelPtr);
if (freePageListHead.compareAndSet(freePageRelPtrMasked, relPtr)) {
allocatedPages.decrementAndGet();
return;
}
}
}
示例7: borrowFreePage
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
* @return Relative pointer to a free page that was borrowed from the allocated pool.
*/
private long borrowFreePage() {
while (true) {
long freePageRelPtrMasked = freePageListHead.get();
long freePageRelPtr = freePageRelPtrMasked & ADDRESS_MASK;
if (freePageRelPtr != INVALID_REL_PTR) {
int pageIdx = PageIdUtils.pageIndex(freePageRelPtr);
Segment seg = segment(pageIdx);
long freePageAbsPtr = seg.absolute(pageIdx);
long nextFreePageRelPtr = GridUnsafe.getLong(freePageAbsPtr) & ADDRESS_MASK;
long cnt = ((freePageRelPtrMasked & COUNTER_MASK) + COUNTER_INC) & COUNTER_MASK;
if (freePageListHead.compareAndSet(freePageRelPtrMasked, nextFreePageRelPtr | cnt)) {
GridUnsafe.putLong(freePageAbsPtr, PAGE_MARKER);
allocatedPages.incrementAndGet();
return freePageRelPtr;
}
}
else
return INVALID_REL_PTR;
}
}
示例8: writeLong
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void writeLong(long val) {
lastFinished = buf.remaining() >= 8;
if (lastFinished) {
int pos = buf.position();
GridUnsafe.putLong(heapArr, baseOff + pos, val);
buf.position(pos + 8);
}
}
示例9: writeLong
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
* @param arr Array.
* @param off Offset.
* @param val Value.
*/
public static void writeLong(byte[] arr, int off, long val) {
long pos = GridUnsafe.BYTE_ARR_OFF + off;
if (BIG_ENDIAN)
GridUnsafe.putLongLE(arr, pos, val);
else
GridUnsafe.putLong(arr, pos, val);
}
示例10: writeLongFast
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected void writeLongFast(long val) {
long addr = ptr + pos;
if (BIG_ENDIAN)
GridUnsafe.putLongLE(addr, val);
else
GridUnsafe.putLong(addr, val);
}
示例11: writeLong
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void writeLong(long val) throws IOException {
int writePos = ensure(8);
GridUnsafe.putLong(buf, BYTE_ARR_OFF + writePos, val);
}
示例12: unsafeWriteLong
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void unsafeWriteLong(long val) {
GridUnsafe.putLong(data + pos, val);
shift(8);
}
示例13: writeLongArray
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void writeLongArray(long[] val) {
int cnt = val.length << 3;
ensureCapacity(pos + cnt);
long startPos = data + pos;
for (long item : val) {
GridUnsafe.putLong(startPos, Long.reverseBytes(item));
startPos += 8;
}
shift(cnt);
}
示例14: writeDoubleArray
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void writeDoubleArray(double[] val) {
int cnt = val.length << 3;
ensureCapacity(pos + cnt);
long startPos = data + pos;
for (double item : val) {
GridUnsafe.putLong(startPos, Long.reverseBytes(Double.doubleToLongBits(item)));
startPos += 8;
}
shift(cnt);
}
示例15: PagePool
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
* @param idx Index.
* @param region Region
* @param pagesCntr Pages counter.
*/
protected PagePool(int idx, DirectMemoryRegion region, AtomicInteger pagesCntr) {
this.idx = idx;
this.region = region;
this.pagesCntr = pagesCntr;
long base = (region.address() + 7) & ~0x7;
freePageListPtr = base;
base += 8;
lastAllocatedIdxPtr = base;
base += 8;
// Align page start by
pagesBase = base;
GridUnsafe.putLong(freePageListPtr, INVALID_REL_PTR);
GridUnsafe.putLong(lastAllocatedIdxPtr, 1L);
}