use of org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl in project ignite by apache.
the class InlineIndexHelperTest method testPutGet.
/**
*/
private void testPutGet(Value v1, Value v2, Value v3) 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;
int max = 255;
InlineIndexHelper ih = new InlineIndexHelper(v1.getType(), 1, 0, CompareMode.getInstance(null, 0));
off += ih.put(pageAddr, off, v1, max - off);
off += ih.put(pageAddr, off, v2, max - off);
off += ih.put(pageAddr, off, v3, max - off);
Value v11 = ih.get(pageAddr, 0, max);
Value v22 = ih.get(pageAddr, ih.fullSize(pageAddr, 0), max);
assertEquals(v1.getObject(), v11.getObject());
assertEquals(v2.getObject(), v22.getObject());
} 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 putAndCompare.
/**
* @param v1 Value 1.
* @param v2 Value 2.
* @param maxSize Max inline size.
* @return Compare result.
* @throws Exception If failed.
*/
private int putAndCompare(String v1, String v2, int maxSize) 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, v1 == null ? ValueNull.INSTANCE : ValueString.get(v1), maxSize);
Comparator<Value> comp = new Comparator<Value>() {
@Override
public int compare(Value o1, Value o2) {
throw new AssertionError("Optimized algorithm should be used.");
}
};
return ih.compare(pageAddr, off, maxSize, v2 == null ? ValueNull.INSTANCE : ValueString.get(v2), comp);
} 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 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.
* @param skipVer Whether version read should be skipped.
* @throws IgniteCheckedException If failed.
*/
public final void initFromLink(@Nullable CacheGroupContext grp, GridCacheSharedContext<?, ?> sharedCtx, PageMemory pageMem, RowData rowData, boolean skipVer) throws IgniteCheckedException {
// Group is null if try evict page, with persistence evictions should be disabled.
assert grp != null || pageMem instanceof PageMemoryNoStoreImpl;
CacheObjectContext coctx = grp != null ? grp.cacheObjectContext() : null;
boolean readCacheId = grp == null || grp.storeCacheIdInDataPage();
int grpId = grp != null ? grp.groupId() : 0;
IoStatisticsHolder statHolder = grp != null ? grp.statisticsHolderData() : IoStatisticsHolderNoOp.INSTANCE;
doInitFromLink(link, sharedCtx, coctx, pageMem, grpId, statHolder, readCacheId, rowData, null, skipVer);
}
use of org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl in project ignite by apache.
the class CacheFreeListSelfTest method createPageMemory.
/**
* @return Page memory.
*/
protected PageMemory createPageMemory(int pageSize, DataRegionConfiguration plcCfg) {
PageMemory pageMem = new PageMemoryNoStoreImpl(log, new UnsafeMemoryProvider(log), null, pageSize, plcCfg, new DataRegionMetricsImpl(plcCfg, new GridTestKernalContext(log())), true);
pageMem.start();
return pageMem;
}
use of org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl in project ignite by apache.
the class IndexStorageSelfTest method memory.
/**
* @param clean Clean flag. If {@code true}, will clean previous memory state and allocate
* new empty page memory.
* @return Page memory instance.
*/
protected PageMemory memory(boolean clean) throws Exception {
DirectMemoryProvider provider = new MappedFileMemoryProvider(log(), allocationPath);
DataRegionConfiguration plcCfg = new DataRegionConfiguration().setMaxSize(30L * 1024 * 1024).setInitialSize(30L * 1024 * 1024);
return new PageMemoryNoStoreImpl(log, provider, null, PAGE_SIZE, plcCfg, new DataRegionMetricsImpl(plcCfg, new GridTestKernalContext(log())), true);
}
Aggregations