Search in sources :

Example 6 with IndexKey

use of org.apache.ignite.internal.cache.query.index.sorted.keys.IndexKey in project ignite by apache.

the class H2RowComparator method compareKey.

/**
 * {@inheritDoc}
 */
@Override
public int compareKey(long pageAddr, int off, int maxSize, IndexKey key, InlineIndexKeyType type) {
    int cmp = super.compareKey(pageAddr, off, maxSize, key, type);
    if (cmp != COMPARE_UNSUPPORTED)
        return cmp;
    int objType = key == NullIndexKey.INSTANCE ? type.type() : key.type();
    int highOrder = Value.getHigherOrder(type.type(), objType);
    // H2 supports comparison between different types after casting them to single type.
    if (highOrder != objType && highOrder == type.type()) {
        Value va = DataType.convertToValue(ses, key.key(), highOrder);
        va = va.convertTo(highOrder);
        IndexKey objHighOrder = IndexKeyFactory.wrap(va.getObject(), highOrder, coctx, keyTypeSettings);
        InlineIndexKeyType highType = InlineIndexKeyTypeRegistry.get(objHighOrder, highOrder, keyTypeSettings);
        // The only way to invoke inline comparison again.
        if (highType != null)
            return ((NullableInlineIndexKeyType) highType).compare0(pageAddr, off, objHighOrder);
    }
    return COMPARE_UNSUPPORTED;
}
Also used : IndexKey(org.apache.ignite.internal.cache.query.index.sorted.keys.IndexKey) NullIndexKey(org.apache.ignite.internal.cache.query.index.sorted.keys.NullIndexKey) InlineIndexKeyType(org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndexKeyType) NullableInlineIndexKeyType(org.apache.ignite.internal.cache.query.index.sorted.inline.types.NullableInlineIndexKeyType) Value(org.h2.value.Value)

Example 7 with IndexKey

use of org.apache.ignite.internal.cache.query.index.sorted.keys.IndexKey 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);
}
Also used : IndexSearchRowImpl(org.apache.ignite.internal.cache.query.index.sorted.IndexSearchRowImpl) IndexKey(org.apache.ignite.internal.cache.query.index.sorted.keys.IndexKey) Value(org.h2.value.Value)

Aggregations

IndexKey (org.apache.ignite.internal.cache.query.index.sorted.keys.IndexKey)7 IndexKeyDefinition (org.apache.ignite.internal.cache.query.index.sorted.IndexKeyDefinition)3 IndexKeyTypeSettings (org.apache.ignite.internal.cache.query.index.sorted.IndexKeyTypeSettings)3 NullIndexKey (org.apache.ignite.internal.cache.query.index.sorted.keys.NullIndexKey)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 RangeIndexQueryCriterion (org.apache.ignite.internal.cache.query.RangeIndexQueryCriterion)2 IndexSearchRowImpl (org.apache.ignite.internal.cache.query.index.sorted.IndexSearchRowImpl)2 InlineIndexKeyType (org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndexKeyType)2 JavaObjectIndexKey (org.apache.ignite.internal.cache.query.index.sorted.keys.JavaObjectIndexKey)2 Value (org.h2.value.Value)2 Map (java.util.Map)1 IndexQueryCriterion (org.apache.ignite.cache.query.IndexQueryCriterion)1 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)1 IndexRow (org.apache.ignite.internal.cache.query.index.sorted.IndexRow)1 IndexRowComparator (org.apache.ignite.internal.cache.query.index.sorted.IndexRowComparator)1 InlineIndexRowHandler (org.apache.ignite.internal.cache.query.index.sorted.InlineIndexRowHandler)1 NullableInlineIndexKeyType (org.apache.ignite.internal.cache.query.index.sorted.inline.types.NullableInlineIndexKeyType)1 StringInlineIndexKeyType (org.apache.ignite.internal.cache.query.index.sorted.inline.types.StringInlineIndexKeyType)1 UnsafeMemoryProvider (org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider)1