Search in sources :

Example 6 with IndexRowImpl

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

the class H2RowCacheSelfTest method getLinkForKey.

/**
 * @param cacheName Cache name.
 * @param rowCache Row cache.
 * @param key Key to find.
 * @return Row's link.
 */
private long getLinkForKey(String cacheName, IndexRowCache rowCache, int key) {
    grid().cache(cacheName).query(new SqlQuery(Value.class, "_key = " + key)).getAll().size();
    ConcurrentLinkedHashMap<Long, IndexRowImpl> rowsMap = GridTestUtils.getFieldValue(rowCache, "rows");
    for (Map.Entry<Long, IndexRowImpl> e : rowsMap.entrySet()) {
        IndexRowImpl val = e.getValue();
        KeyCacheObject rowKey = val.cacheDataRow().key();
        if ((Integer) rowKey.value(null, false) == key)
            return e.getKey();
    }
    fail("Row cache doesn't contain key [key=" + key + ']');
    return -1;
}
Also used : SqlQuery(org.apache.ignite.cache.query.SqlQuery) IndexRowImpl(org.apache.ignite.internal.cache.query.index.sorted.IndexRowImpl) ConcurrentLinkedHashMap(org.jsr166.ConcurrentLinkedHashMap) Map(java.util.Map) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject)

Aggregations

IndexRowImpl (org.apache.ignite.internal.cache.query.index.sorted.IndexRowImpl)6 Map (java.util.Map)1 SqlQuery (org.apache.ignite.cache.query.SqlQuery)1 FailureContext (org.apache.ignite.failure.FailureContext)1 IndexRow (org.apache.ignite.internal.cache.query.index.sorted.IndexRow)1 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)1 CacheDataRowAdapter (org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter)1 MvccDataRow (org.apache.ignite.internal.processors.cache.tree.mvcc.data.MvccDataRow)1 ConcurrentLinkedHashMap (org.jsr166.ConcurrentLinkedHashMap)1