org.apache.hadoop.hbase.client.Delete#getTimestamp ( )源码实例Demo

下面列出了org.apache.hadoop.hbase.client.Delete#getTimestamp ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hbase   文件: ThriftUtilities.java
public static TDelete deleteFromHBase(Delete in) {
  TDelete out = new TDelete(ByteBuffer.wrap(in.getRow()));

  List<TColumn> columns = new ArrayList<>(in.getFamilyCellMap().entrySet().size());
  long rowTimestamp = in.getTimestamp();
  if (rowTimestamp != HConstants.LATEST_TIMESTAMP) {
    out.setTimestamp(rowTimestamp);
  }

  for (Map.Entry<String, byte[]> attribute : in.getAttributesMap().entrySet()) {
    out.putToAttributes(ByteBuffer.wrap(Bytes.toBytes(attribute.getKey())),
        ByteBuffer.wrap(attribute.getValue()));
  }
  if (in.getDurability() != Durability.USE_DEFAULT)  {
    out.setDurability(durabilityFromHBase(in.getDurability()));
  }
  // Delete the whole row
  if (in.getFamilyCellMap().size() == 0) {
    return out;
  }
  TDeleteType type = null;
  for (Map.Entry<byte[], List<Cell>> familyEntry:
      in.getFamilyCellMap().entrySet()) {
    byte[] family = familyEntry.getKey();
    TColumn column = new TColumn(ByteBuffer.wrap(familyEntry.getKey()));
    for (Cell cell: familyEntry.getValue()) {
      TDeleteType cellDeleteType = deleteTypeFromHBase(cell.getType());
      if (type == null) {
        type = cellDeleteType;
      } else if (type != cellDeleteType){
        throw new RuntimeException("Only the same delete type is supported, but two delete type "
            + "is founded, one is " + type + " the other one is " + cellDeleteType);
      }
      byte[] qualifier = CellUtil.cloneQualifier(cell);
      long timestamp = cell.getTimestamp();
      column.setFamily(family);
      if (qualifier != null) {
        column.setQualifier(qualifier);
      }
      if (timestamp != HConstants.LATEST_TIMESTAMP) {
        column.setTimestamp(timestamp);
      }
    }
    columns.add(column);
  }
  out.setColumns(columns);
  out.setDeleteType(type);

  return out;
}