Search in sources :

Example 6 with MultiMapRecord

use of com.hazelcast.multimap.impl.MultiMapRecord in project hazelcast by hazelcast.

the class TxnRemoveBackupOperation method run.

@Override
public void run() throws Exception {
    MultiMapContainer container = getOrCreateContainer();
    MultiMapValue multiMapValue = container.getMultiMapValueOrNull(dataKey);
    response = true;
    if (multiMapValue == null || !multiMapValue.containsRecordId(recordId)) {
        response = false;
        return;
    }
    Collection<MultiMapRecord> coll = multiMapValue.getCollection(false);
    Iterator<MultiMapRecord> iter = coll.iterator();
    while (iter.hasNext()) {
        if (iter.next().getRecordId() == recordId) {
            iter.remove();
            break;
        }
    }
    if (coll.isEmpty()) {
        delete();
    }
}
Also used : MultiMapRecord(com.hazelcast.multimap.impl.MultiMapRecord) MultiMapValue(com.hazelcast.multimap.impl.MultiMapValue) MultiMapContainer(com.hazelcast.multimap.impl.MultiMapContainer)

Example 7 with MultiMapRecord

use of com.hazelcast.multimap.impl.MultiMapRecord in project hazelcast by hazelcast.

the class TxnRemoveOperation method run.

@Override
public void run() throws Exception {
    begin = Clock.currentTimeMillis();
    MultiMapContainer container = getOrCreateContainer();
    MultiMapValue multiMapValue = container.getMultiMapValueOrNull(dataKey);
    response = true;
    if (multiMapValue == null || !multiMapValue.containsRecordId(recordId)) {
        response = false;
        return;
    }
    Collection<MultiMapRecord> coll = multiMapValue.getCollection(false);
    Iterator<MultiMapRecord> iter = coll.iterator();
    while (iter.hasNext()) {
        if (iter.next().getRecordId() == recordId) {
            iter.remove();
            break;
        }
    }
    if (coll.isEmpty()) {
        delete();
    }
}
Also used : MultiMapRecord(com.hazelcast.multimap.impl.MultiMapRecord) MultiMapValue(com.hazelcast.multimap.impl.MultiMapValue) MultiMapContainer(com.hazelcast.multimap.impl.MultiMapContainer)

Example 8 with MultiMapRecord

use of com.hazelcast.multimap.impl.MultiMapRecord in project hazelcast by hazelcast.

the class MultiMapRemoveMessageTask method encodeResponse.

@Override
protected ClientMessage encodeResponse(Object response) {
    MultiMapResponse multiMapResponse = (MultiMapResponse) response;
    Collection<MultiMapRecord> collection = multiMapResponse.getCollection();
    List<Data> resultCollection = new ArrayList<Data>(collection.size());
    for (MultiMapRecord multiMapRecord : collection) {
        resultCollection.add(serializationService.toData(multiMapRecord.getObject()));
    }
    return MultiMapRemoveCodec.encodeResponse(resultCollection);
}
Also used : MultiMapRecord(com.hazelcast.multimap.impl.MultiMapRecord) MultiMapResponse(com.hazelcast.multimap.impl.operations.MultiMapResponse) ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data)

Example 9 with MultiMapRecord

use of com.hazelcast.multimap.impl.MultiMapRecord in project hazelcast by hazelcast.

the class TransactionalMultiMapProxy method remove.

@Override
public Collection<V> remove(Object key) {
    checkTransactionActive();
    Data dataKey = getNodeEngine().toData(key);
    Collection<MultiMapRecord> coll = removeAllInternal(dataKey);
    Collection<V> result = new ArrayList<V>(coll.size());
    for (MultiMapRecord record : coll) {
        result.add((V) toObjectIfNeeded(record.getObject()));
    }
    return result;
}
Also used : MultiMapRecord(com.hazelcast.multimap.impl.MultiMapRecord) ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data)

Example 10 with MultiMapRecord

use of com.hazelcast.multimap.impl.MultiMapRecord in project hazelcast by hazelcast.

the class MultiMapGetMessageTask method encodeResponse.

@Override
protected ClientMessage encodeResponse(Object response) {
    List<Data> collection = new ArrayList<Data>();
    Collection<MultiMapRecord> responseCollection = ((MultiMapResponse) response).getCollection();
    if (responseCollection != null) {
        for (MultiMapRecord record : responseCollection) {
            collection.add(serializationService.toData(record.getObject()));
        }
    }
    return MultiMapGetCodec.encodeResponse(collection);
}
Also used : MultiMapRecord(com.hazelcast.multimap.impl.MultiMapRecord) MultiMapResponse(com.hazelcast.multimap.impl.operations.MultiMapResponse) ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data)

Aggregations

MultiMapRecord (com.hazelcast.multimap.impl.MultiMapRecord)26 MultiMapValue (com.hazelcast.multimap.impl.MultiMapValue)11 MultiMapContainer (com.hazelcast.multimap.impl.MultiMapContainer)8 MultiMapResponse (com.hazelcast.multimap.impl.operations.MultiMapResponse)8 Data (com.hazelcast.nio.serialization.Data)7 ArrayList (java.util.ArrayList)5 ConcurrentModificationException (java.util.ConcurrentModificationException)3 List (java.util.List)3 OperationService (com.hazelcast.spi.OperationService)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 MultiMapService (com.hazelcast.multimap.impl.MultiMapService)1 ValueCollectionFactory.createCollection (com.hazelcast.multimap.impl.ValueCollectionFactory.createCollection)1 ValueCollectionFactory.emptyCollection (com.hazelcast.multimap.impl.ValueCollectionFactory.emptyCollection)1 CountOperation (com.hazelcast.multimap.impl.operations.CountOperation)1 GetAllOperation (com.hazelcast.multimap.impl.operations.GetAllOperation)1 TransactionException (com.hazelcast.transaction.TransactionException)1 Collection (java.util.Collection)1 LinkedList (java.util.LinkedList)1