use of org.apache.ignite.lang.ByteArray in project ignite-3 by apache.
the class WatchAggregatorTest method testTwoEqualExactCriteriaUnion.
@Test
public void testTwoEqualExactCriteriaUnion() {
var watchAggregator = new WatchAggregator();
watchAggregator.add(new ByteArray("key1"), null);
watchAggregator.add(new ByteArray("key1"), null);
var keyCriterion = watchAggregator.watch(0, null).get().keyCriterion();
assertEquals(keyCriterion, keyCriterion);
}
use of org.apache.ignite.lang.ByteArray in project ignite-3 by apache.
the class WatchAggregatorTest method testNullKeyAsStartOfRangeCriterion.
@Test
public void testNullKeyAsStartOfRangeCriterion() {
var watchAggregator = new WatchAggregator();
watchAggregator.add(new ByteArray("key0"), null);
watchAggregator.add(null, new ByteArray("key2"), null);
var keyCriterion = watchAggregator.watch(0, null).get().keyCriterion();
var expKeyCriterion = new KeyCriterion.RangeCriterion(null, new ByteArray("key2"));
assertEquals(expKeyCriterion, keyCriterion);
}
use of org.apache.ignite.lang.ByteArray in project ignite-3 by apache.
the class MetaStorageServiceImpl method multipleEntryResult.
private static Map<ByteArray, Entry> multipleEntryResult(Object obj) {
MultipleEntryResponse resp = (MultipleEntryResponse) obj;
Map<ByteArray, Entry> res = new HashMap<>();
for (SingleEntryResponse e : resp.entries()) {
ByteArray key = new ByteArray(e.key());
res.put(key, new EntryImpl(key, e.value(), e.revision(), e.updateCounter()));
}
return res;
}
use of org.apache.ignite.lang.ByteArray in project ignite-3 by apache.
the class ConcurrentHashMapPartitionStorage method removeAllExact.
/**
* {@inheritDoc}
*/
@Override
public Collection<DataRow> removeAllExact(List<? extends DataRow> keyValues) {
var skippedRows = new ArrayList<DataRow>(keyValues.size());
for (DataRow row : keyValues) {
var key = new ByteArray(row.keyBytes());
byte[] existingValueBytes = map.get(key);
if (Arrays.equals(existingValueBytes, row.valueBytes())) {
map.remove(key);
} else {
skippedRows.add(row);
}
}
return skippedRows;
}
use of org.apache.ignite.lang.ByteArray in project ignite-3 by apache.
the class ConcurrentHashMapPartitionStorage method invoke.
/**
* {@inheritDoc}
*/
@Nullable
@Override
public <T> T invoke(SearchRow key, InvokeClosure<T> clo) throws StorageException {
byte[] keyBytes = key.keyBytes();
ByteArray mapKey = new ByteArray(keyBytes);
byte[] existingDataBytes = map.get(mapKey);
clo.call(existingDataBytes == null ? null : new SimpleDataRow(keyBytes, existingDataBytes));
switch(clo.operationType()) {
case WRITE:
DataRow newRow = clo.newRow();
assert newRow != null;
map.put(mapKey, newRow.valueBytes());
break;
case REMOVE:
map.remove(mapKey);
break;
case NOOP:
break;
default:
throw new UnsupportedOperationException(String.valueOf(clo.operationType()));
}
return clo.result();
}
Aggregations