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