
net.oneandone.troilus.WriteQuery Maven / Gradle / Ivy
/*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.troilus;
import java.util.Set;
import net.oneandone.troilus.java7.Batchable;
import net.oneandone.troilus.java7.interceptor.CascadeOnWriteInterceptor;
import net.oneandone.troilus.java7.interceptor.WriteQueryData;
import net.oneandone.troilus.java7.interceptor.WriteQueryRequestInterceptor;
import com.datastax.driver.core.Statement;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
/**
* abstract write query implementation
*/
abstract class WriteQuery extends MutationQuery {
private final WriteQueryData data;
/**
* @param ctx the context
* @param data the data
*/
WriteQuery(Context ctx, WriteQueryData data) {
super(ctx);
this.data = data;
}
protected WriteQueryData getData() {
return data;
}
public CounterMutationQuery incr(String name) {
return incr(name, 1);
}
public CounterMutationQuery incr(String name, long value) {
return new CounterMutationQuery(getContext(),
new CounterMutationQueryData().keys(getData().getKeys())
.whereConditions(getData().getWhereConditions())
.name(name)
.diff(value));
}
public CounterMutationQuery decr(String name) {
return decr(name, 1);
}
public CounterMutationQuery decr(String name, long value) {
return new CounterMutationQuery(getContext(),
new CounterMutationQueryData().keys(getData().getKeys())
.whereConditions(getData().getWhereConditions())
.name(name)
.diff(0 - value));
}
protected ImmutableMap
© 2015 - 2025 Weber Informatics LLC | Privacy Policy