Search in sources :

Example 1 with NullableInlineIndexKeyType

use of org.apache.ignite.internal.cache.query.index.sorted.inline.types.NullableInlineIndexKeyType 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)

Aggregations

InlineIndexKeyType (org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndexKeyType)1 NullableInlineIndexKeyType (org.apache.ignite.internal.cache.query.index.sorted.inline.types.NullableInlineIndexKeyType)1 IndexKey (org.apache.ignite.internal.cache.query.index.sorted.keys.IndexKey)1 NullIndexKey (org.apache.ignite.internal.cache.query.index.sorted.keys.NullIndexKey)1 Value (org.h2.value.Value)1