Search in sources :

Example 1 with SpatialIndex

use of org.h2.index.SpatialIndex 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.
     */
public Index createDuplicateIndexIfNeeded(Index target) {
    if (!(target instanceof H2TreeIndex) && !(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;
}
Also used : H2TreeIndex(org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex) SpatialIndex(org.h2.index.SpatialIndex) ArrayList(java.util.ArrayList) IndexColumn(org.h2.table.IndexColumn)

Aggregations

ArrayList (java.util.ArrayList)1 H2TreeIndex (org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex)1 SpatialIndex (org.h2.index.SpatialIndex)1 IndexColumn (org.h2.table.IndexColumn)1