use of org.apache.ignite.internal.cache.query.index.sorted.IndexSearchRowImpl in project ignite by apache.
the class IndexQueryProcessor method alignCriteriaWithIndex.
/**
* Checks that specified index matches index query criteria.
*/
private IndexRangeQuery alignCriteriaWithIndex(InlineIndexImpl idx, Map<String, RangeIndexQueryCriterion> criteria, IndexDefinition idxDef) {
// Size of bounds array has to be equal to count of indexed fields.
IndexKey[] lowerBounds = new IndexKey[idxDef.indexKeyDefinitions().size()];
IndexKey[] upperBounds = new IndexKey[idxDef.indexKeyDefinitions().size()];
boolean lowerAllNulls = true;
boolean upperAllNulls = true;
IndexRangeQuery qry = new IndexRangeQuery(criteria.size());
// Checks that users criteria matches a prefix subset of index fields.
int i = 0;
for (Map.Entry<String, IndexKeyDefinition> keyDef : idxDef.indexKeyDefinitions().entrySet()) {
RangeIndexQueryCriterion criterion = criteria.remove(keyDef.getKey());
if (keyDef.getValue().order().sortOrder() == DESC)
criterion = criterion.swap();
qry.criteria[i] = criterion;
IndexKey l = (IndexKey) criterion.lower();
IndexKey u = (IndexKey) criterion.upper();
if (l != null)
lowerAllNulls = false;
if (u != null)
upperAllNulls = false;
lowerBounds[i] = l;
upperBounds[i++] = u;
if (criteria.isEmpty())
break;
}
InlineIndexRowHandler hnd = idx.segment(0).rowHandler();
qry.lower = lowerAllNulls ? null : new IndexSearchRowImpl(lowerBounds, hnd);
qry.upper = upperAllNulls ? null : new IndexSearchRowImpl(upperBounds, hnd);
return qry;
}
use of org.apache.ignite.internal.cache.query.index.sorted.IndexSearchRowImpl in project ignite by apache.
the class H2TreeIndex method preparePlainIndexKey.
/**
*/
private IndexRow preparePlainIndexKey(SearchRow row, InlineIndexRowHandler rowHnd) {
int idxColsLen = indexColumns.length;
IndexKey[] keys = row == null ? null : new IndexKey[idxColsLen];
for (int i = 0; i < idxColsLen; ++i) {
int colId = indexColumns[i].column.getColumnId();
Value v = row.getValue(colId);
keys[i] = v == null ? null : IndexKeyFactory.wrap(v.getObject(), v.getType(), cctx.cacheObjectContext(), queryIndex.keyTypeSettings());
}
return new IndexSearchRowImpl(keys, rowHnd);
}
Aggregations