Java 类org.apache.hadoop.hbase.thrift.generated.TAppend 实例源码

项目:ditb    文件:ThriftUtilities.java   
/**
 * From a {@link TAppend} create an {@link Append}.
 * @param tappend the Thrift version of an append.
 * @return an increment that the {@link TAppend} represented.
 */
public static Append appendFromThrift(TAppend tappend) {
  Append append = new Append(tappend.getRow());
  List<ByteBuffer> columns = tappend.getColumns();
  List<ByteBuffer> values = tappend.getValues();

  if (columns.size() != values.size()) {
    throw new IllegalArgumentException(
        "Sizes of columns and values in tappend object are not matching");
  }

  int length = columns.size();

  for (int i = 0; i < length; i++) {
    byte[][] famAndQf = KeyValue.parseColumn(getBytes(columns.get(i)));
    append.add(famAndQf[0], famAndQf[1], getBytes(values.get(i)));
  }
  return append;
}
项目:hbase    文件:ThriftUtilities.java   
/**
 * From a {@link TAppend} create an {@link Append}.
 * @param tappend the Thrift version of an append.
 * @return an increment that the {@link TAppend} represented.
 */
public static Append appendFromThrift(TAppend tappend) {
  Append append = new Append(tappend.getRow());
  List<ByteBuffer> columns = tappend.getColumns();
  List<ByteBuffer> values = tappend.getValues();

  if (columns.size() != values.size()) {
    throw new IllegalArgumentException(
        "Sizes of columns and values in tappend object are not matching");
  }

  int length = columns.size();

  for (int i = 0; i < length; i++) {
    byte[][] famAndQf = CellUtil.parseColumn(getBytes(columns.get(i)));
    append.addColumn(famAndQf[0], famAndQf[1], getBytes(values.get(i)));
  }
  return append;
}
项目:PyroDB    文件:ThriftUtilities.java   
/**
 * From a {@link TAppend} create an {@link Append}.
 * @param tappend the Thrift version of an append.
 * @return an increment that the {@link TAppend} represented.
 */
public static Append appendFromThrift(TAppend tappend) {
  Append append = new Append(tappend.getRow());
  List<ByteBuffer> columns = tappend.getColumns();
  List<ByteBuffer> values = tappend.getValues();

  if (columns.size() != values.size()) {
    throw new IllegalArgumentException(
        "Sizes of columns and values in tappend object are not matching");
  }

  int length = columns.size();

  for (int i = 0; i < length; i++) {
    byte[][] famAndQf = KeyValue.parseColumn(getBytes(columns.get(i)));
    append.add(famAndQf[0], famAndQf[1], getBytes(values.get(i)));
  }
  return append;
}
项目:ditb    文件:TestThriftServer.java   
/**
 * Appends the value to a cell and checks that the cell value is updated properly.
 *
 * @throws Exception
 */
public static void doTestAppend() throws Exception {
  ThriftServerRunner.HBaseHandler handler =
    new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration(),
      UserProvider.instantiate(UTIL.getConfiguration()));
  handler.createTable(tableAname, getColumnDescriptors());
  try {
    List<Mutation> mutations = new ArrayList<Mutation>(1);
    mutations.add(new Mutation(false, columnAname, valueAname, true));
    handler.mutateRow(tableAname, rowAname, mutations, null);

    List<ByteBuffer> columnList = new ArrayList<ByteBuffer>();
    columnList.add(columnAname);
    List<ByteBuffer> valueList = new ArrayList<ByteBuffer>();
    valueList.add(valueBname);

    TAppend append = new TAppend(tableAname, rowAname, columnList, valueList);
    handler.append(append);

    TRowResult rowResult = handler.getRow(tableAname, rowAname, null).get(0);
    assertEquals(rowAname, rowResult.row);
    assertArrayEquals(Bytes.add(valueAname.array(), valueBname.array()),
      rowResult.columns.get(columnAname).value.array());
  } finally {
    handler.disableTable(tableAname);
    handler.deleteTable(tableAname);
  }
}
项目:hbase    文件:TestThriftServer.java   
/**
 * Appends the value to a cell and checks that the cell value is updated properly.
 */
public static void doTestAppend() throws Exception {
  ThriftServerRunner.HBaseHandler handler =
    new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration(),
      UserProvider.instantiate(UTIL.getConfiguration()));
  handler.createTable(tableAname, getColumnDescriptors());
  try {
    List<Mutation> mutations = new ArrayList<>(1);
    mutations.add(new Mutation(false, columnAname, valueAname, true));
    handler.mutateRow(tableAname, rowAname, mutations, null);

    List<ByteBuffer> columnList = new ArrayList<>(1);
    columnList.add(columnAname);
    List<ByteBuffer> valueList = new ArrayList<>(1);
    valueList.add(valueBname);

    TAppend append = new TAppend(tableAname, rowAname, columnList, valueList);
    handler.append(append);

    TRowResult rowResult = handler.getRow(tableAname, rowAname, null).get(0);
    assertEquals(rowAname, rowResult.row);
    assertArrayEquals(Bytes.add(valueAname.array(), valueBname.array()),
      rowResult.columns.get(columnAname).value.array());
  } finally {
    handler.disableTable(tableAname);
    handler.deleteTable(tableAname);
  }
}
项目:PyroDB    文件:TestThriftServer.java   
/**
 * Appends the value to a cell and checks that the cell value is updated properly.
 *
 * @throws Exception
 */
public static void doTestAppend() throws Exception {
  ThriftServerRunner.HBaseHandler handler =
      new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration());
  handler.createTable(tableAname, getColumnDescriptors());
  try {
    List<Mutation> mutations = new ArrayList<Mutation>(1);
    mutations.add(new Mutation(false, columnAname, valueAname, true));
    handler.mutateRow(tableAname, rowAname, mutations, null);

    List<ByteBuffer> columnList = new ArrayList<ByteBuffer>();
    columnList.add(columnAname);
    List<ByteBuffer> valueList = new ArrayList<ByteBuffer>();
    valueList.add(valueBname);

    TAppend append = new TAppend(tableAname, rowAname, columnList, valueList);
    handler.append(append);

    TRowResult rowResult = handler.getRow(tableAname, rowAname, null).get(0);
    assertEquals(rowAname, rowResult.row);
    assertArrayEquals(Bytes.add(valueAname.array(), valueBname.array()),
      rowResult.columns.get(columnAname).value.array());
  } finally {
    handler.disableTable(tableAname);
    handler.deleteTable(tableAname);
  }
}