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);
}
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());
}
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);
}
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;
}
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);
}
Aggregations