use of org.apache.ignite.internal.processors.query.h2.opt.GridH2ProxyIndex in project ignite by apache.
the class GridH2Table method removeIndex.
/**
* Remove the given index from the list.
*
* @param h2Idx the index to remove
*/
public void removeIndex(Session session, Index h2Idx) {
lock(true);
try {
ensureNotDestroyed();
ArrayList<Index> idxs = new ArrayList<>(this.idxs);
Index targetIdx = (h2Idx instanceof GridH2ProxyIndex) ? ((GridH2ProxyIndex) h2Idx).underlyingIndex() : h2Idx;
for (int i = pkIndexPos; i < idxs.size(); ) {
Index idx = idxs.get(i);
if (idx == targetIdx || (idx instanceof GridH2ProxyIndex && ((GridH2ProxyIndex) idx).underlyingIndex() == targetIdx)) {
idxs.remove(i);
if (idx instanceof GridH2ProxyIndex && idx.getSchema().findIndex(session, idx.getName()) != null)
database.removeSchemaObject(session, idx);
if (idx instanceof GridH2IndexBase)
destroyIndex(idx);
continue;
}
i++;
}
this.idxs = idxs;
} finally {
unlock(true);
}
}
use of org.apache.ignite.internal.processors.query.h2.opt.GridH2ProxyIndex in project ignite by apache.
the class GridH2Table method createDuplicateIndexIfNeeded.
/**
* Creates proxy index for given target index.
* Proxy index refers to alternative key and val columns.
*
* @param target Index to clone.
* @return Proxy index.
*/
private Index createDuplicateIndexIfNeeded(Index target) {
if (!(target instanceof H2TreeIndexBase) && !(target instanceof SpatialIndex))
return null;
IndexColumn[] cols = target.getIndexColumns();
List<IndexColumn> proxyCols = new ArrayList<>(cols.length);
boolean modified = false;
for (IndexColumn col : cols) {
IndexColumn proxyCol = new IndexColumn();
proxyCol.columnName = col.columnName;
proxyCol.column = col.column;
proxyCol.sortType = col.sortType;
int altColId = desc.getAlternativeColumnId(proxyCol.column.getColumnId());
if (altColId != proxyCol.column.getColumnId()) {
proxyCol.column = getColumn(altColId);
proxyCol.columnName = proxyCol.column.getName();
modified = true;
}
proxyCols.add(proxyCol);
}
if (modified) {
String proxyName = target.getName() + "_proxy";
if (target.getIndexType().isSpatial())
return new GridH2ProxySpatialIndex(this, proxyName, proxyCols, target);
return new GridH2ProxyIndex(this, proxyName, proxyCols, target);
}
return null;
}
Aggregations