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);
}
}
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);
}
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.");
}
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());
}
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());
}
Aggregations