Search in sources :

Example 1 with SearchRow

use of org.apache.ignite.internal.storage.SearchRow in project ignite-3 by apache.

the class ConcurrentHashMapPartitionStorage method removeAll.

/**
 * {@inheritDoc}
 */
@Override
public Collection<SearchRow> removeAll(List<? extends SearchRow> keys) {
    var skippedRows = new ArrayList<SearchRow>(keys.size());
    for (SearchRow key : keys) {
        byte[] keyBytes = key.keyBytes();
        byte[] removedValueBytes = map.remove(new ByteArray(keyBytes));
        if (removedValueBytes == null) {
            skippedRows.add(key);
        }
    }
    return skippedRows;
}
Also used : ArrayList(java.util.ArrayList) ByteArray(org.apache.ignite.lang.ByteArray) SearchRow(org.apache.ignite.internal.storage.SearchRow)

Example 2 with SearchRow

use of org.apache.ignite.internal.storage.SearchRow in project ignite-3 by apache.

the class RocksDbPartitionStorage method removeAll.

/**
 * {@inheritDoc}
 */
@Override
public Collection<SearchRow> removeAll(List<? extends SearchRow> keys) {
    List<SearchRow> skippedRows = new ArrayList<>();
    try (var batch = new WriteBatch();
        var opts = new WriteOptions()) {
        for (SearchRow key : keys) {
            byte[] partitionKey = partitionKey(key);
            byte[] value = data.get(partitionKey);
            if (value != null) {
                data.delete(batch, partitionKey);
            } else {
                skippedRows.add(key);
            }
        }
        db.write(opts, batch);
    } catch (RocksDBException e) {
        throw new StorageException("Failed to remove data from the storage", e);
    }
    return skippedRows;
}
Also used : WriteOptions(org.rocksdb.WriteOptions) RocksDBException(org.rocksdb.RocksDBException) ArrayList(java.util.ArrayList) SearchRow(org.apache.ignite.internal.storage.SearchRow) WriteBatch(org.rocksdb.WriteBatch) StorageException(org.apache.ignite.internal.storage.StorageException)

Aggregations

ArrayList (java.util.ArrayList)2 SearchRow (org.apache.ignite.internal.storage.SearchRow)2 StorageException (org.apache.ignite.internal.storage.StorageException)1 ByteArray (org.apache.ignite.lang.ByteArray)1 RocksDBException (org.rocksdb.RocksDBException)1 WriteBatch (org.rocksdb.WriteBatch)1 WriteOptions (org.rocksdb.WriteOptions)1