• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ColumnValue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ColumnValue类属于org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto包,在下文中一共展示了ColumnValue类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: buildMutateRequest

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue; //导入依赖的package包/类
/**
 * Create a protocol buffer MutateRequest for a client increment
 *
 * @param regionName
 * @param row
 * @param family
 * @param qualifier
 * @param amount
 * @param durability
 * @return a mutate request
 */
public static MutateRequest buildMutateRequest(
    final byte[] regionName, final byte[] row, final byte[] family,
    final byte [] qualifier, final long amount, final Durability durability) {
  MutateRequest.Builder builder = MutateRequest.newBuilder();
  RegionSpecifier region = buildRegionSpecifier(
    RegionSpecifierType.REGION_NAME, regionName);
  builder.setRegion(region);

  MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
  mutateBuilder.setRow(ZeroCopyLiteralByteString.wrap(row));
  mutateBuilder.setMutateType(MutationType.INCREMENT);
  mutateBuilder.setDurability(ProtobufUtil.toDurability(durability));
  ColumnValue.Builder columnBuilder = ColumnValue.newBuilder();
  columnBuilder.setFamily(ZeroCopyLiteralByteString.wrap(family));
  QualifierValue.Builder valueBuilder = QualifierValue.newBuilder();
  valueBuilder.setValue(ZeroCopyLiteralByteString.wrap(Bytes.toBytes(amount)));
  valueBuilder.setQualifier(ZeroCopyLiteralByteString.wrap(qualifier));
  columnBuilder.addQualifierValue(valueBuilder.build());
  mutateBuilder.addColumnValue(columnBuilder.build());
  builder.setMutation(mutateBuilder.build());
  return builder.build();
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:34,代码来源:RequestConverter.java


示例2: toMutation

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue; //导入依赖的package包/类
public static MutationProto toMutation(final MutationType type, final Mutation mutation,
    MutationProto.Builder builder)
throws IOException {
  builder = getMutationBuilderAndSetCommonFields(type, mutation, builder);
  ColumnValue.Builder columnBuilder = ColumnValue.newBuilder();
  QualifierValue.Builder valueBuilder = QualifierValue.newBuilder();
  for (Map.Entry<byte[],List<Cell>> family: mutation.getFamilyCellMap().entrySet()) {
    columnBuilder.clear();
    columnBuilder.setFamily(ZeroCopyLiteralByteString.wrap(family.getKey()));
    for (Cell cell: family.getValue()) {
      KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
      valueBuilder.setQualifier(ZeroCopyLiteralByteString.wrap(
          kv.getQualifierArray(), kv.getQualifierOffset(), kv.getQualifierLength()));
      valueBuilder.setValue(ZeroCopyLiteralByteString.wrap(
          kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()));
      valueBuilder.setTimestamp(kv.getTimestamp());
      if (type == MutationType.DELETE) {
        KeyValue.Type keyValueType = KeyValue.Type.codeToType(kv.getType());
        valueBuilder.setDeleteType(toDeleteType(keyValueType));
      }
      columnBuilder.addQualifierValue(valueBuilder.build());
    }
    builder.addColumnValue(columnBuilder.build());
  }
  return builder.build();
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:27,代码来源:ProtobufUtil.java


示例3: testAppend

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue; //导入依赖的package包/类
/**
 * Test Append Mutate conversions.
 *
 * @throws IOException
 */
@Test
public void testAppend() throws IOException {
  long timeStamp = 111111;
  MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
  mutateBuilder.setRow(ByteString.copyFromUtf8("row"));
  mutateBuilder.setMutateType(MutationType.APPEND);
  mutateBuilder.setTimestamp(timeStamp);
  ColumnValue.Builder valueBuilder = ColumnValue.newBuilder();
  valueBuilder.setFamily(ByteString.copyFromUtf8("f1"));
  QualifierValue.Builder qualifierBuilder = QualifierValue.newBuilder();
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c1"));
  qualifierBuilder.setValue(ByteString.copyFromUtf8("v1"));
  qualifierBuilder.setTimestamp(timeStamp);
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c2"));
  qualifierBuilder.setValue(ByteString.copyFromUtf8("v2"));
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  qualifierBuilder.setTimestamp(timeStamp);
  mutateBuilder.addColumnValue(valueBuilder.build());

  MutationProto proto = mutateBuilder.build();
  // default fields
  assertEquals(MutationProto.Durability.USE_DEFAULT, proto.getDurability());

  // set the default value for equal comparison
  mutateBuilder = MutationProto.newBuilder(proto);
  mutateBuilder.setDurability(MutationProto.Durability.USE_DEFAULT);

  Append append = ProtobufUtil.toAppend(proto, null);

  // append always use the latest timestamp,
  // reset the timestamp to the original mutate
  mutateBuilder.setTimestamp(append.getTimeStamp());
  assertEquals(mutateBuilder.build(), ProtobufUtil.toMutation(MutationType.APPEND, append));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:41,代码来源:TestProtobufUtil.java


示例4: testIncrement

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue; //导入依赖的package包/类
/**
 * Test Increment Mutate conversions.
 *
 * @throws IOException
 */
@Test
public void testIncrement() throws IOException {
  MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
  mutateBuilder.setRow(ByteString.copyFromUtf8("row"));
  mutateBuilder.setMutateType(MutationType.INCREMENT);
  ColumnValue.Builder valueBuilder = ColumnValue.newBuilder();
  valueBuilder.setFamily(ByteString.copyFromUtf8("f1"));
  QualifierValue.Builder qualifierBuilder = QualifierValue.newBuilder();
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c1"));
  qualifierBuilder.setValue(ByteStringer.wrap(Bytes.toBytes(11L)));
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c2"));
  qualifierBuilder.setValue(ByteStringer.wrap(Bytes.toBytes(22L)));
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  mutateBuilder.addColumnValue(valueBuilder.build());

  MutationProto proto = mutateBuilder.build();
  // default fields
  assertEquals(MutationProto.Durability.USE_DEFAULT, proto.getDurability());

  // set the default value for equal comparison
  mutateBuilder = MutationProto.newBuilder(proto);
  mutateBuilder.setDurability(MutationProto.Durability.USE_DEFAULT);

  Increment increment = ProtobufUtil.toIncrement(proto, null);
  assertEquals(mutateBuilder.build(),
    ProtobufUtil.toMutation(increment, MutationProto.newBuilder(), HConstants.NO_NONCE));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:34,代码来源:TestProtobufUtil.java


示例5: buildIncrementRequest

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue; //导入依赖的package包/类
/**
 * Create a protocol buffer MutateRequest for a client increment
 *
 * @param regionName
 * @param row
 * @param family
 * @param qualifier
 * @param amount
 * @param durability
 * @return a mutate request
 */
public static MutateRequest buildIncrementRequest(
    final byte[] regionName, final byte[] row, final byte[] family, final byte[] qualifier,
    final long amount, final Durability durability, long nonceGroup, long nonce) {
  MutateRequest.Builder builder = MutateRequest.newBuilder();
  RegionSpecifier region = buildRegionSpecifier(
    RegionSpecifierType.REGION_NAME, regionName);
  builder.setRegion(region);

  MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
  mutateBuilder.setRow(ByteStringer.wrap(row));
  mutateBuilder.setMutateType(MutationType.INCREMENT);
  mutateBuilder.setDurability(ProtobufUtil.toDurability(durability));
  ColumnValue.Builder columnBuilder = ColumnValue.newBuilder();
  columnBuilder.setFamily(ByteStringer.wrap(family));
  QualifierValue.Builder valueBuilder = QualifierValue.newBuilder();
  valueBuilder.setValue(ByteStringer.wrap(Bytes.toBytes(amount)));
  valueBuilder.setQualifier(ByteStringer.wrap(qualifier));
  columnBuilder.addQualifierValue(valueBuilder.build());
  mutateBuilder.addColumnValue(columnBuilder.build());
  if (nonce != HConstants.NO_NONCE) {
    mutateBuilder.setNonce(nonce);
  }
  builder.setMutation(mutateBuilder.build());
  if (nonceGroup != HConstants.NO_NONCE) {
    builder.setNonceGroup(nonceGroup);
  }
  return builder.build();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:40,代码来源:RequestConverter.java


示例6: toMutation

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue; //导入依赖的package包/类
public static MutationProto toMutation(final MutationType type, final Mutation mutation,
    MutationProto.Builder builder, long nonce)
throws IOException {
  builder = getMutationBuilderAndSetCommonFields(type, mutation, builder);
  if (nonce != HConstants.NO_NONCE) {
    builder.setNonce(nonce);
  }
  ColumnValue.Builder columnBuilder = ColumnValue.newBuilder();
  QualifierValue.Builder valueBuilder = QualifierValue.newBuilder();
  for (Map.Entry<byte[],List<Cell>> family: mutation.getFamilyCellMap().entrySet()) {
    columnBuilder.clear();
    columnBuilder.setFamily(ByteStringer.wrap(family.getKey()));
    for (Cell cell: family.getValue()) {
      valueBuilder.clear();
      valueBuilder.setQualifier(ByteStringer.wrap(
          cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()));
      valueBuilder.setValue(ByteStringer.wrap(
          cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
      valueBuilder.setTimestamp(cell.getTimestamp());
      if (type == MutationType.DELETE || (type == MutationType.PUT && CellUtil.isDelete(cell))) {
        KeyValue.Type keyValueType = KeyValue.Type.codeToType(cell.getTypeByte());
        valueBuilder.setDeleteType(toDeleteType(keyValueType));
      }
      columnBuilder.addQualifierValue(valueBuilder.build());
    }
    builder.addColumnValue(columnBuilder.build());
  }
  return builder.build();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:30,代码来源:ProtobufUtil.java


示例7: toMutation

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue; //导入依赖的package包/类
public static MutationProto toMutation(final MutationType type, final Mutation mutation,
    MutationProto.Builder builder, long nonce)
throws IOException {
  builder = getMutationBuilderAndSetCommonFields(type, mutation, builder);
  if (nonce != HConstants.NO_NONCE) {
    builder.setNonce(nonce);
  }
  ColumnValue.Builder columnBuilder = ColumnValue.newBuilder();
  QualifierValue.Builder valueBuilder = QualifierValue.newBuilder();
  for (Map.Entry<byte[],List<Cell>> family: mutation.getFamilyCellMap().entrySet()) {
    columnBuilder.clear();
    columnBuilder.setFamily(ByteStringer.wrap(family.getKey()));
    for (Cell cell: family.getValue()) {
      valueBuilder.clear();
      valueBuilder.setQualifier(ByteStringer.wrap(
          cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()));
      valueBuilder.setValue(ByteStringer.wrap(
          cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
      valueBuilder.setTimestamp(cell.getTimestamp());
      if(cell.getTagsLength() > 0) {
        valueBuilder.setTags(ByteStringer.wrap(cell.getTagsArray(), cell.getTagsOffset(),
            cell.getTagsLength()));
      }
      if (type == MutationType.DELETE || (type == MutationType.PUT && CellUtil.isDelete(cell))) {
        KeyValue.Type keyValueType = KeyValue.Type.codeToType(cell.getTypeByte());
        valueBuilder.setDeleteType(toDeleteType(keyValueType));
      }
      columnBuilder.addQualifierValue(valueBuilder.build());
    }
    builder.addColumnValue(columnBuilder.build());
  }
  return builder.build();
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:34,代码来源:ProtobufUtil.java


示例8: testIncrement

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue; //导入依赖的package包/类
/**
 * Test Increment Mutate conversions.
 *
 * @throws IOException
 */
@Test
public void testIncrement() throws IOException {
  MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
  mutateBuilder.setRow(ByteString.copyFromUtf8("row"));
  mutateBuilder.setMutateType(MutationType.INCREMENT);
  ColumnValue.Builder valueBuilder = ColumnValue.newBuilder();
  valueBuilder.setFamily(ByteString.copyFromUtf8("f1"));
  QualifierValue.Builder qualifierBuilder = QualifierValue.newBuilder();
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c1"));
  qualifierBuilder.setValue(HBaseZeroCopyByteString.wrap(Bytes.toBytes(11L)));
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c2"));
  qualifierBuilder.setValue(HBaseZeroCopyByteString.wrap(Bytes.toBytes(22L)));
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  mutateBuilder.addColumnValue(valueBuilder.build());

  MutationProto proto = mutateBuilder.build();
  // default fields
  assertEquals(MutationProto.Durability.USE_DEFAULT, proto.getDurability());

  // set the default value for equal comparison
  mutateBuilder = MutationProto.newBuilder(proto);
  mutateBuilder.setDurability(MutationProto.Durability.USE_DEFAULT);

  Increment increment = ProtobufUtil.toIncrement(proto, null);
  assertEquals(mutateBuilder.build(),
    ProtobufUtil.toMutation(increment, MutationProto.newBuilder(), HConstants.NO_NONCE));
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:34,代码来源:TestProtobufUtil.java


示例9: buildIncrementRequest

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue; //导入依赖的package包/类
/**
 * Create a protocol buffer MutateRequest for a client increment
 *
 * @param regionName
 * @param row
 * @param family
 * @param qualifier
 * @param amount
 * @param durability
 * @return a mutate request
 */
public static MutateRequest buildIncrementRequest(
    final byte[] regionName, final byte[] row, final byte[] family, final byte[] qualifier,
    final long amount, final Durability durability, long nonceGroup, long nonce) {
  MutateRequest.Builder builder = MutateRequest.newBuilder();
  RegionSpecifier region = buildRegionSpecifier(
    RegionSpecifierType.REGION_NAME, regionName);
  builder.setRegion(region);

  MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
  mutateBuilder.setRow(HBaseZeroCopyByteString.wrap(row));
  mutateBuilder.setMutateType(MutationType.INCREMENT);
  mutateBuilder.setDurability(ProtobufUtil.toDurability(durability));
  ColumnValue.Builder columnBuilder = ColumnValue.newBuilder();
  columnBuilder.setFamily(HBaseZeroCopyByteString.wrap(family));
  QualifierValue.Builder valueBuilder = QualifierValue.newBuilder();
  valueBuilder.setValue(HBaseZeroCopyByteString.wrap(Bytes.toBytes(amount)));
  valueBuilder.setQualifier(HBaseZeroCopyByteString.wrap(qualifier));
  columnBuilder.addQualifierValue(valueBuilder.build());
  mutateBuilder.addColumnValue(columnBuilder.build());
  if (nonce != HConstants.NO_NONCE) {
    mutateBuilder.setNonce(nonce);
  }
  builder.setMutation(mutateBuilder.build());
  if (nonceGroup != HConstants.NO_NONCE) {
    builder.setNonceGroup(nonceGroup);
  }
  return builder.build();
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:40,代码来源:RequestConverter.java


示例10: toMutation

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue; //导入依赖的package包/类
public static MutationProto toMutation(final MutationType type, final Mutation mutation,
    MutationProto.Builder builder, long nonce)
throws IOException {
  builder = getMutationBuilderAndSetCommonFields(type, mutation, builder);
  if (nonce != HConstants.NO_NONCE) {
    builder.setNonce(nonce);
  }
  ColumnValue.Builder columnBuilder = ColumnValue.newBuilder();
  QualifierValue.Builder valueBuilder = QualifierValue.newBuilder();
  for (Map.Entry<byte[],List<Cell>> family: mutation.getFamilyCellMap().entrySet()) {
    columnBuilder.clear();
    columnBuilder.setFamily(HBaseZeroCopyByteString.wrap(family.getKey()));
    for (Cell cell: family.getValue()) {
      KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
      valueBuilder.setQualifier(HBaseZeroCopyByteString.wrap(
          kv.getQualifierArray(), kv.getQualifierOffset(), kv.getQualifierLength()));
      valueBuilder.setValue(HBaseZeroCopyByteString.wrap(
          kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()));
      valueBuilder.setTimestamp(kv.getTimestamp());
      if(cell.getTagsLength() > 0) {
        valueBuilder.setTags(ByteString.copyFrom(CellUtil.getTagArray(kv)));
      }
      if (type == MutationType.DELETE) {
        KeyValue.Type keyValueType = KeyValue.Type.codeToType(kv.getType());
        valueBuilder.setDeleteType(toDeleteType(keyValueType));
      }
      columnBuilder.addQualifierValue(valueBuilder.build());
    }
    builder.addColumnValue(columnBuilder.build());
  }
  return builder.build();
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:33,代码来源:ProtobufUtil.java


示例11: testAppend

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue; //导入依赖的package包/类
/**
 * Test Append Mutate conversions.
 *
 * @throws IOException
 */
@Test
public void testAppend() throws IOException {
  long timeStamp = 111111;
  MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
  mutateBuilder.setRow(ByteString.copyFromUtf8("row"));
  mutateBuilder.setMutateType(MutationType.APPEND);
  mutateBuilder.setTimestamp(timeStamp);
  ColumnValue.Builder valueBuilder = ColumnValue.newBuilder();
  valueBuilder.setFamily(ByteString.copyFromUtf8("f1"));
  QualifierValue.Builder qualifierBuilder = QualifierValue.newBuilder();
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c1"));
  qualifierBuilder.setValue(ByteString.copyFromUtf8("v1"));
  qualifierBuilder.setTimestamp(timeStamp);
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c2"));
  qualifierBuilder.setValue(ByteString.copyFromUtf8("v2"));
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  mutateBuilder.addColumnValue(valueBuilder.build());

  MutationProto proto = mutateBuilder.build();
  // default fields
  assertEquals(MutationProto.Durability.USE_DEFAULT, proto.getDurability());

  // set the default value for equal comparison
  mutateBuilder = MutationProto.newBuilder(proto);
  mutateBuilder.setDurability(MutationProto.Durability.USE_DEFAULT);

  Append append = ProtobufUtil.toAppend(proto, null);

  // append always use the latest timestamp,
  // reset the timestamp to the original mutate
  mutateBuilder.setTimestamp(append.getTimeStamp());
  assertEquals(mutateBuilder.build(), ProtobufUtil.toMutation(MutationType.APPEND, append));
}
 
开发者ID:apache,项目名称:hbase,代码行数:40,代码来源:TestProtobufUtil.java


示例12: testIncrement

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue; //导入依赖的package包/类
/**
 * Test Increment Mutate conversions.
 *
 * @throws IOException
 */
@Test
public void testIncrement() throws IOException {
  long timeStamp = 111111;
  MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
  mutateBuilder.setRow(ByteString.copyFromUtf8("row"));
  mutateBuilder.setMutateType(MutationType.INCREMENT);
  ColumnValue.Builder valueBuilder = ColumnValue.newBuilder();
  valueBuilder.setFamily(ByteString.copyFromUtf8("f1"));
  QualifierValue.Builder qualifierBuilder = QualifierValue.newBuilder();
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c1"));
  qualifierBuilder.setValue(ByteString.copyFrom(Bytes.toBytes(11L)));
  qualifierBuilder.setTimestamp(timeStamp);
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c2"));
  qualifierBuilder.setValue(ByteString.copyFrom(Bytes.toBytes(22L)));
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  mutateBuilder.addColumnValue(valueBuilder.build());

  MutationProto proto = mutateBuilder.build();
  // default fields
  assertEquals(MutationProto.Durability.USE_DEFAULT, proto.getDurability());

  // set the default value for equal comparison
  mutateBuilder = MutationProto.newBuilder(proto);
  mutateBuilder.setDurability(MutationProto.Durability.USE_DEFAULT);

  Increment increment = ProtobufUtil.toIncrement(proto, null);
  mutateBuilder.setTimestamp(increment.getTimeStamp());
  assertEquals(mutateBuilder.build(), ProtobufUtil.toMutation(MutationType.INCREMENT, increment));
}
 
开发者ID:apache,项目名称:hbase,代码行数:36,代码来源:TestProtobufUtil.java


示例13: testAppend

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue; //导入依赖的package包/类
/**
 * Test Append Mutate conversions.
 *
 * @throws IOException
 */
@Test
public void testAppend() throws IOException {
  MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
  mutateBuilder.setRow(ByteString.copyFromUtf8("row"));
  mutateBuilder.setMutateType(MutationType.APPEND);
  mutateBuilder.setTimestamp(111111);
  ColumnValue.Builder valueBuilder = ColumnValue.newBuilder();
  valueBuilder.setFamily(ByteString.copyFromUtf8("f1"));
  QualifierValue.Builder qualifierBuilder = QualifierValue.newBuilder();
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c1"));
  qualifierBuilder.setValue(ByteString.copyFromUtf8("v1"));
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c2"));
  qualifierBuilder.setValue(ByteString.copyFromUtf8("v2"));
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  mutateBuilder.addColumnValue(valueBuilder.build());

  MutationProto proto = mutateBuilder.build();
  // default fields
  assertEquals(MutationProto.Durability.USE_DEFAULT, proto.getDurability());

  // set the default value for equal comparison
  mutateBuilder = MutationProto.newBuilder(proto);
  mutateBuilder.setDurability(MutationProto.Durability.USE_DEFAULT);

  Append append = ProtobufUtil.toAppend(proto, null);

  // append always use the latest timestamp,
  // add the timestamp to the original mutate
  long timestamp = append.getTimeStamp();
  mutateBuilder.setTimestamp(timestamp);
  for (ColumnValue.Builder column: mutateBuilder.getColumnValueBuilderList()) {
    for (QualifierValue.Builder qualifier:
        column.getQualifierValueBuilderList()) {
      qualifier.setTimestamp(timestamp);
    }
  }
  assertEquals(mutateBuilder.build(), ProtobufUtil.toMutation(MutationType.APPEND, append));
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:45,代码来源:TestProtobufUtil.java


示例14: testIncrement

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue; //导入依赖的package包/类
/**
 * Test Increment Mutate conversions.
 *
 * @throws IOException
 */
@Test
public void testIncrement() throws IOException {
  MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
  mutateBuilder.setRow(ByteString.copyFromUtf8("row"));
  mutateBuilder.setMutateType(MutationType.INCREMENT);
  ColumnValue.Builder valueBuilder = ColumnValue.newBuilder();
  valueBuilder.setFamily(ByteString.copyFromUtf8("f1"));
  QualifierValue.Builder qualifierBuilder = QualifierValue.newBuilder();
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c1"));
  qualifierBuilder.setValue(ZeroCopyLiteralByteString.wrap(Bytes.toBytes(11L)));
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c2"));
  qualifierBuilder.setValue(ZeroCopyLiteralByteString.wrap(Bytes.toBytes(22L)));
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  mutateBuilder.addColumnValue(valueBuilder.build());

  MutationProto proto = mutateBuilder.build();
  // default fields
  assertEquals(MutationProto.Durability.USE_DEFAULT, proto.getDurability());

  // set the default value for equal comparison
  mutateBuilder = MutationProto.newBuilder(proto);
  mutateBuilder.setDurability(MutationProto.Durability.USE_DEFAULT);

  Increment increment = ProtobufUtil.toIncrement(proto, null);
  assertEquals(mutateBuilder.build(),
    ProtobufUtil.toMutation(increment, MutationProto.newBuilder()));
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:34,代码来源:TestProtobufUtil.java


示例15: testDelete

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue; //导入依赖的package包/类
/**
 * Test Delete Mutate conversions.
 *
 * @throws IOException
 */
@Test
public void testDelete() throws IOException {
  MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
  mutateBuilder.setRow(ByteString.copyFromUtf8("row"));
  mutateBuilder.setMutateType(MutationType.DELETE);
  mutateBuilder.setTimestamp(111111);
  ColumnValue.Builder valueBuilder = ColumnValue.newBuilder();
  valueBuilder.setFamily(ByteString.copyFromUtf8("f1"));
  QualifierValue.Builder qualifierBuilder = QualifierValue.newBuilder();
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c1"));
  qualifierBuilder.setDeleteType(DeleteType.DELETE_ONE_VERSION);
  qualifierBuilder.setTimestamp(111222);
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c2"));
  qualifierBuilder.setDeleteType(DeleteType.DELETE_MULTIPLE_VERSIONS);
  qualifierBuilder.setTimestamp(111333);
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  mutateBuilder.addColumnValue(valueBuilder.build());

  MutationProto proto = mutateBuilder.build();
  // default fields
  assertEquals(MutationProto.Durability.USE_DEFAULT, proto.getDurability());

  // set the default value for equal comparison
  mutateBuilder = MutationProto.newBuilder(proto);
  mutateBuilder.setDurability(MutationProto.Durability.USE_DEFAULT);

  Delete delete = ProtobufUtil.toDelete(proto);

  // delete always have empty value,
  // add empty value to the original mutate
  for (ColumnValue.Builder column:
      mutateBuilder.getColumnValueBuilderList()) {
    for (QualifierValue.Builder qualifier:
        column.getQualifierValueBuilderList()) {
      qualifier.setValue(ByteString.EMPTY);
    }
  }
  assertEquals(mutateBuilder.build(),
    ProtobufUtil.toMutation(MutationType.DELETE, delete));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:47,代码来源:TestProtobufUtil.java


示例16: testPut

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue; //导入依赖的package包/类
/**
 * Test Put Mutate conversions.
 *
 * @throws IOException
 */
@Test
public void testPut() throws IOException {
  MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
  mutateBuilder.setRow(ByteString.copyFromUtf8("row"));
  mutateBuilder.setMutateType(MutationType.PUT);
  mutateBuilder.setTimestamp(111111);
  ColumnValue.Builder valueBuilder = ColumnValue.newBuilder();
  valueBuilder.setFamily(ByteString.copyFromUtf8("f1"));
  QualifierValue.Builder qualifierBuilder = QualifierValue.newBuilder();
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c1"));
  qualifierBuilder.setValue(ByteString.copyFromUtf8("v1"));
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c2"));
  qualifierBuilder.setValue(ByteString.copyFromUtf8("v2"));
  qualifierBuilder.setTimestamp(222222);
  valueBuilder.addQualifierValue(qualifierBuilder.build());
  mutateBuilder.addColumnValue(valueBuilder.build());

  MutationProto proto = mutateBuilder.build();
  // default fields
  assertEquals(MutationProto.Durability.USE_DEFAULT, proto.getDurability());

  // set the default value for equal comparison
  mutateBuilder = MutationProto.newBuilder(proto);
  mutateBuilder.setDurability(MutationProto.Durability.USE_DEFAULT);

  Put put = ProtobufUtil.toPut(proto);

  // put value always use the default timestamp if no
  // value level timestamp specified,
  // add the timestamp to the original mutate
  long timestamp = put.getTimeStamp();
  for (ColumnValue.Builder column:
      mutateBuilder.getColumnValueBuilderList()) {
    for (QualifierValue.Builder qualifier:
        column.getQualifierValueBuilderList()) {
      if (!qualifier.hasTimestamp()) {
        qualifier.setTimestamp(timestamp);
      }
    }
  }
  assertEquals(mutateBuilder.build(),
    ProtobufUtil.toMutation(MutationType.PUT, put));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:50,代码来源:TestProtobufUtil.java


示例17: toDelta

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue; //导入依赖的package包/类
private static <T extends Mutation> T toDelta(Function<Bytes, T> supplier, ConsumerWithException<T, Cell> consumer,
    final MutationProto proto, final CellScanner cellScanner) throws IOException {
  byte[] row = proto.hasRow() ? proto.getRow().toByteArray() : null;
  T mutation = row == null ? null : supplier.apply(new Bytes(row));
  int cellCount = proto.hasAssociatedCellCount() ? proto.getAssociatedCellCount() : 0;
  if (cellCount > 0) {
    // The proto has metadata only and the data is separate to be found in the cellScanner.
    if (cellScanner == null) {
      throw new DoNotRetryIOException("Cell count of " + cellCount + " but no cellScanner: " +
              toShortString(proto));
    }
    for (int i = 0; i < cellCount; i++) {
      if (!cellScanner.advance()) {
        throw new DoNotRetryIOException("Cell count of " + cellCount + " but at index " + i +
                " no cell returned: " + toShortString(proto));
      }
      Cell cell = cellScanner.current();
      if (mutation == null) {
        mutation = supplier.apply(new Bytes(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()));
      }
      consumer.accept(mutation, cell);
    }
  } else {
    if (mutation == null) {
      throw new IllegalArgumentException("row cannot be null");
    }
    for (ColumnValue column : proto.getColumnValueList()) {
      byte[] family = column.getFamily().toByteArray();
      for (QualifierValue qv : column.getQualifierValueList()) {
        byte[] qualifier = qv.getQualifier().toByteArray();
        if (!qv.hasValue()) {
          throw new DoNotRetryIOException(
                  "Missing required field: qualifier value");
        }
        byte[] value = qv.getValue().toByteArray();
        byte[] tags = null;
        if (qv.hasTags()) {
          tags = qv.getTags().toByteArray();
        }
        consumer.accept(mutation, CellUtil.createCell(mutation.getRow(), family, qualifier, qv.getTimestamp(),
                KeyValue.Type.Put, value, tags));
      }
    }
  }
  mutation.setDurability(toDurability(proto.getDurability()));
  for (NameBytesPair attribute : proto.getAttributeList()) {
    mutation.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
  }
  return mutation;
}
 
开发者ID:apache,项目名称:hbase,代码行数:51,代码来源:ProtobufUtil.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EaseUserUtils类代码示例发布时间:2022-05-22
下一篇:
Java TextFieldBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap