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