Search in sources :

Example 11 with CollectionItem

use of com.hazelcast.collection.impl.collection.CollectionItem in project hazelcast by hazelcast.

the class ListContainer method rollbackRemove.

@Override
public void rollbackRemove(long itemId) {
    TxCollectionItem txItem = txMap.remove(itemId);
    if (txItem == null) {
        logger.warning("Transaction log cannot be found for rolling back 'remove()' operation." + " Missing log item id: " + itemId);
        return;
    }
    CollectionItem item = new CollectionItem(itemId, txItem.getValue());
    addTxItemOrdered(item);
}
Also used : TxCollectionItem(com.hazelcast.collection.impl.collection.TxCollectionItem) CollectionItem(com.hazelcast.collection.impl.collection.CollectionItem) TxCollectionItem(com.hazelcast.collection.impl.collection.TxCollectionItem)

Example 12 with CollectionItem

use of com.hazelcast.collection.impl.collection.CollectionItem in project hazelcast by hazelcast.

the class ListContainer method indexOf.

public int indexOf(boolean last, Data value) {
    final List<CollectionItem> list = getCollection();
    if (last) {
        int index = list.size();
        final ListIterator<CollectionItem> iterator = list.listIterator(index);
        while (iterator.hasPrevious()) {
            final CollectionItem item = iterator.previous();
            index--;
            if (value.equals(item.getValue())) {
                return index;
            }
        }
    } else {
        int index = -1;
        for (CollectionItem item : list) {
            index++;
            if (value.equals(item.getValue())) {
                return index;
            }
        }
    }
    return -1;
}
Also used : CollectionItem(com.hazelcast.collection.impl.collection.CollectionItem) TxCollectionItem(com.hazelcast.collection.impl.collection.TxCollectionItem)

Example 13 with CollectionItem

use of com.hazelcast.collection.impl.collection.CollectionItem in project hazelcast by hazelcast.

the class CollectionRemoveOperation method run.

@Override
public void run() throws Exception {
    response = false;
    CollectionContainer collectionContainer = getOrCreateContainer();
    CollectionItem item = collectionContainer.remove(value);
    if (item != null) {
        response = true;
        itemId = item.getItemId();
    }
}
Also used : CollectionContainer(com.hazelcast.collection.impl.collection.CollectionContainer) CollectionItem(com.hazelcast.collection.impl.collection.CollectionItem)

Example 14 with CollectionItem

use of com.hazelcast.collection.impl.collection.CollectionItem in project hazelcast by hazelcast.

the class ListGetOperation method run.

@Override
public void run() throws Exception {
    ListContainer listContainer = getOrCreateListContainer();
    CollectionItem item = listContainer.get(index);
    response = item.getValue();
}
Also used : ListContainer(com.hazelcast.collection.impl.list.ListContainer) CollectionItem(com.hazelcast.collection.impl.collection.CollectionItem)

Example 15 with CollectionItem

use of com.hazelcast.collection.impl.collection.CollectionItem in project hazelcast by hazelcast.

the class ListRemoveOperation method run.

@Override
public void run() throws Exception {
    ListContainer listContainer = getOrCreateListContainer();
    final CollectionItem item = listContainer.remove(index);
    itemId = item.getItemId();
    response = item.getValue();
}
Also used : ListContainer(com.hazelcast.collection.impl.list.ListContainer) CollectionItem(com.hazelcast.collection.impl.collection.CollectionItem)

Aggregations

CollectionItem (com.hazelcast.collection.impl.collection.CollectionItem)20 Data (com.hazelcast.nio.serialization.Data)9 TxCollectionItem (com.hazelcast.collection.impl.collection.TxCollectionItem)7 ListContainer (com.hazelcast.collection.impl.list.ListContainer)5 ArrayList (java.util.ArrayList)5 NodeEngine (com.hazelcast.spi.NodeEngine)3 TransactionException (com.hazelcast.transaction.TransactionException)3 CollectionReserveAddOperation (com.hazelcast.collection.impl.txncollection.operations.CollectionReserveAddOperation)2 CollectionTxnAddOperation (com.hazelcast.collection.impl.txncollection.operations.CollectionTxnAddOperation)2 Address (com.hazelcast.nio.Address)2 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)2 HashMap (java.util.HashMap)2 CollectionContainer (com.hazelcast.collection.impl.collection.CollectionContainer)1 ListService (com.hazelcast.collection.impl.list.ListService)1 SetContainer (com.hazelcast.collection.impl.set.SetContainer)1 SetService (com.hazelcast.collection.impl.set.SetService)1 CollectionReserveRemoveOperation (com.hazelcast.collection.impl.txncollection.operations.CollectionReserveRemoveOperation)1 CollectionTxnRemoveOperation (com.hazelcast.collection.impl.txncollection.operations.CollectionTxnRemoveOperation)1 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)1 SerializationServiceBuilder (com.hazelcast.internal.serialization.SerializationServiceBuilder)1