Search in sources :

Example 61 with QueryIndex

use of org.apache.ignite.cache.QueryIndex in project ignite by apache.

the class DynamicIndexAbstractBasicSelfTest method checkIndexCreatedForInlineSize.

/**
 * Verifies that index is created with the specified inline size.
 *
 * @param inlineSize Inline size to put into CREATE INDEX
 * @throws Exception If failed.
 */
private void checkIndexCreatedForInlineSize(int inlineSize) throws Exception {
    QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
    idx.setInlineSize(inlineSize);
    dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
    assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, inlineSize, field(FIELD_NAME_1_ESCAPED));
    assertSimpleIndexOperations(SQL_SIMPLE_FIELD_1);
    assertIndexUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
    dynamicIndexDrop(CACHE_NAME, IDX_NAME_1, false);
    assertNoIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1);
}
Also used : QueryIndex(org.apache.ignite.cache.QueryIndex)

Example 62 with QueryIndex

use of org.apache.ignite.cache.QueryIndex in project ignite by apache.

the class DynamicIndexAbstractBasicSelfTest method checkCreateNotCache.

/**
 * Check create when cache doesn't exist.
 *
 * @param mode Mode.
 * @param atomicityMode Atomicity mode.
 * @param near Near flag.
 * @throws Exception If failed.
 */
private void checkCreateNotCache(CacheMode mode, CacheAtomicityMode atomicityMode, boolean near) throws Exception {
    initialize(mode, atomicityMode, near);
    final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
    try {
        String cacheName = randomString();
        queryProcessor(node()).dynamicIndexCreate(cacheName, cacheName, TBL_NAME, idx, false, 0).get();
    } catch (SchemaOperationException e) {
        assertEquals(SchemaOperationException.CODE_CACHE_NOT_FOUND, e.code());
        assertNoIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1);
        return;
    } catch (Exception e) {
        fail("Unexpected exception: " + e);
    }
    fail(SchemaOperationException.class.getSimpleName() + " is not thrown.");
}
Also used : SchemaOperationException(org.apache.ignite.internal.processors.query.schema.SchemaOperationException) QueryIndex(org.apache.ignite.cache.QueryIndex) CacheException(javax.cache.CacheException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) SchemaOperationException(org.apache.ignite.internal.processors.query.schema.SchemaOperationException)

Example 63 with QueryIndex

use of org.apache.ignite.cache.QueryIndex in project ignite by apache.

the class DynamicIndexAbstractBasicSelfTest method testNonSqlCache.

/**
 * Test that operations work on statically configured cache.
 *
 * @throws Exception If failed.
 */
public void testNonSqlCache() throws Exception {
    final QueryIndex idx = index(IDX_NAME_2, field(FIELD_NAME_1));
    dynamicIndexCreate(STATIC_CACHE_NAME, TBL_NAME, idx, true, 0);
    assertIndex(STATIC_CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1_ESCAPED));
    dynamicIndexDrop(STATIC_CACHE_NAME, IDX_NAME_1, true);
    assertNoIndex(STATIC_CACHE_NAME, TBL_NAME, IDX_NAME_1);
}
Also used : QueryIndex(org.apache.ignite.cache.QueryIndex)

Example 64 with QueryIndex

use of org.apache.ignite.cache.QueryIndex in project ignite by apache.

the class DynamicIndexAbstractBasicSelfTest method checkDrop.

/**
 * Check simple index drop.
 *
 * @param mode Mode.
 * @param atomicityMode Atomicity mode.
 * @param near Near flag.
 * @throws Exception If failed.
 */
public void checkDrop(CacheMode mode, CacheAtomicityMode atomicityMode, boolean near) throws Exception {
    initialize(mode, atomicityMode, near);
    // Create target index.
    QueryIndex idx1 = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
    dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx1, false, 0);
    assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1_ESCAPED));
    assertIndexUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
    assertSimpleIndexOperations(SQL_SIMPLE_FIELD_1);
    // Create another index which must stay intact afterwards.
    QueryIndex idx2 = index(IDX_NAME_2, field(alias(FIELD_NAME_2_ESCAPED)));
    dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx2, false, 0);
    assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, QueryIndex.DFLT_INLINE_SIZE, field(alias(FIELD_NAME_2_ESCAPED)));
    // Load some data.
    loadInitialData();
    // Drop index.
    dynamicIndexDrop(CACHE_NAME, IDX_NAME_1, false);
    assertNoIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1);
    assertSimpleIndexOperations(SQL_SIMPLE_FIELD_1);
    assertIndexNotUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
    // Make sure the second index is still there.
    assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, QueryIndex.DFLT_INLINE_SIZE, field(alias(FIELD_NAME_2_ESCAPED)));
}
Also used : QueryIndex(org.apache.ignite.cache.QueryIndex)

Example 65 with QueryIndex

use of org.apache.ignite.cache.QueryIndex in project ignite by apache.

the class DynamicIndexAbstractBasicSelfTest method checkIndexCreatedForParallelism.

/**
 * Verifies that index was created properly with different parallelism levels.
 * NOTE! Unfortunately we cannot check the real parallelism level on which this index was created because it should
 * use internal API. But we can check if this index was created properly on different parallelism levels.
 *
 * @param parallel Parallelism level to put into CREATE INDEX
 * @throws Exception If failed.
 */
private void checkIndexCreatedForParallelism(int parallel) throws Exception {
    QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
    dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, parallel);
    assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1_ESCAPED));
    assertSimpleIndexOperations(SQL_SIMPLE_FIELD_1);
    assertIndexUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
    dynamicIndexDrop(CACHE_NAME, IDX_NAME_1, false);
    assertNoIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1);
}
Also used : QueryIndex(org.apache.ignite.cache.QueryIndex)

Aggregations

QueryIndex (org.apache.ignite.cache.QueryIndex)89 QueryEntity (org.apache.ignite.cache.QueryEntity)46 LinkedHashMap (java.util.LinkedHashMap)35 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)26 SchemaOperationException (org.apache.ignite.internal.processors.query.schema.SchemaOperationException)24 ArrayList (java.util.ArrayList)21 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)20 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)14 Ignite (org.apache.ignite.Ignite)13 CacheException (javax.cache.CacheException)10 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)10 IgniteException (org.apache.ignite.IgniteException)9 HashMap (java.util.HashMap)8 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)8 Map (java.util.Map)7 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)7 HashSet (java.util.HashSet)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 BinaryObject (org.apache.ignite.binary.BinaryObject)5 CountDownLatch (java.util.concurrent.CountDownLatch)4