Search in sources :

Example 1 with SchemaManager

use of org.apache.ignite.internal.processors.query.h2.SchemaManager in project ignite by apache.

the class SqlViewExporterSpi method onContextInitialized0.

/**
 * {@inheritDoc}
 */
@Override
protected void onContextInitialized0(IgniteSpiContext spiCtx) throws IgniteSpiException {
    GridKernalContext ctx = ((IgniteEx) ignite()).context();
    if (ctx.query().getIndexing() instanceof IgniteH2Indexing) {
        mgr = ((IgniteH2Indexing) ctx.query().getIndexing()).schemaManager();
        sysViewReg.forEach(this::register);
        sysViewReg.addSystemViewCreationListener(this::register);
    }
}
Also used : GridKernalContext(org.apache.ignite.internal.GridKernalContext) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteH2Indexing(org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing)

Example 2 with SchemaManager

use of org.apache.ignite.internal.processors.query.h2.SchemaManager in project ignite by apache.

the class H2DynamicTableSelfTest method assertAffinityCacheConfiguration.

/**
 * Check that dynamic cache created with {@code CREATE TABLE} is correctly configured affinity wise.
 * @param cacheName Cache name to check.
 * @param affKeyFieldName Expected affinity key field name.
 */
private void assertAffinityCacheConfiguration(String cacheName, String affKeyFieldName) {
    String actualCacheName = cacheName(cacheName);
    Collection<GridQueryTypeDescriptor> types = client().context().query().types(actualCacheName);
    assertEquals(1, types.size());
    GridQueryTypeDescriptor type = types.iterator().next();
    assertTrue(type.name().startsWith(actualCacheName));
    assertEquals(cacheName, type.tableName());
    assertEquals(affKeyFieldName, type.affinityKey());
    GridH2Table tbl = ((IgniteH2Indexing) queryProcessor(client()).getIndexing()).schemaManager().dataTable("PUBLIC", cacheName);
    assertNotNull(tbl);
    assertNotNull(tbl.getAffinityKeyColumn());
    assertEquals(affKeyFieldName, tbl.getAffinityKeyColumn().columnName);
}
Also used : GridH2Table(org.apache.ignite.internal.processors.query.h2.opt.GridH2Table) GridQueryTypeDescriptor(org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor)

Example 3 with SchemaManager

use of org.apache.ignite.internal.processors.query.h2.SchemaManager in project ignite by apache.

the class SqlViewMetricExporterSpi method onContextInitialized0.

/**
 * {@inheritDoc}
 */
@Override
protected void onContextInitialized0(IgniteSpiContext spiCtx) throws IgniteSpiException {
    GridKernalContext ctx = ((IgniteEx) ignite()).context();
    if (!(ctx.query().getIndexing() instanceof IgniteH2Indexing))
        return;
    SchemaManager mgr = ((IgniteH2Indexing) ctx.query().getIndexing()).schemaManager();
    mgr.createSystemView(SCHEMA_SYS, new MetricRegistryLocalSystemView(ctx, mreg));
    if (log.isDebugEnabled())
        log.debug(SYS_VIEW_NAME + " SQL view for metrics created.");
}
Also used : GridKernalContext(org.apache.ignite.internal.GridKernalContext) IgniteEx(org.apache.ignite.internal.IgniteEx) SchemaManager(org.apache.ignite.internal.processors.query.h2.SchemaManager) IgniteH2Indexing(org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing)

Example 4 with SchemaManager

use of org.apache.ignite.internal.processors.query.h2.SchemaManager in project ignite by apache.

the class BasicIndexTest method testCreateSystemIndexWithSpecifiedInlineSizeByDdl.

/**
 */
@Test
public void testCreateSystemIndexWithSpecifiedInlineSizeByDdl() throws Exception {
    inlineSize = 10;
    final int pkInlineSize = 22;
    final int affInlineSize = 23;
    IgniteEx ign = startGrid();
    sql("CREATE TABLE TEST (ID VARCHAR, ID_AFF INT, VAL INT, " + "PRIMARY KEY (ID, ID_AFF)) WITH" + "\"" + "AFFINITY_KEY=ID_AFF," + "PK_INLINE_SIZE=" + pkInlineSize + "," + "AFFINITY_INDEX_INLINE_SIZE=" + affInlineSize + "\"");
    GridH2Table tbl = ((IgniteH2Indexing) ign.context().query().getIndexing()).schemaManager().dataTable("PUBLIC", "TEST");
    assertEquals(pkInlineSize, ((H2TreeIndex) tbl.getIndex("_key_PK")).inlineSize());
    assertEquals(affInlineSize, ((H2TreeIndex) tbl.getIndex("AFFINITY_KEY")).inlineSize());
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) GridH2Table(org.apache.ignite.internal.processors.query.h2.opt.GridH2Table) Test(org.junit.Test)

Example 5 with SchemaManager

use of org.apache.ignite.internal.processors.query.h2.SchemaManager in project ignite by apache.

the class SqlTwoCachesInGroupWithSameEntryTest method test.

/**
 * @throws Exception On error.
 */
@SuppressWarnings("unchecked")
@Test
public void test() throws Exception {
    IgniteEx ign = startGrid(0);
    ign.cluster().active(true);
    IgniteCache cache0 = ign.createCache(new CacheConfiguration<>("cache0").setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL).setGroupName("grp0").setSqlSchema("CACHE0").setIndexedTypes(Integer.class, Integer.class));
    IgniteCache cache1 = ign.createCache(new CacheConfiguration<>("cache1").setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL).setGroupName("grp0").setSqlSchema("CACHE1").setIndexedTypes(Integer.class, Integer.class));
    for (int i = 0; i < KEYS; ++i) {
        cache0.put(i, i);
        cache1.put(i, i);
    }
    if (useOnlyPkHashIndex) {
        for (GridH2Table t : ((IgniteH2Indexing) grid(0).context().query().getIndexing()).schemaManager().dataTables()) GridTestUtils.setFieldValue(t, "rebuildFromHashInProgress", 1);
    }
    assertEquals(KEYS, cache0.size());
    assertEquals(KEYS, cache1.size());
    assertEquals(KEYS, sql("select * FROM cache0.Integer").getAll().size());
    assertEquals(KEYS, sql("select * FROM cache1.Integer").getAll().size());
    cache0.clear();
    assertEquals(0, cache0.size());
    assertEquals(KEYS, cache1.size());
    assertEquals(0, sql("select * FROM cache0.Integer").getAll().size());
    assertEquals(KEYS, sql("select * FROM cache1.Integer").getAll().size());
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) GridH2Table(org.apache.ignite.internal.processors.query.h2.opt.GridH2Table) IgniteCache(org.apache.ignite.IgniteCache) AbstractIndexingCommonTest(org.apache.ignite.internal.processors.cache.index.AbstractIndexingCommonTest) Test(org.junit.Test)

Aggregations

IgniteEx (org.apache.ignite.internal.IgniteEx)4 IgniteH2Indexing (org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing)3 GridH2Table (org.apache.ignite.internal.processors.query.h2.opt.GridH2Table)3 GridKernalContext (org.apache.ignite.internal.GridKernalContext)2 SchemaManager (org.apache.ignite.internal.processors.query.h2.SchemaManager)2 Test (org.junit.Test)2 IgniteCache (org.apache.ignite.IgniteCache)1 AbstractIndexingCommonTest (org.apache.ignite.internal.processors.cache.index.AbstractIndexingCommonTest)1 GridQueryTypeDescriptor (org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor)1 RunningQueryManager (org.apache.ignite.internal.processors.query.RunningQueryManager)1 H2TableDescriptor (org.apache.ignite.internal.processors.query.h2.H2TableDescriptor)1 H2PartitionResolver (org.apache.ignite.internal.processors.query.h2.affinity.H2PartitionResolver)1 PartitionExtractor (org.apache.ignite.internal.processors.query.h2.affinity.PartitionExtractor)1 H2TreeIndex (org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex)1 GridMapQueryExecutor (org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor)1 GridReduceQueryExecutor (org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor)1 PartitionReservationManager (org.apache.ignite.internal.processors.query.h2.twostep.PartitionReservationManager)1 IgniteStatisticsManagerImpl (org.apache.ignite.internal.processors.query.stat.IgniteStatisticsManagerImpl)1