Search in sources :

Example 1 with MultiMapValue

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

the class TxnPutBackupOperation method run.

@Override
public void run() throws Exception {
    MultiMapContainer container = getOrCreateContainer();
    MultiMapValue multiMapValue = container.getOrCreateMultiMapValue(dataKey);
    response = true;
    if (multiMapValue.containsRecordId(recordId)) {
        response = false;
        return;
    }
    Collection<MultiMapRecord> coll = multiMapValue.getCollection(false);
    MultiMapRecord record = new MultiMapRecord(recordId, isBinary() ? value : toObject(value));
    coll.add(record);
}
Also used : MultiMapRecord(com.hazelcast.multimap.impl.MultiMapRecord) MultiMapValue(com.hazelcast.multimap.impl.MultiMapValue) MultiMapContainer(com.hazelcast.multimap.impl.MultiMapContainer)

Example 2 with MultiMapValue

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

the class TxnPutOperation method run.

@Override
public void run() throws Exception {
    begin = Clock.currentTimeMillis();
    MultiMapContainer container = getOrCreateContainer();
    MultiMapValue multiMapValue = container.getOrCreateMultiMapValue(dataKey);
    response = true;
    if (multiMapValue.containsRecordId(recordId)) {
        response = false;
        return;
    }
    Collection<MultiMapRecord> coll = multiMapValue.getCollection(false);
    MultiMapRecord record = new MultiMapRecord(recordId, isBinary() ? value : toObject(value));
    coll.add(record);
}
Also used : MultiMapRecord(com.hazelcast.multimap.impl.MultiMapRecord) MultiMapValue(com.hazelcast.multimap.impl.MultiMapValue) MultiMapContainer(com.hazelcast.multimap.impl.MultiMapContainer)

Example 3 with MultiMapValue

use of com.hazelcast.multimap.impl.MultiMapValue 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 4 with MultiMapValue

use of com.hazelcast.multimap.impl.MultiMapValue 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 5 with MultiMapValue

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

the class MultiMapKeyValueSource method hasNext.

@Override
public boolean hasNext() {
    if (valueIterator != null) {
        boolean hasNext = valueIterator.hasNext();
        multiMapRecord = hasNext ? valueIterator.next() : null;
        if (hasNext) {
            return true;
        }
    }
    if (keyIterator != null && keyIterator.hasNext()) {
        Data dataKey = keyIterator.next();
        key = (K) ss.toObject(dataKey);
        MultiMapValue wrapper = multiMapContainer.getMultiMapValueOrNull(dataKey);
        valueIterator = wrapper.getCollection(true).iterator();
        return hasNext();
    }
    return false;
}
Also used : MultiMapValue(com.hazelcast.multimap.impl.MultiMapValue) Data(com.hazelcast.nio.serialization.Data)

Aggregations

MultiMapValue (com.hazelcast.multimap.impl.MultiMapValue)14 MultiMapRecord (com.hazelcast.multimap.impl.MultiMapRecord)11 MultiMapContainer (com.hazelcast.multimap.impl.MultiMapContainer)9 Data (com.hazelcast.nio.serialization.Data)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 MultiMapResponse (com.hazelcast.multimap.impl.operations.MultiMapResponse)1 TransactionException (com.hazelcast.transaction.TransactionException)1 Collection (java.util.Collection)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1