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


Java Get.hasFamilies方法代码示例

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


在下文中一共展示了Get.hasFamilies方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toGet

import org.apache.hadoop.hbase.client.Get; //导入方法依赖的package包/类
/**
 * Create a protocol buffer Get based on a client Get.
 *
 * @param get the client Get
 * @return a protocol buffer Get
 * @throws IOException
 */
public static ClientProtos.Get toGet(
    final Get get) throws IOException {
  ClientProtos.Get.Builder builder =
    ClientProtos.Get.newBuilder();
  builder.setRow(ByteStringer.wrap(get.getRow()));
  builder.setCacheBlocks(get.getCacheBlocks());
  builder.setMaxVersions(get.getMaxVersions());
  if (get.getFilter() != null) {
    builder.setFilter(ProtobufUtil.toFilter(get.getFilter()));
  }
  for (Entry<byte[], TimeRange> cftr : get.getColumnFamilyTimeRange().entrySet()) {
    HBaseProtos.ColumnFamilyTimeRange.Builder b = HBaseProtos.ColumnFamilyTimeRange.newBuilder();
    b.setColumnFamily(ByteString.copyFrom(cftr.getKey()));
    b.setTimeRange(timeRangeToProto(cftr.getValue()));
    builder.addCfTimeRange(b);
  }
  TimeRange timeRange = get.getTimeRange();
  if (!timeRange.isAllTime()) {
    HBaseProtos.TimeRange.Builder timeRangeBuilder =
      HBaseProtos.TimeRange.newBuilder();
    timeRangeBuilder.setFrom(timeRange.getMin());
    timeRangeBuilder.setTo(timeRange.getMax());
    builder.setTimeRange(timeRangeBuilder.build());
  }
  Map<String, byte[]> attributes = get.getAttributesMap();
  if (!attributes.isEmpty()) {
    NameBytesPair.Builder attributeBuilder = NameBytesPair.newBuilder();
    for (Map.Entry<String, byte[]> attribute: attributes.entrySet()) {
      attributeBuilder.setName(attribute.getKey());
      attributeBuilder.setValue(ByteStringer.wrap(attribute.getValue()));
      builder.addAttribute(attributeBuilder.build());
    }
  }
  if (get.hasFamilies()) {
    Column.Builder columnBuilder = Column.newBuilder();
    Map<byte[], NavigableSet<byte[]>> families = get.getFamilyMap();
    for (Map.Entry<byte[], NavigableSet<byte[]>> family: families.entrySet()) {
      NavigableSet<byte[]> qualifiers = family.getValue();
      columnBuilder.setFamily(ByteStringer.wrap(family.getKey()));
      columnBuilder.clearQualifier();
      if (qualifiers != null && qualifiers.size() > 0) {
        for (byte[] qualifier: qualifiers) {
          columnBuilder.addQualifier(ByteStringer.wrap(qualifier));
        }
      }
      builder.addColumn(columnBuilder.build());
    }
  }
  if (get.getMaxResultsPerColumnFamily() >= 0) {
    builder.setStoreLimit(get.getMaxResultsPerColumnFamily());
  }
  if (get.getRowOffsetPerColumnFamily() > 0) {
    builder.setStoreOffset(get.getRowOffsetPerColumnFamily());
  }
  if (get.isCheckExistenceOnly()){
    builder.setExistenceOnly(true);
  }
  if (get.isClosestRowBefore()){
    builder.setClosestRowBefore(true);
  }
  if (get.getConsistency() != null && get.getConsistency() != Consistency.STRONG) {
    builder.setConsistency(toConsistency(get.getConsistency()));
  }

  return builder.build();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:74,代码来源:ProtobufUtil.java


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