Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.hydraql.thrift;
import com.hydraql.common.callback.RowMapper;
import com.hydraql.common.model.data.HBaseRowData;
import com.hydraql.common.model.data.HBaseRowDataWithMultiVersions;
import com.hydraql.common.query.GetRowParam;
import com.hydraql.common.query.GetRowsParam;
import com.hydraql.common.query.ScanParams;
import java.io.Closeable;
import java.util.List;
import java.util.Map;
/**
* @author leojie 2020/12/27 2:48 下午
*/
public class HBaseThrift implements Closeable, IHBaseThriftOperations {
protected HBaseThriftClient hBaseThriftClient;
protected HBaseThriftPoolAbstract dataSource = null;
public HBaseThrift() {
hBaseThriftClient = new HBaseThriftClient();
}
public HBaseThrift(final String host) {
hBaseThriftClient = new HBaseThriftClient(host);
}
public HBaseThrift(final String host, final int port) {
hBaseThriftClient = new HBaseThriftClient(host, port);
}
public HBaseThrift(final String host, final int port, final int timeout) {
this(host, port, timeout, timeout);
}
public HBaseThrift(final String host, final int port, final int connectionTimeout,
final int socketTimeout) {
hBaseThriftClient = new HBaseThriftClient(host, port, connectionTimeout, socketTimeout);
}
public HBaseThrift(final IHBaseThriftTSocket thriftTSocketFactory) {
hBaseThriftClient = new HBaseThriftClient(thriftTSocketFactory);
}
@Override
public void save(String tableName, String rowKey, Map data) {
hBaseThriftClient.save(tableName, rowKey, data);
}
@Override
public void save(T t) {
hBaseThriftClient.save(t);
}
@Override
public void saveBatch(String tableName, Map> data) {
hBaseThriftClient.saveBatch(tableName, data);
}
@Override
public void saveBatch(List list) {
hBaseThriftClient.saveBatch(list);
}
@Override
public T getRow(GetRowParam getRowParam, Class clazz) {
return hBaseThriftClient.getRow(getRowParam, clazz);
}
@Override
public T getRow(String tableName, GetRowParam getRowParam, RowMapper rowMapper) {
return hBaseThriftClient.getRow(tableName, getRowParam, rowMapper);
}
@Override
public HBaseRowData getRow(String tableName, GetRowParam getRowParam) {
return hBaseThriftClient.getRow(tableName, getRowParam);
}
@Override
public List getWithMultiVersions(GetRowParam getRowParam, Class clazz) {
return hBaseThriftClient.getWithMultiVersions(getRowParam, clazz);
}
@Override
public List getWithMultiVersions(String tableName, GetRowParam getRowParam,
RowMapper rowMapper) {
return hBaseThriftClient.getWithMultiVersions(tableName, getRowParam, rowMapper);
}
@Override
public HBaseRowDataWithMultiVersions getWithMultiVersions(String tableName,
GetRowParam getRowParam) {
return hBaseThriftClient.getWithMultiVersions(tableName, getRowParam);
}
@Override
public List getRows(GetRowsParam getRowsParam, Class clazz) {
return hBaseThriftClient.getRows(getRowsParam, clazz);
}
@Override
public List getRows(String tableName, GetRowsParam getRowsParams, RowMapper rowMapper) {
return hBaseThriftClient.getRows(tableName, getRowsParams, rowMapper);
}
@Override
public List getRows(String tableName, GetRowsParam getRowsParam) {
return hBaseThriftClient.getRows(tableName, getRowsParam);
}
@Override
public List scan(ScanParams scanQueryParams, Class clazz) {
return hBaseThriftClient.scan(scanQueryParams, clazz);
}
@Override
public List scan(String tableName, ScanParams scanQueryParams, RowMapper rowMapper) {
return hBaseThriftClient.scan(tableName, scanQueryParams, rowMapper);
}
@Override
public List scan(String tableName, ScanParams scanQueryParams) {
return hBaseThriftClient.scan(tableName, scanQueryParams);
}
@Override
public List scanWithMultiVersions(String tableName,
ScanParams scanParams) {
return null;
}
@Override
public void delete(T t) {
hBaseThriftClient.delete(t);
}
@Override
public void delete(String tableName, String rowKey) {
hBaseThriftClient.delete(tableName, rowKey);
}
@Override
public void delete(String tableName, String rowKey, String familyName) {
hBaseThriftClient.delete(tableName, rowKey, familyName);
}
@Override
public void delete(String tableName, String rowKey, String familyName, List qualifiers) {
hBaseThriftClient.delete(tableName, rowKey, familyName, qualifiers);
}
@Override
public void delete(String tableName, String rowKey, String familyName, String... qualifiers) {
hBaseThriftClient.delete(tableName, rowKey, familyName, qualifiers);
}
@Override
public void deleteBatch(List list) {
hBaseThriftClient.deleteBatch(list);
}
@Override
public void deleteBatch(String tableName, List rowKeys) {
hBaseThriftClient.deleteBatch(tableName, rowKeys, null);
}
@Override
public void deleteBatch(String tableName, List rowKeys, String familyName) {
hBaseThriftClient.deleteBatch(tableName, rowKeys, familyName);
}
@Override
public void deleteBatch(String tableName, List rowKeys, String familyName,
List qualifiers) {
hBaseThriftClient.deleteBatch(tableName, rowKeys, familyName, qualifiers);
}
@Override
public void deleteBatch(String tableName, List rowKeys, String familyName,
String... qualifiers) {
hBaseThriftClient.deleteBatch(tableName, rowKeys, familyName, qualifiers);
}
public void connect() {
hBaseThriftClient.connect();
}
public boolean isConnected() {
return hBaseThriftClient.isConnected();
}
public void disconnect() {
hBaseThriftClient.disconnect();
}
public boolean ping() {
try {
return hBaseThriftClient.ping();
} catch (Exception e) {
return false;
}
}
@Override
public void close() {
if (dataSource != null) {
HBaseThriftPoolAbstract pool = this.dataSource;
this.dataSource = null;
if (hBaseThriftClient.isBroken()) {
pool.returnBrokenResource(this);
} else {
pool.returnResource(this);
}
} else {
hBaseThriftClient.close();
}
}
public void setDataSource(HBaseThriftPoolAbstract poolAbstract) {
this.dataSource = poolAbstract;
}
}