Search in sources :

Example 1 with BytesMapPersist

use of com.tvd12.calabash.persist.BytesMapPersist in project calabash by youngmonkeys.

the class SimpleBytesMapFactory method newMapPersist.

protected void newMapPersist(String mapName) {
    BytesMapPersist mapPersist = bytesMapPersistFactory.newMapPersist(mapName);
    mapPersistManager.addMapPersist(mapName, mapPersist);
}
Also used : BytesMapPersist(com.tvd12.calabash.persist.BytesMapPersist)

Example 2 with BytesMapPersist

use of com.tvd12.calabash.persist.BytesMapPersist in project calabash by youngmonkeys.

the class SimpleBytesMapPersistExecutor method delete.

@Override
public void delete(MapSetting mapSetting, ByteArray key) {
    BytesMapPersist mapPersist = getMapPersist(mapSetting);
    if (mapPersist != null) {
        PersistDeleteOneAction action = new PersistDeleteOneAction(key);
        addPersistActionToQueue(mapSetting, action);
    }
}
Also used : BytesMapPersist(com.tvd12.calabash.persist.BytesMapPersist)

Example 3 with BytesMapPersist

use of com.tvd12.calabash.persist.BytesMapPersist in project calabash by youngmonkeys.

the class PersistDeleteActionBulk method execute.

@Override
public void execute() {
    Set keys = new HashSet<>();
    for (PersistAction action : actions) {
        if (action.getType() == PersistActionType.DELETE_ONE) {
            keys.add(((PersistDeleteOneAction) action).getKey());
        } else {
            keys.addAll(((PersistDeleteManyAction) action).getKeys());
        }
    }
    ((BytesMapPersist) mapPersist).delete(keys);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) PersistAction(com.tvd12.calabash.persist.action.PersistAction) BytesMapPersist(com.tvd12.calabash.persist.BytesMapPersist) HashSet(java.util.HashSet)

Example 4 with BytesMapPersist

use of com.tvd12.calabash.persist.BytesMapPersist in project calabash by youngmonkeys.

the class PersistSaveActionBulk method execute.

@Override
public void execute() {
    Map keyValues = new HashMap<>();
    for (PersistAction action : actions) {
        if (action.getType() == PersistActionType.SAVE_ONE) {
            PersistSaveOneAction one = (PersistSaveOneAction) action;
            keyValues.put(one.getKey(), one.getValue());
        } else {
            PersistSaveManyAction many = (PersistSaveManyAction) action;
            keyValues.putAll(many.getKeyValues());
        }
    }
    ((BytesMapPersist) mapPersist).persist(keyValues);
}
Also used : PersistSaveManyAction(com.tvd12.calabash.persist.action.PersistSaveManyAction) HashMap(java.util.HashMap) PersistSaveOneAction(com.tvd12.calabash.persist.action.PersistSaveOneAction) PersistAction(com.tvd12.calabash.persist.action.PersistAction) BytesMapPersist(com.tvd12.calabash.persist.BytesMapPersist) Map(java.util.Map) HashMap(java.util.HashMap)

Example 5 with BytesMapPersist

use of com.tvd12.calabash.persist.BytesMapPersist in project calabash by youngmonkeys.

the class SimpleBytesMapPersistExecutor method persist.

@Override
public void persist(MapSetting mapSetting, Map<ByteArray, byte[]> m) {
    BytesMapPersist mapPersist = getMapPersist(mapSetting);
    if (mapPersist != null) {
        PersistSaveManyAction action = new PersistSaveManyAction(m);
        addPersistActionToQueue(mapSetting, action);
    }
}
Also used : BytesMapPersist(com.tvd12.calabash.persist.BytesMapPersist)

Aggregations

BytesMapPersist (com.tvd12.calabash.persist.BytesMapPersist)7 PersistAction (com.tvd12.calabash.persist.action.PersistAction)2 PersistSaveManyAction (com.tvd12.calabash.persist.action.PersistSaveManyAction)1 PersistSaveOneAction (com.tvd12.calabash.persist.action.PersistSaveOneAction)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1