com.landawn.abacus.util.AsyncHBaseExecutor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of abacus-android Show documentation
Show all versions of abacus-android Show documentation
A general and simple library for Android
/*
* Copyright (C) 2015 HaiYang Li
*
* 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 com.landawn.abacus.util;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import org.apache.hadoop.hbase.client.Append;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Durability;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Increment;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.RowMutations;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.coprocessor.Batch;
import org.apache.hadoop.hbase.filter.CompareFilter;
import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel;
import com.google.protobuf.Descriptors;
import com.google.protobuf.Message;
import com.google.protobuf.Service;
import com.landawn.abacus.util.stream.Stream;
/**
* Asynchronous HBaseExecutor
.
*
* @since 0.8
*
* @author Haiyang Li
*
* @see http://hbase.apache.org/devapidocs/index.html
* @see org.apache.hadoop.hbase.client.Table
*/
public final class AsyncHBaseExecutor {
private final HBaseExecutor hbaseExecutor;
private final AsyncExecutor asyncExecutor;
AsyncHBaseExecutor(final HBaseExecutor hbaseExecutor, final AsyncExecutor asyncExecutor) {
this.hbaseExecutor = hbaseExecutor;
this.asyncExecutor = asyncExecutor;
}
public HBaseExecutor sync() {
return hbaseExecutor;
}
public ContinuableFuture exists(final String tableName, final Get get) {
return asyncExecutor.execute(new Callable() {
@Override
public Boolean call() throws Exception {
return hbaseExecutor.exists(tableName, get);
}
});
}
public ContinuableFuture> existsAll(final String tableName, final List gets) {
return asyncExecutor.execute(new Callable>() {
@Override
public List call() throws Exception {
return hbaseExecutor.existsAll(tableName, gets);
}
});
}
public ContinuableFuture exists(final String tableName, final AnyGet anyGet) {
return asyncExecutor.execute(new Callable() {
@Override
public Boolean call() throws Exception {
return hbaseExecutor.exists(tableName, anyGet);
}
});
}
public ContinuableFuture> existsAll(final String tableName, final Collection anyGets) {
return asyncExecutor.execute(new Callable>() {
@Override
public List call() throws Exception {
return hbaseExecutor.existsAll(tableName, anyGets);
}
});
}
public ContinuableFuture get(final String tableName, final Get get) {
return asyncExecutor.execute(new Callable() {
@Override
public Result call() throws Exception {
return hbaseExecutor.get(tableName, get);
}
});
}
public ContinuableFuture> get(final String tableName, final List gets) {
return asyncExecutor.execute(new Callable>() {
@Override
public List call() throws Exception {
return hbaseExecutor.get(tableName, gets);
}
});
}
public ContinuableFuture get(final String tableName, final AnyGet anyGet) {
return asyncExecutor.execute(new Callable() {
@Override
public Result call() throws Exception {
return hbaseExecutor.get(tableName, anyGet);
}
});
}
public ContinuableFuture> get(final String tableName, final Collection anyGets) {
return asyncExecutor.execute(new Callable>() {
@Override
public List call() throws Exception {
return hbaseExecutor.get(tableName, anyGets);
}
});
}
public ContinuableFuture get(final Class targetClass, final String tableName, final Get get) {
return asyncExecutor.execute(new Callable() {
@Override
public T call() throws Exception {
return hbaseExecutor.get(targetClass, tableName, get);
}
});
}
public ContinuableFuture> get(final Class targetClass, final String tableName, final List gets) {
return asyncExecutor.execute(new Callable>() {
@Override
public List call() throws Exception {
return hbaseExecutor.get(targetClass, tableName, gets);
}
});
}
public ContinuableFuture get(final Class targetClass, final String tableName, final AnyGet anyGet) {
return asyncExecutor.execute(new Callable() {
@Override
public T call() throws Exception {
return hbaseExecutor.get(targetClass, tableName, anyGet);
}
});
}
public ContinuableFuture> get(final Class targetClass, final String tableName, final Collection anyGets) {
return asyncExecutor.execute(new Callable>() {
@Override
public List call() throws Exception {
return hbaseExecutor.get(targetClass, tableName, anyGets);
}
});
}
public ContinuableFuture> scan(final String tableName, final Scan scan) {
return asyncExecutor.execute(new Callable>() {
@Override
public Stream call() throws Exception {
return hbaseExecutor.scan(tableName, scan);
}
});
}
public ContinuableFuture> scan(final String tableName, final AnyScan anyScan) {
return asyncExecutor.execute(new Callable>() {
@Override
public Stream call() throws Exception {
return hbaseExecutor.scan(tableName, anyScan);
}
});
}
public ContinuableFuture> scan(final String tableName, final String family) {
return asyncExecutor.execute(new Callable>() {
@Override
public Stream call() throws Exception {
return hbaseExecutor.scan(tableName, family);
}
});
}
public ContinuableFuture> scan(final String tableName, final String family, final String qualifier) {
return asyncExecutor.execute(new Callable>() {
@Override
public Stream call() throws Exception {
return hbaseExecutor.scan(tableName, family, qualifier);
}
});
}
public ContinuableFuture> scan(final Class targetClass, final String tableName, final Scan scan) {
return asyncExecutor.execute(new Callable>() {
@Override
public Stream call() throws Exception {
return hbaseExecutor.scan(targetClass, tableName, scan);
}
});
}
public ContinuableFuture> scan(final Class targetClass, final String tableName, final AnyScan anyScan) {
return asyncExecutor.execute(new Callable>() {
@Override
public Stream call() throws Exception {
return hbaseExecutor.scan(targetClass, tableName, anyScan);
}
});
}
public ContinuableFuture> scan(final Class targetClass, final String tableName, final String family) {
return asyncExecutor.execute(new Callable>() {
@Override
public Stream call() throws Exception {
return hbaseExecutor.scan(targetClass, tableName, family);
}
});
}
public ContinuableFuture> scan(final Class targetClass, final String tableName, final String family, final String qualifier) {
return asyncExecutor.execute(new Callable>() {
@Override
public Stream call() throws Exception {
return hbaseExecutor.scan(targetClass, tableName, family, qualifier);
}
});
}
public ContinuableFuture put(final String tableName, final Put put) {
return asyncExecutor.execute(new Callable() {
@Override
public Void call() throws Exception {
hbaseExecutor.put(tableName, put);
return null;
}
});
}
public ContinuableFuture put(final String tableName, final List puts) {
return asyncExecutor.execute(new Callable() {
@Override
public Void call() throws Exception {
hbaseExecutor.put(tableName, puts);
return null;
}
});
}
public ContinuableFuture put(final String tableName, final AnyPut anyPut) {
return asyncExecutor.execute(new Callable() {
@Override
public Void call() throws Exception {
hbaseExecutor.put(tableName, anyPut);
return null;
}
});
}
public ContinuableFuture put(final String tableName, final Collection anyPuts) {
return asyncExecutor.execute(new Callable() {
@Override
public Void call() throws Exception {
hbaseExecutor.put(tableName, anyPuts);
return null;
}
});
}
public ContinuableFuture delete(final String tableName, final Delete delete) {
return asyncExecutor.execute(new Callable() {
@Override
public Void call() throws Exception {
hbaseExecutor.delete(tableName, delete);
return null;
}
});
}
public ContinuableFuture delete(final String tableName, final List deletes) {
return asyncExecutor.execute(new Callable() {
@Override
public Void call() throws Exception {
hbaseExecutor.delete(tableName, deletes);
return null;
}
});
}
public ContinuableFuture delete(final String tableName, final AnyDelete anyDelete) {
return asyncExecutor.execute(new Callable() {
@Override
public Void call() throws Exception {
hbaseExecutor.delete(tableName, anyDelete);
return null;
}
});
}
public ContinuableFuture delete(final String tableName, final Collection anyDeletes) {
return asyncExecutor.execute(new Callable() {
@Override
public Void call() throws Exception {
hbaseExecutor.delete(tableName, anyDeletes);
return null;
}
});
}
public ContinuableFuture checkAndPut(final String tableName, final Object rowKey, final String family, final String qualifier, final Object value,
final Put put) {
return asyncExecutor.execute(new Callable() {
@Override
public Boolean call() throws Exception {
return hbaseExecutor.checkAndPut(tableName, rowKey, family, qualifier, value, put);
}
});
}
public ContinuableFuture checkAndPut(final String tableName, final Object rowKey, final String family, final String qualifier,
final CompareFilter.CompareOp compareOp, final Object value, final Put put) {
return asyncExecutor.execute(new Callable() {
@Override
public Boolean call() throws Exception {
return hbaseExecutor.checkAndPut(tableName, rowKey, family, qualifier, compareOp, value, put);
}
});
}
public ContinuableFuture checkAndDelete(final String tableName, final Object rowKey, final String family, final String qualifier,
final Object value, final Delete delete) {
return asyncExecutor.execute(new Callable() {
@Override
public Boolean call() throws Exception {
return hbaseExecutor.checkAndDelete(tableName, rowKey, family, qualifier, value, delete);
}
});
}
public ContinuableFuture checkAndDelete(final String tableName, final Object rowKey, final String family, final String qualifier,
final CompareFilter.CompareOp compareOp, final Object value, final Delete delete) {
return asyncExecutor.execute(new Callable() {
@Override
public Boolean call() throws Exception {
return hbaseExecutor.checkAndDelete(tableName, rowKey, family, qualifier, compareOp, value, delete);
}
});
}
public ContinuableFuture checkAndMutate(final String tableName, final Object rowKey, final String family, final String qualifier,
final CompareFilter.CompareOp compareOp, final Object value, final RowMutations mutation) {
return asyncExecutor.execute(new Callable() {
@Override
public Boolean call() throws Exception {
return hbaseExecutor.checkAndMutate(tableName, rowKey, family, qualifier, compareOp, value, mutation);
}
});
}
public ContinuableFuture mutateRow(final String tableName, final RowMutations rm) {
return asyncExecutor.execute(new Callable() {
@Override
public Void call() throws Exception {
hbaseExecutor.mutateRow(tableName, rm);
return null;
}
});
}
public ContinuableFuture append(final String tableName, final Append append) {
return asyncExecutor.execute(new Callable() {
@Override
public Result call() throws Exception {
return hbaseExecutor.append(tableName, append);
}
});
}
public ContinuableFuture increment(final String tableName, final Increment increment) {
return asyncExecutor.execute(new Callable() {
@Override
public Result call() throws Exception {
return hbaseExecutor.increment(tableName, increment);
}
});
}
public ContinuableFuture incrementColumnValue(final String tableName, final Object rowKey, final String family, final String qualifier,
final long amount) {
return asyncExecutor.execute(new Callable() {
@Override
public Long call() throws Exception {
return hbaseExecutor.incrementColumnValue(tableName, rowKey, family, qualifier, amount);
}
});
}
public ContinuableFuture incrementColumnValue(final String tableName, final Object rowKey, final String family, final String qualifier,
final long amount, final Durability durability) {
return asyncExecutor.execute(new Callable() {
@Override
public Long call() throws Exception {
return hbaseExecutor.incrementColumnValue(tableName, rowKey, family, qualifier, amount, durability);
}
});
}
ContinuableFuture coprocessorService(final String tableName, final Object rowKey) {
return asyncExecutor.execute(new Callable() {
@Override
public CoprocessorRpcChannel call() throws Exception {
return hbaseExecutor.coprocessorService(tableName, rowKey);
}
});
}
ContinuableFuture