Search in sources :

Example 16 with PageMemoryNoStoreImpl

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();
    }
}
Also used : DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) PageMemoryNoStoreImpl(org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) Value(org.h2.value.Value) DataRegionMetricsImpl(org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl) UnsafeMemoryProvider(org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider)

Example 17 with PageMemoryNoStoreImpl

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();
    }
}
Also used : DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) PageMemoryNoStoreImpl(org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) Value(org.h2.value.Value) DataRegionMetricsImpl(org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl) UnsafeMemoryProvider(org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider) Comparator(java.util.Comparator)

Example 18 with PageMemoryNoStoreImpl

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);
}
Also used : PageMemoryNoStoreImpl(org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl) IoStatisticsHolder(org.apache.ignite.internal.metric.IoStatisticsHolder) CacheObjectContext(org.apache.ignite.internal.processors.cache.CacheObjectContext)

Example 19 with PageMemoryNoStoreImpl

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;
}
Also used : PageMemoryNoStoreImpl(org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) DataRegionMetricsImpl(org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl) UnsafeMemoryProvider(org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider)

Example 20 with PageMemoryNoStoreImpl

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);
}
Also used : MappedFileMemoryProvider(org.apache.ignite.internal.mem.file.MappedFileMemoryProvider) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) PageMemoryNoStoreImpl(org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl) DirectMemoryProvider(org.apache.ignite.internal.mem.DirectMemoryProvider) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) DataRegionMetricsImpl(org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl)

Aggregations

PageMemoryNoStoreImpl (org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl)24 PageMemory (org.apache.ignite.internal.pagemem.PageMemory)19 UnsafeMemoryProvider (org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider)17 DataRegionMetricsImpl (org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl)17 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)15 GridTestKernalContext (org.apache.ignite.testframework.junits.GridTestKernalContext)11 IndexKeyTypeSettings (org.apache.ignite.internal.cache.query.index.sorted.IndexKeyTypeSettings)6 InlineIndexKeyType (org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndexKeyType)6 StringInlineIndexKeyType (org.apache.ignite.internal.cache.query.index.sorted.inline.types.StringInlineIndexKeyType)6 Test (org.junit.Test)5 AbstractIndexingCommonTest (org.apache.ignite.internal.processors.cache.index.AbstractIndexingCommonTest)4 DirectMemoryProvider (org.apache.ignite.internal.mem.DirectMemoryProvider)3 CacheObjectContext (org.apache.ignite.internal.processors.cache.CacheObjectContext)3 Value (org.h2.value.Value)3 JavaObjectIndexKey (org.apache.ignite.internal.cache.query.index.sorted.keys.JavaObjectIndexKey)2 MappedFileMemoryProvider (org.apache.ignite.internal.mem.file.MappedFileMemoryProvider)2 IoStatisticsHolder (org.apache.ignite.internal.metric.IoStatisticsHolder)2 MemoryMetricsImpl (org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl)2 ByteBuffer (java.nio.ByteBuffer)1 Comparator (java.util.Comparator)1