Search in sources :

Example 1 with GridIntList

use of org.apache.ignite.internal.util.GridIntList in project ignite by apache.

the class GridIntListSelfTest method testTruncate.

/**
 */
public void testTruncate() {
    GridIntList list = asList(1, 2, 3, 4, 5, 6, 7, 8);
    list.truncate(4, true);
    assertEquals(asList(1, 2, 3, 4), list);
    list.truncate(2, false);
    assertEquals(asList(3, 4), list);
    list = new GridIntList();
    list.truncate(0, false);
    list.truncate(0, true);
    assertEquals(new GridIntList(), list);
}
Also used : GridIntList(org.apache.ignite.internal.util.GridIntList)

Example 2 with GridIntList

use of org.apache.ignite.internal.util.GridIntList in project ignite by apache.

the class GridIntListSelfTest method testSort.

/**
 */
public void testSort() {
    assertEquals(new GridIntList(), new GridIntList().sort());
    assertEquals(asList(1), asList(1).sort());
    assertEquals(asList(1, 2), asList(2, 1).sort());
    assertEquals(asList(1, 2, 3), asList(2, 1, 3).sort());
    GridIntList list = new GridIntList();
    list.add(4);
    list.add(3);
    list.add(5);
    list.add(1);
    assertEquals(asList(1, 3, 4, 5), list.sort());
    list.add(0);
    assertEquals(asList(1, 3, 4, 5, 0), list);
    assertEquals(asList(0, 1, 3, 4, 5), list.sort());
}
Also used : GridIntList(org.apache.ignite.internal.util.GridIntList)

Example 3 with GridIntList

use of org.apache.ignite.internal.util.GridIntList in project ignite by apache.

the class GridIntListSelfTest method testRemove.

/**
 */
public void testRemove() {
    GridIntList list = asList(1, 2, 3, 4, 5, 6);
    assertEquals(2, list.removeValue(0, 3));
    assertEquals(asList(1, 2, 4, 5, 6), list);
    assertEquals(-1, list.removeValue(1, 1));
    assertEquals(-1, list.removeValue(0, 3));
    assertEquals(4, list.removeValue(0, 6));
    assertEquals(asList(1, 2, 4, 5), list);
    assertEquals(2, list.removeIndex(1));
    assertEquals(asList(1, 4, 5), list);
    assertEquals(1, list.removeIndex(0));
    assertEquals(asList(4, 5), list);
}
Also used : GridIntList(org.apache.ignite.internal.util.GridIntList)

Example 4 with GridIntList

use of org.apache.ignite.internal.util.GridIntList in project ignite by apache.

the class IgniteTxStateImpl method stores.

/**
 * {@inheritDoc}
 */
@Override
public Collection<CacheStoreManager> stores(GridCacheSharedContext cctx) {
    GridIntList cacheIds = activeCacheIds;
    if (!cacheIds.isEmpty()) {
        Collection<CacheStoreManager> stores = new ArrayList<>(cacheIds.size());
        for (int i = 0; i < cacheIds.size(); i++) {
            int cacheId = cacheIds.get(i);
            CacheStoreManager store = cctx.cacheContext(cacheId).store();
            if (store.configured())
                stores.add(store);
        }
        return stores;
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) GridIntList(org.apache.ignite.internal.util.GridIntList) CacheStoreManager(org.apache.ignite.internal.processors.cache.store.CacheStoreManager)

Example 5 with GridIntList

use of org.apache.ignite.internal.util.GridIntList in project ignite by apache.

the class GridDhtAtomicUpdateRequest method addNearWriteValue.

/**
 * {@inheritDoc}
 */
@Override
public void addNearWriteValue(KeyCacheObject key, @Nullable CacheObject val, EntryProcessor<Object, Object, Object> entryProcessor, long ttl, long expireTime) {
    assert key.partition() >= 0 : key;
    if (hasKey(key)) {
        if (obsoleteIndexes == null)
            obsoleteIndexes = new GridIntList();
        obsoleteIndexes.add(keys.indexOf(key));
        return;
    }
    if (nearKeys == null) {
        nearKeys = new ArrayList<>();
        if (forceTransformBackups) {
            nearEntryProcessors = new ArrayList<>();
            nearEntryProcessorsBytes = new ArrayList<>();
        } else
            nearVals = new ArrayList<>();
    }
    nearKeys.add(key);
    if (forceTransformBackups) {
        assert entryProcessor != null;
        nearEntryProcessors.add(entryProcessor);
    } else
        nearVals.add(val);
    if (ttl >= 0) {
        if (nearTtls == null) {
            nearTtls = new GridLongList(nearKeys.size());
            for (int i = 0; i < nearKeys.size() - 1; i++) nearTtls.add(CU.TTL_NOT_CHANGED);
        }
    }
    if (nearTtls != null)
        nearTtls.add(ttl);
    if (expireTime >= 0) {
        if (nearExpireTimes == null) {
            nearExpireTimes = new GridLongList(nearKeys.size());
            for (int i = 0; i < nearKeys.size() - 1; i++) nearExpireTimes.add(CU.EXPIRE_TIME_CALCULATE);
        }
    }
    if (nearExpireTimes != null)
        nearExpireTimes.add(expireTime);
}
Also used : ArrayList(java.util.ArrayList) GridLongList(org.apache.ignite.internal.util.GridLongList) GridIntList(org.apache.ignite.internal.util.GridIntList)

Aggregations

GridIntList (org.apache.ignite.internal.util.GridIntList)7 ArrayList (java.util.ArrayList)3 Collections.singletonList (java.util.Collections.singletonList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 CacheStoreManager (org.apache.ignite.internal.processors.cache.store.CacheStoreManager)1 GridIntIterator (org.apache.ignite.internal.util.GridIntIterator)1 GridLongList (org.apache.ignite.internal.util.GridLongList)1 IntArray (org.h2.util.IntArray)1