use of org.apache.ignite.internal.processors.query.h2.H2TableDescriptor in project ignite by apache.
the class SchemaManager method createInitialUserIndex.
/**
* Add initial user index.
*
* @param schemaName Schema name.
* @param desc Table descriptor.
* @param h2Idx User index.
* @throws IgniteCheckedException If failed.
*/
private void createInitialUserIndex(String schemaName, H2TableDescriptor desc, GridH2IndexBase h2Idx) throws IgniteCheckedException {
GridH2Table h2Tbl = desc.table();
h2Tbl.proposeUserIndex(h2Idx);
try {
String sql = H2Utils.indexCreateSql(desc.fullTableName(), h2Idx, false);
connMgr.executeStatement(schemaName, sql);
} catch (Exception e) {
// Rollback and re-throw.
h2Tbl.rollbackUserIndex(h2Idx.getName());
throw e;
}
}
use of org.apache.ignite.internal.processors.query.h2.H2TableDescriptor in project ignite by apache.
the class DynamicEnableIndexingAbstractTest method checkQueryParallelism.
/**
*/
protected void checkQueryParallelism(IgniteEx ig, CacheMode cacheMode) {
int expectedParallelism = cacheMode != CacheMode.REPLICATED ? QUERY_PARALLELISM : CacheConfiguration.DFLT_QUERY_PARALLELISM;
IgniteH2Indexing indexing = (IgniteH2Indexing) ig.context().query().getIndexing();
SchemaManager schemaMgr = indexing.schemaManager();
H2TableDescriptor descr = schemaMgr.tableForType(POI_SCHEMA_NAME, POI_CACHE_NAME, POI_CLASS_NAME);
assertNotNull(descr);
if (descr.table().getIndex(KEY_PK_IDX_NAME) instanceof H2TreeIndex) {
H2TreeIndex pkIdx = (H2TreeIndex) descr.table().getIndex(KEY_PK_IDX_NAME);
assertNotNull(pkIdx);
assertEquals(expectedParallelism, pkIdx.segmentsCount());
}
CacheConfiguration<?, ?> cfg = ig.context().cache().cacheConfiguration(POI_CACHE_NAME);
assertEquals(expectedParallelism, cfg.getQueryParallelism());
}
use of org.apache.ignite.internal.processors.query.h2.H2TableDescriptor in project ignite by apache.
the class BasicIndexTest method testCreateLuceneIndex.
/**
*/
@Test
public void testCreateLuceneIndex() throws Exception {
inlineSize = 10;
startGrid();
sql("create table test0(id1 int primary key, val varchar) " + "WITH \"WRAP_VALUE=false\"");
IgniteH2Indexing idx = ((IgniteH2Indexing) grid().context().query().getIndexing());
H2TableDescriptor tblDesc0 = idx.schemaManager().dataTable("PUBLIC", "TEST0").rowDescriptor().tableDescriptor();
assertNotNull(GridTestUtils.getFieldValue(tblDesc0, "luceneIdx"));
idx.distributedConfiguration().disableCreateLuceneIndexForStringValueType(true).get();
sql("create table test1(id1 int primary key, val varchar) " + "WITH \"WRAP_VALUE=false\"");
H2TableDescriptor tblDesc1 = idx.schemaManager().dataTable("PUBLIC", "TEST1").rowDescriptor().tableDescriptor();
assertNull(GridTestUtils.getFieldValue(tblDesc1, "luceneIdx"));
}
use of org.apache.ignite.internal.processors.query.h2.H2TableDescriptor in project ignite by apache.
the class H2DynamicTableSelfTest method testGetTablesForCache.
/**
* Test that tables method only returns tables belonging to given cache.
*
* @throws Exception if failed.
*/
@Test
public void testGetTablesForCache() throws Exception {
try {
execute("create table t1(id int primary key, name varchar)");
execute("create table t2(id int primary key, name varchar)");
IgniteH2Indexing h2Idx = (IgniteH2Indexing) grid(0).context().query().getIndexing();
String cacheName = cacheName("T1");
Collection<H2TableDescriptor> col = h2Idx.schemaManager().tablesForCache(cacheName);
assertNotNull(col);
H2TableDescriptor[] tables = col.toArray(new H2TableDescriptor[col.size()]);
assertEquals(1, tables.length);
assertEquals(tables[0].table().getName(), "T1");
} finally {
execute("drop table t1 if exists");
execute("drop table t2 if exists");
}
}
Aggregations