Search in sources :

Example 6 with MultiMapContainer

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

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

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

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

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

the class PutOperation method run.

@Override
public void run() throws Exception {
    MultiMapContainer container = getOrCreateContainer();
    recordId = container.nextId();
    MultiMapRecord record = new MultiMapRecord(recordId, isBinary() ? value : toObject(value));
    Collection<MultiMapRecord> coll = container.getOrCreateMultiMapValue(dataKey).getCollection(false);
    if (index == -1) {
        response = coll.add(record);
    } else {
        try {
            ((List<MultiMapRecord>) coll).add(index, record);
            response = true;
        } catch (IndexOutOfBoundsException e) {
            response = e;
        }
    }
}
Also used : MultiMapRecord(com.hazelcast.multimap.impl.MultiMapRecord) MultiMapContainer(com.hazelcast.multimap.impl.MultiMapContainer) List(java.util.List)

Aggregations

MultiMapContainer (com.hazelcast.multimap.impl.MultiMapContainer)21 MultiMapValue (com.hazelcast.multimap.impl.MultiMapValue)9 MultiMapRecord (com.hazelcast.multimap.impl.MultiMapRecord)8 TransactionException (com.hazelcast.transaction.TransactionException)2 MultiMapConfig (com.hazelcast.config.MultiMapConfig)1 MultiMapResponse (com.hazelcast.multimap.impl.operations.MultiMapResponse)1 Collection (java.util.Collection)1 List (java.util.List)1