use of org.apache.ignite.internal.cache.query.index.IndexDefinition 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.IndexDefinition 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);
}
}
Aggregations