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


Java NameBytesPair类代码示例

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


NameBytesPair类属于org.apache.hadoop.hbase.protobuf.generated.HBaseProtos包,在下文中一共展示了NameBytesPair类的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: toException

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair; //导入依赖的package包/类
/**
 * Convert a stringified protocol buffer exception Parameter to a Java Exception
 *
 * @param parameter the protocol buffer Parameter to convert
 * @return the converted Exception
 * @throws IOException if failed to deserialize the parameter
 */
@SuppressWarnings("unchecked")
public static Throwable toException(
    final NameBytesPair parameter) throws IOException {
  if (parameter == null || !parameter.hasValue()) return null;
  String desc = parameter.getValue().toStringUtf8();
  String type = parameter.getName();
  try {
    Class<? extends Throwable> c =
      (Class<? extends Throwable>)Class.forName(type);
    Constructor<? extends Throwable> cn =
      c.getDeclaredConstructor(String.class);
    return cn.newInstance(desc);
  } catch (Exception e) {
    throw new IOException(e);
  }
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:24,代码来源:ProtobufUtil.java

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例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(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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: toGet

import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair; //导入依赖的package包/类
/**
 * Convert a protocol buffer Get to a client Get
 *
 * @param proto the protocol buffer Get to convert
 * @return the converted client Get
 * @throws IOException
 */
public static Get toGet(
    final ClientProtos.Get proto) throws IOException {
  if (proto == null) return null;
  byte[] row = proto.getRow().toByteArray();
  Get get = new Get(row);
  if (proto.hasCacheBlocks()) {
    get.setCacheBlocks(proto.getCacheBlocks());
  }
  if (proto.hasMaxVersions()) {
    get.setMaxVersions(proto.getMaxVersions());
  }
  if (proto.hasStoreLimit()) {
    get.setMaxResultsPerColumnFamily(proto.getStoreLimit());
  }
  if (proto.hasStoreOffset()) {
    get.setRowOffsetPerColumnFamily(proto.getStoreOffset());
  }
  if (proto.hasTimeRange()) {
    HBaseProtos.TimeRange timeRange = proto.getTimeRange();
    long minStamp = 0;
    long maxStamp = Long.MAX_VALUE;
    if (timeRange.hasFrom()) {
      minStamp = timeRange.getFrom();
    }
    if (timeRange.hasTo()) {
      maxStamp = timeRange.getTo();
    }
    get.setTimeRange(minStamp, maxStamp);
  }
  if (proto.hasFilter()) {
    FilterProtos.Filter filter = proto.getFilter();
    get.setFilter(ProtobufUtil.toFilter(filter));
  }
  for (NameBytesPair attribute: proto.getAttributeList()) {
    get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
  }
  if (proto.getColumnCount() > 0) {
    for (Column column: proto.getColumnList()) {
      byte[] family = column.getFamily().toByteArray();
      if (column.getQualifierCount() > 0) {
        for (ByteString qualifier: column.getQualifierList()) {
          get.addColumn(family, qualifier.toByteArray());
        }
      } else {
        get.addFamily(family);
      }
    }
  }
  if (proto.hasExistenceOnly() && proto.getExistenceOnly()){
    get.setCheckExistenceOnly(true);
  }
  if (proto.hasClosestRowBefore() && proto.getClosestRowBefore()){
    get.setClosestRowBefore(true);
  }
  if (proto.hasConsistency()) {
    get.setConsistency(toConsistency(proto.getConsistency()));
  }
  return get;
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:67,代码来源:ProtobufUtil.java


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