本文整理汇总了Java中org.apache.hadoop.hbase.thrift2.generated.TColumnValue.setFamily方法的典型用法代码示例。如果您正苦于以下问题:Java TColumnValue.setFamily方法的具体用法?Java TColumnValue.setFamily怎么用?Java TColumnValue.setFamily使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.thrift2.generated.TColumnValue
的用法示例。
在下文中一共展示了TColumnValue.setFamily方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resultFromHBase
import org.apache.hadoop.hbase.thrift2.generated.TColumnValue; //导入方法依赖的package包/类
/**
* Creates a {@link TResult} (Thrift) from a {@link Result} (HBase).
*
* @param in the <code>Result</code> to convert
*
* @return converted result, returns an empty result if the input is <code>null</code>
*/
public static TResult resultFromHBase(Result in) {
Cell[] raw = in.rawCells();
TResult out = new TResult();
byte[] row = in.getRow();
if (row != null) {
out.setRow(in.getRow());
}
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
for (Cell kv : raw) {
TColumnValue col = new TColumnValue();
col.setFamily(CellUtil.cloneFamily(kv));
col.setQualifier(CellUtil.cloneQualifier(kv));
col.setTimestamp(kv.getTimestamp());
col.setValue(CellUtil.cloneValue(kv));
if (kv.getTagsLength() > 0) {
col.setTags(CellUtil.getTagArray(kv));
}
columnValues.add(col);
}
out.setColumnValues(columnValues);
return out;
}
示例2: resultFromHBase
import org.apache.hadoop.hbase.thrift2.generated.TColumnValue; //导入方法依赖的package包/类
/**
* Creates a {@link TResult} (Thrift) from a {@link Result} (HBase).
*
* @param in the <code>Result</code> to convert
*
* @return converted result, returns an empty result if the input is <code>null</code>
*/
public static TResult resultFromHBase(Result in) {
Cell[] raw = in.rawCells();
TResult out = new TResult();
byte[] row = in.getRow();
if (row != null) {
out.setRow(in.getRow());
}
List<TColumnValue> columnValues = new ArrayList<>(raw.length);
for (Cell kv : raw) {
TColumnValue col = new TColumnValue();
col.setFamily(CellUtil.cloneFamily(kv));
col.setQualifier(CellUtil.cloneQualifier(kv));
col.setTimestamp(kv.getTimestamp());
col.setValue(CellUtil.cloneValue(kv));
if (kv.getTagsLength() > 0) {
col.setTags(PrivateCellUtil.cloneTags(kv));
}
columnValues.add(col);
}
out.setColumnValues(columnValues);
return out;
}
示例3: main
import org.apache.hadoop.hbase.thrift2.generated.TColumnValue; //导入方法依赖的package包/类
public static void main(String[] args) throws TIOError, TException {
System.out.println("Thrift2 Demo");
System.out.println("This demo assumes you have a table called \"example\" with a column family called \"family1\"");
String host = "localhost";
int port = 9090;
int timeout = 10000;
boolean framed = false;
TTransport transport = new TSocket(host, port, timeout);
if (framed) {
transport = new TFramedTransport(transport);
}
TProtocol protocol = new TBinaryProtocol(transport);
// This is our thrift client.
THBaseService.Iface client = new THBaseService.Client(protocol);
// open the transport
transport.open();
ByteBuffer table = ByteBuffer.wrap("example".getBytes());
TPut put = new TPut();
put.setRow("row1".getBytes());
TColumnValue columnValue = new TColumnValue();
columnValue.setFamily("family1".getBytes());
columnValue.setQualifier("qualifier1".getBytes());
columnValue.setValue("value1".getBytes());
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
columnValues.add(columnValue);
put.setColumnValues(columnValues);
client.put(table, put);
TGet get = new TGet();
get.setRow("row1".getBytes());
TResult result = client.get(table, get);
System.out.print("row = " + new String(result.getRow()));
for (TColumnValue resultColumnValue : result.getColumnValues()) {
System.out.print("family = " + new String(resultColumnValue.getFamily()));
System.out.print("qualifier = " + new String(resultColumnValue.getFamily()));
System.out.print("value = " + new String(resultColumnValue.getValue()));
System.out.print("timestamp = " + resultColumnValue.getTimestamp());
}
transport.close();
}