当前位置: 首页>>代码示例>>Java>>正文


Java TColumnValue.setValue方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.thrift2.generated.TColumnValue.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java TColumnValue.setValue方法的具体用法?Java TColumnValue.setValue怎么用?Java TColumnValue.setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.thrift2.generated.TColumnValue的用法示例。


在下文中一共展示了TColumnValue.setValue方法的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;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:30,代码来源:ThriftUtilities.java

示例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;
}
 
开发者ID:apache,项目名称:hbase,代码行数:30,代码来源:ThriftUtilities.java

示例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();
}
 
开发者ID:zwqjsj0404,项目名称:HBase-Research,代码行数:51,代码来源:DemoClient.java


注:本文中的org.apache.hadoop.hbase.thrift2.generated.TColumnValue.setValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。