use of org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl in project ignite by apache.
the class FreeListImplSelfTest method createPageMemory.
/**
* @return Page memory.
*/
protected PageMemory createPageMemory(int pageSize, MemoryPolicyConfiguration plcCfg) throws Exception {
PageMemory pageMem = new PageMemoryNoStoreImpl(log, new UnsafeMemoryProvider(log), null, pageSize, plcCfg, new MemoryMetricsImpl(plcCfg), true);
pageMem.start();
return pageMem;
}
use of org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl in project ignite by apache.
the class IgniteCacheDatabaseSharedManager method createPageMemory.
/**
* Creates PageMemory with given size and memory provider.
*
* @param memProvider Memory provider.
* @param memCfg Memory configuartion.
* @param memPlcCfg data region configuration.
* @param memMetrics DataRegionMetrics to collect memory usage metrics.
* @return PageMemory instance.
*/
protected PageMemory createPageMemory(DirectMemoryProvider memProvider, DataStorageConfiguration memCfg, DataRegionConfiguration memPlcCfg, DataRegionMetricsImpl memMetrics, boolean trackable) {
memMetrics.persistenceEnabled(false);
PageMemory pageMem = new PageMemoryNoStoreImpl(log, memProvider, cctx, memCfg.getPageSize(), memPlcCfg, memMetrics, false);
memMetrics.pageMemory(pageMem);
return pageMem;
}
use of org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl in project ignite by apache.
the class CacheDataRowAdapter method initFromLink.
/**
* Read row from data pages.
* Can be called with cctx == null, if cache instance is unknown, but its ID is stored in the data row.
*
* @param grp Cache group.
* @param sharedCtx Shared context.
* @param pageMem Page memory.
* @param rowData Row data.
* @throws IgniteCheckedException If failed.
*/
public final void initFromLink(@Nullable CacheGroupContext grp, GridCacheSharedContext<?, ?> sharedCtx, PageMemory pageMem, RowData rowData) throws IgniteCheckedException {
assert link != 0 : "link";
assert key == null : "key";
CacheObjectContext coctx = grp != null ? grp.cacheObjectContext() : null;
boolean readCacheId = grp == null || grp.storeCacheIdInDataPage();
long nextLink = link;
IncompleteObject<?> incomplete = null;
boolean first = true;
do {
final long pageId = pageId(nextLink);
// Group is null if try evict page, with persistence evictions should be disabled.
assert grp != null || pageMem instanceof PageMemoryNoStoreImpl;
int grpId = grp != null ? grp.groupId() : 0;
final long page = pageMem.acquirePage(grpId, pageId);
try {
// Non-empty data page must not be recycled.
long pageAddr = pageMem.readLock(grpId, pageId, page);
assert pageAddr != 0L : nextLink;
try {
DataPageIO io = DataPageIO.VERSIONS.forPage(pageAddr);
DataPagePayload data = io.readPayload(pageAddr, itemId(nextLink), pageMem.pageSize());
nextLink = data.nextLink();
if (first) {
if (nextLink == 0) {
// Fast path for a single page row.
readFullRow(sharedCtx, coctx, pageAddr + data.offset(), rowData, readCacheId);
return;
}
first = false;
}
ByteBuffer buf = pageMem.pageBuffer(pageAddr);
buf.position(data.offset());
buf.limit(data.offset() + data.payloadSize());
boolean keyOnly = rowData == RowData.KEY_ONLY;
incomplete = readFragment(sharedCtx, coctx, buf, keyOnly, readCacheId, incomplete);
if (keyOnly && key != null)
return;
} finally {
pageMem.readUnlock(grpId, pageId, page);
}
} finally {
pageMem.releasePage(grpId, pageId, page);
}
} while (nextLink != 0);
assert isReady() : "ready";
}
use of org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl in project ignite by apache.
the class InlineIndexHelperTest method testStringTruncate.
/**
*/
public void testStringTruncate() throws Exception {
DataRegionConfiguration plcCfg = new DataRegionConfiguration().setInitialSize(1024 * MB).setMaxSize(1024 * MB);
PageMemory pageMem = new PageMemoryNoStoreImpl(log(), new UnsafeMemoryProvider(log()), null, PAGE_SIZE, plcCfg, new DataRegionMetricsImpl(plcCfg), false);
pageMem.start();
long pageId = 0L;
long page = 0L;
try {
pageId = pageMem.allocatePage(CACHE_ID, 1, PageIdAllocator.FLAG_DATA);
page = pageMem.acquirePage(CACHE_ID, pageId);
long pageAddr = pageMem.readLock(CACHE_ID, pageId, page);
int off = 0;
InlineIndexHelper ih = new InlineIndexHelper(Value.STRING, 1, 0, CompareMode.getInstance(null, 0));
ih.put(pageAddr, off, ValueString.get("aaaaaaa"), 3 + 5);
assertFalse(ih.isValueFull(pageAddr, off));
assertEquals("aaaaa", ih.get(pageAddr, off, 3 + 5).getString());
ih.put(pageAddr, off, ValueString.get("aaa"), 3 + 5);
assertTrue(ih.isValueFull(pageAddr, off));
assertEquals("aaa", ih.get(pageAddr, off, 3 + 5).getString());
ih.put(pageAddr, off, ValueString.get("\u20acaaa"), 3 + 2);
assertNull(ih.get(pageAddr, off, 3 + 2));
} finally {
if (page != 0L)
pageMem.releasePage(CACHE_ID, pageId, page);
pageMem.stop();
}
}
use of org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl in project ignite by apache.
the class InlineIndexHelperTest method testBytes.
/**
*/
public void testBytes() throws Exception {
DataRegionConfiguration plcCfg = new DataRegionConfiguration().setInitialSize(1024 * MB).setMaxSize(1024 * MB);
PageMemory pageMem = new PageMemoryNoStoreImpl(log(), new UnsafeMemoryProvider(log()), null, PAGE_SIZE, plcCfg, new DataRegionMetricsImpl(plcCfg), false);
pageMem.start();
long pageId = 0L;
long page = 0L;
try {
pageId = pageMem.allocatePage(CACHE_ID, 1, PageIdAllocator.FLAG_DATA);
page = pageMem.acquirePage(CACHE_ID, pageId);
long pageAddr = pageMem.readLock(CACHE_ID, pageId, page);
int off = 0;
InlineIndexHelper ih = new InlineIndexHelper(Value.BYTES, 1, 0, CompareMode.getInstance(null, 0));
ih.put(pageAddr, off, ValueBytes.get(new byte[] { 1, 2, 3, 4, 5 }), 3 + 3);
assertFalse(ih.isValueFull(pageAddr, off));
assertTrue(Arrays.equals(new byte[] { 1, 2, 3 }, ih.get(pageAddr, off, 3 + 5).getBytes()));
ih.put(pageAddr, off, ValueBytes.get(new byte[] { 1, 2, 3, 4, 5 }), 3 + 5);
assertTrue(ih.isValueFull(pageAddr, off));
assertTrue(Arrays.equals(new byte[] { 1, 2, 3, 4, 5 }, ih.get(pageAddr, off, 3 + 5).getBytes()));
} finally {
if (page != 0L)
pageMem.releasePage(CACHE_ID, pageId, page);
pageMem.stop();
}
}
Aggregations