Search in sources :

Example 1 with ClientIndexDefinition

use of org.apache.ignite.internal.processors.query.h2.index.client.ClientIndexDefinition 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);
    }
}
Also used : H2TreeIndex(org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex) InlineIndex(org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndex) IndexColumn(org.h2.table.IndexColumn) IndexName(org.apache.ignite.internal.cache.query.index.IndexName) InlineIndexImpl(org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndexImpl) QueryIndexDefinition(org.apache.ignite.internal.processors.query.h2.index.QueryIndexDefinition) GridCacheContextInfo(org.apache.ignite.internal.processors.cache.GridCacheContextInfo) H2TreeClientIndex(org.apache.ignite.internal.processors.query.h2.database.H2TreeClientIndex) ClientIndexDefinition(org.apache.ignite.internal.processors.query.h2.index.client.ClientIndexDefinition) IndexType(org.h2.index.IndexType)

Aggregations

IndexName (org.apache.ignite.internal.cache.query.index.IndexName)1 InlineIndex (org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndex)1 InlineIndexImpl (org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndexImpl)1 GridCacheContextInfo (org.apache.ignite.internal.processors.cache.GridCacheContextInfo)1 H2TreeClientIndex (org.apache.ignite.internal.processors.query.h2.database.H2TreeClientIndex)1 H2TreeIndex (org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex)1 QueryIndexDefinition (org.apache.ignite.internal.processors.query.h2.index.QueryIndexDefinition)1 ClientIndexDefinition (org.apache.ignite.internal.processors.query.h2.index.client.ClientIndexDefinition)1 IndexType (org.h2.index.IndexType)1 IndexColumn (org.h2.table.IndexColumn)1