@Override public void mutateMany(Map<String, Map<StaticBuffer, KCVMutation>> mutations, StoreTransaction txh) throws BackendException { if (!manager.getFeatures().hasStoreTTL()) { assert manager.getFeatures().hasCellTTL(); for (Map.Entry<String,Map<StaticBuffer, KCVMutation>> sentry : mutations.entrySet()) { Integer ttl = ttlEnabledStores.get(sentry.getKey()); if (null != ttl && 0 < ttl) { for (KCVMutation mut : sentry.getValue().values()) { if (mut.hasAdditions()) applyTTL(mut.getAdditions(), ttl); } } } } manager.mutateMany(mutations,txh); }
@Override public void mutateMany(Map<String, Map<StaticBuffer, KCVMutation>> mutations, StoreTransaction txh) throws BackendException { final Map<String, KVMutation> converted = new HashMap<>(mutations.size()); for (Map.Entry<String, Map<StaticBuffer, KCVMutation>> storeEntry : mutations.entrySet()) { OrderedKeyValueStoreAdapter store = openDatabase(storeEntry.getKey()); Preconditions.checkNotNull(store); KVMutation mut = new KVMutation(); for (Map.Entry<StaticBuffer, KCVMutation> entry : storeEntry.getValue().entrySet()) { StaticBuffer key = entry.getKey(); KCVMutation mutation = entry.getValue(); if (mutation.hasAdditions()) { for (Entry addition : mutation.getAdditions()) { mut.addition(store.concatenate(key,addition)); } } if (mutation.hasDeletions()) { for (StaticBuffer del : mutation.getDeletions()) { mut.deletion(store.concatenate(key, del)); } } } converted.put(storeEntry.getKey(), mut); } manager.mutateMany(converted, txh); }
@Override public Collection<MutateWorker> createMutationWorkers(final Map<StaticBuffer, KCVMutation> mutationMap, final DynamoDbStoreTransaction txh) { final List<MutateWorker> workers = new LinkedList<>(); for (Map.Entry<StaticBuffer, KCVMutation> entry : mutationMap.entrySet()) { final StaticBuffer hashKey = entry.getKey(); final KCVMutation mutation = entry.getValue(); // Filter out deletions that are also added - TODO why use a set? final Set<StaticBuffer> add = mutation.getAdditions().stream() .map(Entry::getColumn).collect(Collectors.toSet()); final List<StaticBuffer> mutableDeletions = mutation.getDeletions().stream() .filter(del -> !add.contains(del)) .collect(Collectors.toList()); if (mutation.hasAdditions()) { workers.addAll(createWorkersForAdditions(hashKey, mutation.getAdditions(), txh)); } if (!mutableDeletions.isEmpty()) { workers.addAll(createWorkersForDeletions(hashKey, mutableDeletions, txh)); } } return workers; }
if (mutation.hasAdditions()) {
if (mutation.hasDeletions() && !mutation.hasAdditions()) { worker = new SingleUpdateWithCleanupWorker(request, client.getDelegate()); } else {