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


Java NameBytesPair.Builder方法代码示例

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


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

示例1: getMutationBuilderAndSetCommonFields

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair; //导入方法依赖的package包/类
/**
 * Code shared by {@link #toMutation(MutationType, Mutation)} and
 * {@link #toMutationNoData(MutationType, Mutation)}
 * @param type
 * @param mutation
 * @return A partly-filled out protobuf'd Mutation.
 */
private static MutationProto.Builder getMutationBuilderAndSetCommonFields(final MutationType type,
    final Mutation mutation, MutationProto.Builder builder) {
  builder.setRow(ByteStringer.wrap(mutation.getRow()));
  builder.setMutateType(type);
  builder.setDurability(toDurability(mutation.getDurability()));
  builder.setTimestamp(mutation.getTimeStamp());
  Map<String, byte[]> attributes = mutation.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());
    }
  }
  return builder;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:25,代码来源:ProtobufUtil.java

示例2: getMutationBuilderAndSetCommonFields

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair; //导入方法依赖的package包/类
/**
 * Code shared by {@link #toMutation(MutationType, Mutation)} and
 * {@link #toMutationNoData(MutationType, Mutation)}
 * @param type
 * @param mutation
 * @return A partly-filled out protobuf'd Mutation.
 */
private static MutationProto.Builder getMutationBuilderAndSetCommonFields(final MutationType type,
    final Mutation mutation, MutationProto.Builder builder) {
  builder.setRow(HBaseZeroCopyByteString.wrap(mutation.getRow()));
  builder.setMutateType(type);
  builder.setDurability(toDurability(mutation.getDurability()));
  builder.setTimestamp(mutation.getTimeStamp());
  Map<String, byte[]> attributes = mutation.getAttributesMap();
  if (!attributes.isEmpty()) {
    NameBytesPair.Builder attributeBuilder = NameBytesPair.newBuilder();
    for (Map.Entry<String, byte[]> attribute: attributes.entrySet()) {
      attributeBuilder.setName(attribute.getKey());
      attributeBuilder.setValue(HBaseZeroCopyByteString.wrap(attribute.getValue()));
      builder.addAttribute(attributeBuilder.build());
    }
  }
  return builder;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:25,代码来源:ProtobufUtil.java

示例3: getMutationBuilderAndSetCommonFields

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair; //导入方法依赖的package包/类
/**
 * Code shared by {@link #toMutation(MutationType, Mutation)} and
 * {@link #toMutationNoData(MutationType, Mutation)}
 * @param type
 * @param mutation
 * @return A partly-filled out protobuf'd Mutation.
 */
private static MutationProto.Builder getMutationBuilderAndSetCommonFields(final MutationType type,
    final Mutation mutation, MutationProto.Builder builder) {
  builder.setRow(ZeroCopyLiteralByteString.wrap(mutation.getRow()));
  builder.setMutateType(type);
  builder.setDurability(toDurability(mutation.getDurability()));
  builder.setTimestamp(mutation.getTimeStamp());
  Map<String, byte[]> attributes = mutation.getAttributesMap();
  if (!attributes.isEmpty()) {
    NameBytesPair.Builder attributeBuilder = NameBytesPair.newBuilder();
    for (Map.Entry<String, byte[]> attribute: attributes.entrySet()) {
      attributeBuilder.setName(attribute.getKey());
      attributeBuilder.setValue(ZeroCopyLiteralByteString.wrap(attribute.getValue()));
      builder.addAttribute(attributeBuilder.build());
    }
  }
  return builder;
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:25,代码来源:ProtobufUtil.java

示例4: testException

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair; //导入方法依赖的package包/类
@Test
public void testException() throws IOException {
  NameBytesPair.Builder builder = NameBytesPair.newBuilder();
  final String omg = "OMG!!!";
  builder.setName("java.io.IOException");
  builder.setValue(ByteStringer.wrap(Bytes.toBytes(omg)));
  Throwable t = ProtobufUtil.toException(builder.build());
  assertEquals(omg, t.getMessage());
  builder.clear();
  builder.setName("org.apache.hadoop.ipc.RemoteException");
  builder.setValue(ByteStringer.wrap(Bytes.toBytes(omg)));
  t = ProtobufUtil.toException(builder.build());
  assertEquals(omg, t.getMessage());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:TestProtobufUtil.java

示例5: buildException

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair; //导入方法依赖的package包/类
/**
 * @param t
 * @return NameValuePair of the exception name to stringified version os exception.
 */
public static NameBytesPair buildException(final Throwable t) {
  NameBytesPair.Builder parameterBuilder = NameBytesPair.newBuilder();
  parameterBuilder.setName(t.getClass().getName());
  parameterBuilder.setValue(
    ByteString.copyFromUtf8(StringUtils.stringifyException(t)));
  return parameterBuilder.build();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:ResponseConverter.java

示例6: testException

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair; //导入方法依赖的package包/类
@Test
public void testException() throws IOException {
  NameBytesPair.Builder builder = NameBytesPair.newBuilder();
  final String omg = "OMG!!!";
  builder.setName("java.io.IOException");
  builder.setValue(HBaseZeroCopyByteString.wrap(Bytes.toBytes(omg)));
  Throwable t = ProtobufUtil.toException(builder.build());
  assertEquals(omg, t.getMessage());
  builder.clear();
  builder.setName("org.apache.hadoop.ipc.RemoteException");
  builder.setValue(HBaseZeroCopyByteString.wrap(Bytes.toBytes(omg)));
  t = ProtobufUtil.toException(builder.build());
  assertEquals(omg, t.getMessage());
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:15,代码来源:TestProtobufUtil.java

示例7: buildException

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair; //导入方法依赖的package包/类
/**
 * @param t
 * @return NameValuePair of the exception name to stringified version os exception.
 */
// Copied from ResponseConverter and made private. Only used in here.
private static NameBytesPair buildException(final Throwable t) {
  NameBytesPair.Builder parameterBuilder = NameBytesPair.newBuilder();
  parameterBuilder.setName(t.getClass().getName());
  parameterBuilder.setValue(
    ByteString.copyFromUtf8(StringUtils.stringifyException(t)));
  return parameterBuilder.build();
}
 
开发者ID:apache,项目名称:hbase,代码行数:13,代码来源:VisibilityController.java

示例8: testException

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair; //导入方法依赖的package包/类
@Test
public void testException() throws IOException {
  NameBytesPair.Builder builder = NameBytesPair.newBuilder();
  final String omg = "OMG!!!";
  builder.setName("java.io.IOException");
  builder.setValue(ByteString.copyFrom(Bytes.toBytes(omg)));
  Throwable t = ProtobufUtil.toException(builder.build());
  assertEquals(omg, t.getMessage());
  builder.clear();
  builder.setName("org.apache.hadoop.ipc.RemoteException");
  builder.setValue(ByteString.copyFrom(Bytes.toBytes(omg)));
  t = ProtobufUtil.toException(builder.build());
  assertEquals(omg, t.getMessage());
}
 
开发者ID:apache,项目名称:hbase,代码行数:15,代码来源:TestProtobufUtil.java

示例9: testException

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair; //导入方法依赖的package包/类
@Test
public void testException() throws IOException {
  NameBytesPair.Builder builder = NameBytesPair.newBuilder();
  final String omg = "OMG!!!";
  builder.setName("java.io.IOException");
  builder.setValue(ZeroCopyLiteralByteString.wrap(Bytes.toBytes(omg)));
  Throwable t = ProtobufUtil.toException(builder.build());
  assertEquals(omg, t.getMessage());
  builder.clear();
  builder.setName("org.apache.hadoop.ipc.RemoteException");
  builder.setValue(ZeroCopyLiteralByteString.wrap(Bytes.toBytes(omg)));
  t = ProtobufUtil.toException(builder.build());
  assertEquals(omg, t.getMessage());
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:15,代码来源:TestProtobufUtil.java

示例10: buildActionResult

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair; //导入方法依赖的package包/类
/**
 * Wrap a throwable to an action result.
 *
 * @param t
 * @return an action result
 */
public static ActionResult buildActionResult(final Throwable t) {
  ActionResult.Builder builder = ActionResult.newBuilder();
  NameBytesPair.Builder parameterBuilder = NameBytesPair.newBuilder();
  parameterBuilder.setName(t.getClass().getName());
  parameterBuilder.setValue(
    ByteString.copyFromUtf8(StringUtils.stringifyException(t)));
  builder.setException(parameterBuilder.build());
  return builder.build();
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:16,代码来源:ResponseConverter.java

示例11: toMutate

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair; //导入方法依赖的package包/类
/**
 * Create a protocol buffer Mutate based on a client Mutation
 *
 * @param mutateType
 * @param mutation
 * @return a mutate
 * @throws IOException
 */
public static Mutate toMutate(final MutateType mutateType,
    final Mutation mutation) throws IOException {
  Mutate.Builder mutateBuilder = Mutate.newBuilder();
  mutateBuilder.setRow(ByteString.copyFrom(mutation.getRow()));
  mutateBuilder.setMutateType(mutateType);
  mutateBuilder.setWriteToWAL(mutation.getWriteToWAL());
  if (mutation.getLockId() >= 0) {
    mutateBuilder.setLockId(mutation.getLockId());
  }
  mutateBuilder.setTimestamp(mutation.getTimeStamp());
  Map<String, byte[]> attributes = mutation.getAttributesMap();
  if (!attributes.isEmpty()) {
    NameBytesPair.Builder attributeBuilder = NameBytesPair.newBuilder();
    for (Map.Entry<String, byte[]> attribute: attributes.entrySet()) {
      attributeBuilder.setName(attribute.getKey());
      attributeBuilder.setValue(ByteString.copyFrom(attribute.getValue()));
      mutateBuilder.addAttribute(attributeBuilder.build());
    }
  }
  ColumnValue.Builder columnBuilder = ColumnValue.newBuilder();
  QualifierValue.Builder valueBuilder = QualifierValue.newBuilder();
  for (Map.Entry<byte[],List<KeyValue>>
      family: mutation.getFamilyMap().entrySet()) {
    columnBuilder.setFamily(ByteString.copyFrom(family.getKey()));
    columnBuilder.clearQualifierValue();
    for (KeyValue value: family.getValue()) {
      valueBuilder.setQualifier(ByteString.copyFrom(value.getQualifier()));
      valueBuilder.setValue(ByteString.copyFrom(value.getValue()));
      valueBuilder.setTimestamp(value.getTimestamp());
      if (mutateType == MutateType.DELETE) {
        KeyValue.Type keyValueType = KeyValue.Type.codeToType(value.getType());
        valueBuilder.setDeleteType(toDeleteType(keyValueType));
      }
      columnBuilder.addQualifierValue(valueBuilder.build());
    }
    mutateBuilder.addColumnValue(columnBuilder.build());
  }
  return mutateBuilder.build();
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:48,代码来源:ProtobufUtil.java

示例12: toGet

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair; //导入方法依赖的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

示例13: toMutation

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair; //导入方法依赖的package包/类
/**
 * Convert a client Increment to a protobuf Mutate.
 *
 * @param increment
 * @return the converted mutate
 */
public static MutationProto toMutation(
  final Increment increment, final MutationProto.Builder builder, long nonce) {
  builder.setRow(ByteStringer.wrap(increment.getRow()));
  builder.setMutateType(MutationType.INCREMENT);
  builder.setDurability(toDurability(increment.getDurability()));
  if (nonce != HConstants.NO_NONCE) {
    builder.setNonce(nonce);
  }
  TimeRange timeRange = increment.getTimeRange();
  if (!timeRange.isAllTime()) {
    HBaseProtos.TimeRange.Builder timeRangeBuilder =
      HBaseProtos.TimeRange.newBuilder();
    timeRangeBuilder.setFrom(timeRange.getMin());
    timeRangeBuilder.setTo(timeRange.getMax());
    builder.setTimeRange(timeRangeBuilder.build());
  }
  ColumnValue.Builder columnBuilder = ColumnValue.newBuilder();
  QualifierValue.Builder valueBuilder = QualifierValue.newBuilder();
  for (Map.Entry<byte[], List<Cell>> family: increment.getFamilyCellMap().entrySet()) {
    columnBuilder.setFamily(ByteStringer.wrap(family.getKey()));
    columnBuilder.clearQualifierValue();
    List<Cell> values = family.getValue();
    if (values != null && values.size() > 0) {
      for (Cell cell: values) {
        valueBuilder.clear();
        valueBuilder.setQualifier(ByteStringer.wrap(
            cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()));
        valueBuilder.setValue(ByteStringer.wrap(
            cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
        if (cell.getTagsLength() > 0) {
          valueBuilder.setTags(ByteStringer.wrap(cell.getTagsArray(),
              cell.getTagsOffset(), cell.getTagsLength()));
        }
        columnBuilder.addQualifierValue(valueBuilder.build());
      }
    }
    builder.addColumnValue(columnBuilder.build());
  }
  Map<String, byte[]> attributes = increment.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());
    }
  }
  return builder.build();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:56,代码来源:ProtobufUtil.java

示例14: toGet

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair; //导入方法依赖的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()));
  }
  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:grokcoder,项目名称:pbase,代码行数:68,代码来源:ProtobufUtil.java

示例15: toScan

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair; //导入方法依赖的package包/类
/**
 * Convert a client Scan to a protocol buffer Scan
 *
 * @param scan the client Scan to convert
 * @return the converted protocol buffer Scan
 * @throws IOException
 */
public static ClientProtos.Scan toScan(
    final Scan scan) throws IOException {
  ClientProtos.Scan.Builder scanBuilder =
    ClientProtos.Scan.newBuilder();
  scanBuilder.setCacheBlocks(scan.getCacheBlocks());
  if (scan.getBatch() > 0) {
    scanBuilder.setBatchSize(scan.getBatch());
  }
  if (scan.getMaxResultSize() > 0) {
    scanBuilder.setMaxResultSize(scan.getMaxResultSize());
  }
  if (scan.isSmall()) {
    scanBuilder.setSmall(scan.isSmall());
  }
  Boolean loadColumnFamiliesOnDemand = scan.getLoadColumnFamiliesOnDemandValue();
  if (loadColumnFamiliesOnDemand != null) {
    scanBuilder.setLoadColumnFamiliesOnDemand(loadColumnFamiliesOnDemand.booleanValue());
  }
  scanBuilder.setMaxVersions(scan.getMaxVersions());
  TimeRange timeRange = scan.getTimeRange();
  if (!timeRange.isAllTime()) {
    HBaseProtos.TimeRange.Builder timeRangeBuilder =
      HBaseProtos.TimeRange.newBuilder();
    timeRangeBuilder.setFrom(timeRange.getMin());
    timeRangeBuilder.setTo(timeRange.getMax());
    scanBuilder.setTimeRange(timeRangeBuilder.build());
  }
  Map<String, byte[]> attributes = scan.getAttributesMap();
  if (!attributes.isEmpty()) {
    NameBytesPair.Builder attributeBuilder = NameBytesPair.newBuilder();
    for (Map.Entry<String, byte[]> attribute: attributes.entrySet()) {
      attributeBuilder.setName(attribute.getKey());
      attributeBuilder.setValue(HBaseZeroCopyByteString.wrap(attribute.getValue()));
      scanBuilder.addAttribute(attributeBuilder.build());
    }
  }
  byte[] startRow = scan.getStartRow();
  if (startRow != null && startRow.length > 0) {
    scanBuilder.setStartRow(HBaseZeroCopyByteString.wrap(startRow));
  }
  byte[] stopRow = scan.getStopRow();
  if (stopRow != null && stopRow.length > 0) {
    scanBuilder.setStopRow(HBaseZeroCopyByteString.wrap(stopRow));
  }
  if (scan.hasFilter()) {
    scanBuilder.setFilter(ProtobufUtil.toFilter(scan.getFilter()));
  }
  if (scan.hasFamilies()) {
    Column.Builder columnBuilder = Column.newBuilder();
    for (Map.Entry<byte[],NavigableSet<byte []>>
        family: scan.getFamilyMap().entrySet()) {
      columnBuilder.setFamily(HBaseZeroCopyByteString.wrap(family.getKey()));
      NavigableSet<byte []> qualifiers = family.getValue();
      columnBuilder.clearQualifier();
      if (qualifiers != null && qualifiers.size() > 0) {
        for (byte [] qualifier: qualifiers) {
          columnBuilder.addQualifier(HBaseZeroCopyByteString.wrap(qualifier));
        }
      }
      scanBuilder.addColumn(columnBuilder.build());
    }
  }
  if (scan.getMaxResultsPerColumnFamily() >= 0) {
    scanBuilder.setStoreLimit(scan.getMaxResultsPerColumnFamily());
  }
  if (scan.getRowOffsetPerColumnFamily() > 0) {
    scanBuilder.setStoreOffset(scan.getRowOffsetPerColumnFamily());
  }
  if (scan.isReversed()) {
    scanBuilder.setReversed(scan.isReversed());
  }
  return scanBuilder.build();
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:81,代码来源:ProtobufUtil.java


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