use of org.apache.ignite.internal.processors.query.h2.opt.GridH2Table in project ignite by apache.
the class GridH2ProxyIndex method createLookupBatch.
/**
* {@inheritDoc}
*/
@Override
public IndexLookupBatch createLookupBatch(TableFilter[] filters, int filter) {
IndexLookupBatch batch = idx.createLookupBatch(filters, filter);
if (batch == null)
return null;
GridH2RowDescriptor rowDesc = ((GridH2Table) idx.getTable()).rowDescriptor();
return new ProxyDistributedLookupBatch(batch, rowDesc);
}
use of org.apache.ignite.internal.processors.query.h2.opt.GridH2Table 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.processors.query.h2.opt.GridH2Table in project ignite by apache.
the class H2DynamicTableSelfTest method assertAffinityCacheConfiguration.
/**
* Check that dynamic cache created with {@code CREATE TABLE} is correctly configured affinity wise.
* @param cacheName Cache name to check.
* @param affKeyFieldName Expected affinity key field name.
*/
private void assertAffinityCacheConfiguration(String cacheName, String affKeyFieldName) {
String actualCacheName = cacheName(cacheName);
Collection<GridQueryTypeDescriptor> types = client().context().query().types(actualCacheName);
assertEquals(1, types.size());
GridQueryTypeDescriptor type = types.iterator().next();
assertTrue(type.name().startsWith(actualCacheName));
assertEquals(cacheName, type.tableName());
assertEquals(affKeyFieldName, type.affinityKey());
GridH2Table tbl = ((IgniteH2Indexing) queryProcessor(client()).getIndexing()).schemaManager().dataTable("PUBLIC", cacheName);
assertNotNull(tbl);
assertNotNull(tbl.getAffinityKeyColumn());
assertEquals(affKeyFieldName, tbl.getAffinityKeyColumn().columnName);
}
use of org.apache.ignite.internal.processors.query.h2.opt.GridH2Table in project ignite by apache.
the class IgniteH2Indexing method indexSize.
/**
* {@inheritDoc}
*/
@Override
public long indexSize(String schemaName, String tblName, String idxName) throws IgniteCheckedException {
GridH2Table tbl = schemaMgr.dataTable(schemaName, tblName);
if (tbl == null)
return 0;
H2TreeIndex idx = (H2TreeIndex) tbl.userIndex(idxName);
return idx == null ? 0 : idx.size();
}
use of org.apache.ignite.internal.processors.query.h2.opt.GridH2Table 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