use of org.apache.ignite.internal.cache.query.index.IndexName in project ignite by apache.
the class LongDestroyDurableBackgroundTaskTest method testConvertOldTaskToNew.
/**
* Checking the converting of the old problem into the new one.
*/
@Test
public void testConvertOldTaskToNew() {
String grpName = "grpTest";
String cacheName = "cacheTest";
String treeName = "treeTest";
String idxName = "idxTest";
List<Long> pages = F.asList(100L);
DurableBackgroundCleanupIndexTreeTask oldTask = new DurableBackgroundCleanupIndexTreeTask(pages, emptyList(), grpName, cacheName, new IndexName(cacheName, "schemaTest", "tableTest", idxName), treeName);
DurableBackgroundTask convertedTask = oldTask.convertAfterRestoreIfNeeded();
assertTrue(convertedTask instanceof DurableBackgroundCleanupIndexTreeTaskV2);
assertEquals(grpName, getFieldValue(convertedTask, "grpName"));
assertEquals(cacheName, getFieldValue(convertedTask, "cacheName"));
assertEquals(treeName, getFieldValue(convertedTask, "oldTreeName"));
assertNotNull(getFieldValue(convertedTask, "newTreeName"));
assertEquals(idxName, getFieldValue(convertedTask, "idxName"));
assertEquals(pages.size(), (int) getFieldValue(convertedTask, "segments"));
}
use of org.apache.ignite.internal.cache.query.index.IndexName in project ignite by apache.
the class GeoSpatialUtils method createIndex.
/**
*/
public static GridH2SpatialIndex createIndex(GridH2Table tbl, String idxName, List<IndexColumn> cols) {
try {
IndexName name = new IndexName(tbl.cacheName(), tbl.getSchema().getName(), tbl.getName(), idxName);
LinkedHashMap<String, IndexKeyDefinition> keyDefs = new QueryIndexKeyDefinitionProvider(tbl, cols).keyDefinitions();
List<InlineIndexKeyType> idxKeyTypes = InlineIndexKeyTypeRegistry.types(keyDefs.values(), DUMMY_SETTINGS);
QueryIndexRowHandler rowHnd = new QueryIndexRowHandler(tbl, cols, keyDefs, idxKeyTypes, DUMMY_SETTINGS);
final int segments = tbl.rowDescriptor().cacheInfo().config().getQueryParallelism();
IndexDefinition def = new GeoSpatialIndexDefinition(name, keyDefs, rowHnd, segments);
Index idx = tbl.cacheContext().kernalContext().indexProcessor().createIndex(tbl.cacheContext(), GeoSpatialIndexFactory.INSTANCE, def);
return new GridH2SpatialIndex(idx.unwrap(GeoSpatialIndexImpl.class));
} catch (Exception e) {
throw new IgniteException("Failed to instantiate", e);
}
}
use of org.apache.ignite.internal.cache.query.index.IndexName in project ignite by apache.
the class IgniteH2Indexing method createSortedIndex.
/**
* Create sorted index.
*
* @param name Index name,
* @param tbl Table.
* @param pk Primary key flag.
* @param affinityKey Affinity key flag.
* @param unwrappedCols Unwrapped index columns for complex types.
* @param wrappedCols Index columns as is complex types.
* @param inlineSize Index inline size.
* @param cacheVisitor whether index created with new cache or on existing one.
* @return Index.
*/
@SuppressWarnings("ConstantConditions")
GridH2IndexBase createSortedIndex(String name, GridH2Table tbl, boolean pk, boolean affinityKey, List<IndexColumn> unwrappedCols, List<IndexColumn> wrappedCols, int inlineSize, @Nullable SchemaIndexCacheVisitor cacheVisitor) {
GridCacheContextInfo cacheInfo = tbl.cacheInfo();
if (log.isDebugEnabled())
log.debug("Creating cache index [cacheId=" + cacheInfo.cacheId() + ", idxName=" + name + ']');
if (cacheInfo.affinityNode()) {
QueryIndexDefinition idxDef = new QueryIndexDefinition(tbl, name, ctx.indexProcessor().rowCacheCleaner(cacheInfo.groupId()), pk, affinityKey, unwrappedCols, wrappedCols, inlineSize);
org.apache.ignite.internal.cache.query.index.Index index;
if (cacheVisitor != null)
index = ctx.indexProcessor().createIndexDynamically(tbl.cacheContext(), idxFactory, idxDef, cacheVisitor);
else
index = ctx.indexProcessor().createIndex(tbl.cacheContext(), idxFactory, idxDef);
InlineIndexImpl queryIndex = index.unwrap(InlineIndexImpl.class);
return new H2TreeIndex(queryIndex, tbl, unwrappedCols.toArray(new IndexColumn[0]), pk, log);
} else {
ClientIndexDefinition d = new ClientIndexDefinition(tbl, new IndexName(tbl.cacheName(), tbl.getSchema().getName(), tbl.getName(), name), unwrappedCols, inlineSize, tbl.cacheInfo().config().getSqlIndexMaxInlineSize());
org.apache.ignite.internal.cache.query.index.Index index = ctx.indexProcessor().createIndex(tbl.cacheContext(), ClientIndexFactory.INSTANCE, d);
InlineIndex idx = index.unwrap(InlineIndex.class);
IndexType idxType = pk ? IndexType.createPrimaryKey(false, false) : IndexType.createNonUnique(false, false, false);
return new H2TreeClientIndex(idx, tbl, name, unwrappedCols.toArray(new IndexColumn[0]), idxType);
}
}
use of org.apache.ignite.internal.cache.query.index.IndexName in project ignite by apache.
the class GridH2Table method destroyIndex.
/**
* Destroy index with GridIndexManager.
*/
private void destroyIndex(Index idx) {
if (idx instanceof GridH2IndexBase) {
GridH2IndexBase h2idx = (GridH2IndexBase) idx;
// Destroy underlying Ignite index.
IndexDefinition deleteDef = new IndexDefinition() {
/**
* {@inheritDoc}
*/
@Override
public IndexName idxName() {
return new IndexName(cacheName(), getSchema().getName(), tableName, idx.getName());
}
/**
* {@inheritDoc}
*/
@Override
public LinkedHashMap<String, IndexKeyDefinition> indexKeyDefinitions() {
throw new UnsupportedOperationException("Hasn't be invoked for destroyed index.");
}
};
idxMgr.removeIndex(cacheContext(), deleteDef.idxName(), !rmIndex);
// Call it too, if H2 index stores some state.
h2idx.destroy(rmIndex);
}
}
use of org.apache.ignite.internal.cache.query.index.IndexName in project ignite by apache.
the class IndexQueryFailoverTest method destroyIndex.
/**
*/
private void destroyIndex() {
IndexName idxName = new IndexName(CACHE, CACHE, Person.class.getSimpleName().toUpperCase(), IDX);
GridCacheContext cctx = ((GatewayProtectedCacheProxy) cache).context();
cctx.kernalContext().indexProcessor().removeIndex(cctx, idxName, false);
}
Aggregations