Search in sources :

Example 16 with H2TableDescriptor

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;
    }
}
Also used : GridH2Table(org.apache.ignite.internal.processors.query.h2.opt.GridH2Table) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) SQLException(java.sql.SQLException) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException)

Example 17 with H2TableDescriptor

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());
}
Also used : H2TreeIndex(org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex) H2TableDescriptor(org.apache.ignite.internal.processors.query.h2.H2TableDescriptor) SchemaManager(org.apache.ignite.internal.processors.query.h2.SchemaManager) IgniteH2Indexing(org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing)

Example 18 with H2TableDescriptor

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"));
}
Also used : H2TableDescriptor(org.apache.ignite.internal.processors.query.h2.H2TableDescriptor) IgniteH2Indexing(org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing) Test(org.junit.Test)

Example 19 with H2TableDescriptor

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");
    }
}
Also used : H2TableDescriptor(org.apache.ignite.internal.processors.query.h2.H2TableDescriptor) IgniteH2Indexing(org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing) Test(org.junit.Test)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)9 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)9 GridH2Table (org.apache.ignite.internal.processors.query.h2.opt.GridH2Table)8 SQLException (java.sql.SQLException)7 IgniteSystemProperties.getString (org.apache.ignite.IgniteSystemProperties.getString)7 IgniteException (org.apache.ignite.IgniteException)6 H2TreeIndex (org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex)4 GridH2IndexBase (org.apache.ignite.internal.processors.query.h2.opt.GridH2IndexBase)4 Index (org.h2.index.Index)4 HashSet (java.util.HashSet)3 LinkedHashSet (java.util.LinkedHashSet)3 Map (java.util.Map)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 ConcurrentMap (java.util.concurrent.ConcurrentMap)3 H2TableDescriptor (org.apache.ignite.internal.processors.query.h2.H2TableDescriptor)3 H2Utils.generateFieldsQueryString (org.apache.ignite.internal.processors.query.h2.H2Utils.generateFieldsQueryString)3 IgniteH2Indexing (org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing)3 GridH2RowDescriptor (org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor)3 GridBoundedConcurrentLinkedHashMap (org.apache.ignite.internal.util.GridBoundedConcurrentLinkedHashMap)3 Connection (java.sql.Connection)2