com.scalar.db.common.AbstractDistributedTransaction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scalardb Show documentation
Show all versions of scalardb Show documentation
A universal transaction manager that achieves database-agnostic transactions and distributed transactions that span multiple databases
The newest version!
package com.scalar.db.common;
import com.scalar.db.api.Delete;
import com.scalar.db.api.DistributedTransaction;
import com.scalar.db.api.Get;
import com.scalar.db.api.Insert;
import com.scalar.db.api.Mutation;
import com.scalar.db.api.Put;
import com.scalar.db.api.Scan;
import com.scalar.db.api.Update;
import com.scalar.db.api.Upsert;
import com.scalar.db.util.ScalarDbUtils;
import java.util.List;
import java.util.Optional;
public abstract class AbstractDistributedTransaction implements DistributedTransaction {
private Optional namespace;
private Optional tableName;
public AbstractDistributedTransaction() {
namespace = Optional.empty();
tableName = Optional.empty();
}
/** @deprecated As of release 3.6.0. Will be removed in release 5.0.0 */
@Deprecated
@Override
public void with(String namespace, String tableName) {
this.namespace = Optional.ofNullable(namespace);
this.tableName = Optional.ofNullable(tableName);
}
/** @deprecated As of release 3.6.0. Will be removed in release 5.0.0 */
@Deprecated
@Override
public void withNamespace(String namespace) {
this.namespace = Optional.ofNullable(namespace);
}
/** @deprecated As of release 3.6.0. Will be removed in release 5.0.0 */
@Deprecated
@Override
public Optional getNamespace() {
return namespace;
}
/** @deprecated As of release 3.6.0. Will be removed in release 5.0.0 */
@Deprecated
@Override
public void withTable(String tableName) {
this.tableName = Optional.ofNullable(tableName);
}
/** @deprecated As of release 3.6.0. Will be removed in release 5.0.0 */
@Deprecated
@Override
public Optional getTable() {
return tableName;
}
protected List copyAndSetTargetToIfNot(List mutations) {
return ScalarDbUtils.copyAndSetTargetToIfNot(mutations, namespace, tableName);
}
protected Get copyAndSetTargetToIfNot(Get get) {
return ScalarDbUtils.copyAndSetTargetToIfNot(get, namespace, tableName);
}
protected Scan copyAndSetTargetToIfNot(Scan scan) {
return ScalarDbUtils.copyAndSetTargetToIfNot(scan, namespace, tableName);
}
protected Put copyAndSetTargetToIfNot(Put put) {
return ScalarDbUtils.copyAndSetTargetToIfNot(put, namespace, tableName);
}
protected Delete copyAndSetTargetToIfNot(Delete delete) {
return ScalarDbUtils.copyAndSetTargetToIfNot(delete, namespace, tableName);
}
protected Insert copyAndSetTargetToIfNot(Insert insert) {
return ScalarDbUtils.copyAndSetTargetToIfNot(insert, namespace, tableName);
}
protected Upsert copyAndSetTargetToIfNot(Upsert upsert) {
return ScalarDbUtils.copyAndSetTargetToIfNot(upsert, namespace, tableName);
}
protected Update copyAndSetTargetToIfNot(Update update) {
return ScalarDbUtils.copyAndSetTargetToIfNot(update, namespace, tableName);
}
}