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


Java TDelete.setColumns方法代码示例

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


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

示例1: deleteFromHBase

import org.apache.hadoop.hbase.thrift2.generated.TDelete; //导入方法依赖的package包/类
public static TDelete deleteFromHBase(Delete in) {
  TDelete out = new TDelete(ByteBuffer.wrap(in.getRow()));

  List<TColumn> columns = new ArrayList<TColumn>();
  long rowTimestamp = in.getTimeStamp();
  if (rowTimestamp != HConstants.LATEST_TIMESTAMP) {
    out.setTimestamp(rowTimestamp);
  }

  // Map<family, List<KeyValue>>
  for (Map.Entry<byte[], List<org.apache.hadoop.hbase.Cell>> familyEntry:
      in.getFamilyCellMap().entrySet()) {
    TColumn column = new TColumn(ByteBuffer.wrap(familyEntry.getKey()));
    for (org.apache.hadoop.hbase.Cell cell: familyEntry.getValue()) {
      byte[] family = CellUtil.cloneFamily(cell);
      byte[] qualifier = CellUtil.cloneQualifier(cell);
      long timestamp = cell.getTimestamp();
      if (family != null) {
        column.setFamily(family);
      }
      if (qualifier != null) {
        column.setQualifier(qualifier);
      }
      if (timestamp != HConstants.LATEST_TIMESTAMP) {
        column.setTimestamp(timestamp);
      }
    }
    columns.add(column);
  }
  out.setColumns(columns);

  return out;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:34,代码来源:ThriftUtilities.java

示例2: testDelete

import org.apache.hadoop.hbase.thrift2.generated.TDelete; //导入方法依赖的package包/类
@Test
public void testDelete() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testDelete".getBytes();
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  TColumnValue columnValueA = new TColumnValue(wrap(familyAname), wrap(qualifierAname),
    wrap(valueAname));
  TColumnValue columnValueB = new TColumnValue(wrap(familyBname), wrap(qualifierBname),
    wrap(valueBname));
  columnValues.add(columnValueA);
  columnValues.add(columnValueB);
  TPut put = new TPut(wrap(rowName), columnValues);

  put.setColumnValues(columnValues);

  handler.put(table, put);

  TDelete delete = new TDelete(wrap(rowName));
  List<TColumn> deleteColumns = new ArrayList<TColumn>();
  TColumn deleteColumn = new TColumn(wrap(familyAname));
  deleteColumn.setQualifier(qualifierAname);
  deleteColumns.add(deleteColumn);
  delete.setColumns(deleteColumns);

  handler.deleteSingle(table, delete);

  TGet get = new TGet(wrap(rowName));
  TResult result = handler.get(table, get);
  assertArrayEquals(rowName, result.getRow());
  List<TColumnValue> returnedColumnValues = result.getColumnValues();
  List<TColumnValue> expectedColumnValues = new ArrayList<TColumnValue>();
  expectedColumnValues.add(columnValueB);
  assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:37,代码来源:TestThriftHBaseServiceHandler.java

示例3: deleteFromHBase

import org.apache.hadoop.hbase.thrift2.generated.TDelete; //导入方法依赖的package包/类
public static TDelete deleteFromHBase(Delete in) {
  TDelete out = new TDelete(ByteBuffer.wrap(in.getRow()));

  List<TColumn> columns = new ArrayList<TColumn>();
  long rowTimestamp = in.getTimeStamp();
  if (rowTimestamp != HConstants.LATEST_TIMESTAMP) {
    out.setTimestamp(rowTimestamp);
  }

  // Map<family, List<KeyValue>>
  for (Map.Entry<byte[], List<org.apache.hadoop.hbase.Cell>> familyEntry:
      in.getFamilyCellMap().entrySet()) {
    TColumn column = new TColumn(ByteBuffer.wrap(familyEntry.getKey()));
    for (org.apache.hadoop.hbase.Cell cell: familyEntry.getValue()) {
      KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
      byte[] family = kv.getFamily();
      byte[] qualifier = kv.getQualifier();
      long timestamp = kv.getTimestamp();
      if (family != null) {
        column.setFamily(family);
      }
      if (qualifier != null) {
        column.setQualifier(qualifier);
      }
      if (timestamp != HConstants.LATEST_TIMESTAMP) {
        column.setTimestamp(kv.getTimestamp());
      }
    }
    columns.add(column);
  }
  out.setColumns(columns);

  return out;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:35,代码来源:ThriftUtilities.java

示例4: deleteFromHBase

import org.apache.hadoop.hbase.thrift2.generated.TDelete; //导入方法依赖的package包/类
public static TDelete deleteFromHBase(Delete in) {
  TDelete out = new TDelete(ByteBuffer.wrap(in.getRow()));

  List<TColumn> columns = new ArrayList<>(in.getFamilyCellMap().entrySet().size());
  long rowTimestamp = in.getTimeStamp();
  if (rowTimestamp != HConstants.LATEST_TIMESTAMP) {
    out.setTimestamp(rowTimestamp);
  }

  // Map<family, List<KeyValue>>
  for (Map.Entry<byte[], List<org.apache.hadoop.hbase.Cell>> familyEntry:
      in.getFamilyCellMap().entrySet()) {
    TColumn column = new TColumn(ByteBuffer.wrap(familyEntry.getKey()));
    for (org.apache.hadoop.hbase.Cell cell: familyEntry.getValue()) {
      byte[] family = CellUtil.cloneFamily(cell);
      byte[] qualifier = CellUtil.cloneQualifier(cell);
      long timestamp = cell.getTimestamp();
      if (family != null) {
        column.setFamily(family);
      }
      if (qualifier != null) {
        column.setQualifier(qualifier);
      }
      if (timestamp != HConstants.LATEST_TIMESTAMP) {
        column.setTimestamp(timestamp);
      }
    }
    columns.add(column);
  }
  out.setColumns(columns);

  return out;
}
 
开发者ID:apache,项目名称:hbase,代码行数:34,代码来源:ThriftUtilities.java

示例5: testDelete

import org.apache.hadoop.hbase.thrift2.generated.TDelete; //导入方法依赖的package包/类
@Test
public void testDelete() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = Bytes.toBytes("testDelete");
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<>(2);
  TColumnValue columnValueA = new TColumnValue(wrap(familyAname), wrap(qualifierAname),
    wrap(valueAname));
  TColumnValue columnValueB = new TColumnValue(wrap(familyBname), wrap(qualifierBname),
    wrap(valueBname));
  columnValues.add(columnValueA);
  columnValues.add(columnValueB);
  TPut put = new TPut(wrap(rowName), columnValues);

  put.setColumnValues(columnValues);

  handler.put(table, put);

  TDelete delete = new TDelete(wrap(rowName));
  List<TColumn> deleteColumns = new ArrayList<>(1);
  TColumn deleteColumn = new TColumn(wrap(familyAname));
  deleteColumn.setQualifier(qualifierAname);
  deleteColumns.add(deleteColumn);
  delete.setColumns(deleteColumns);

  handler.deleteSingle(table, delete);

  TGet get = new TGet(wrap(rowName));
  TResult result = handler.get(table, get);
  assertArrayEquals(rowName, result.getRow());
  List<TColumnValue> returnedColumnValues = result.getColumnValues();
  List<TColumnValue> expectedColumnValues = new ArrayList<>(1);
  expectedColumnValues.add(columnValueB);
  assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);
}
 
开发者ID:apache,项目名称:hbase,代码行数:37,代码来源:TestThriftHBaseServiceHandler.java

示例6: testDelete

import org.apache.hadoop.hbase.thrift2.generated.TDelete; //导入方法依赖的package包/类
@Test
public void testDelete() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testDelete".getBytes();
  ByteBuffer table = ByteBuffer.wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  TColumnValue columnValueA = new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname),
      ByteBuffer.wrap(valueAname));
  TColumnValue columnValueB = new TColumnValue(ByteBuffer.wrap(familyBname), ByteBuffer.wrap(qualifierBname),
      ByteBuffer.wrap(valueBname));
  columnValues.add(columnValueA);
  columnValues.add(columnValueB);
  TPut put = new TPut(ByteBuffer.wrap(rowName), columnValues);

  put.setColumnValues(columnValues);

  handler.put(table, put);

  TDelete delete = new TDelete(ByteBuffer.wrap(rowName));
  List<TColumn> deleteColumns = new ArrayList<TColumn>();
  TColumn deleteColumn = new TColumn(ByteBuffer.wrap(familyAname));
  deleteColumn.setQualifier(qualifierAname);
  deleteColumns.add(deleteColumn);
  delete.setColumns(deleteColumns);

  handler.deleteSingle(table, delete);

  TGet get = new TGet(ByteBuffer.wrap(rowName));
  TResult result = handler.get(table, get);
  assertArrayEquals(rowName, result.getRow());
  List<TColumnValue> returnedColumnValues = result.getColumnValues();
  List<TColumnValue> expectedColumnValues = new ArrayList<TColumnValue>();
  expectedColumnValues.add(columnValueB);
  assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);
}
 
开发者ID:zwqjsj0404,项目名称:HBase-Research,代码行数:37,代码来源:TestThriftHBaseServiceHandler.java

示例7: testMutateRow

import org.apache.hadoop.hbase.thrift2.generated.TDelete; //导入方法依赖的package包/类
/**
 * Put valueA to a row, make sure put has happened, then create a mutation object to put valueB
 * and delete ValueA, then check that the row value is only valueB.
 *
 * @throws Exception
 */
@Test
public void testMutateRow() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testMutateRow".getBytes();
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValuesA = new ArrayList<TColumnValue>();
  TColumnValue columnValueA = new TColumnValue(wrap(familyAname), wrap(qualifierAname),
      wrap(valueAname));
  columnValuesA.add(columnValueA);
  TPut putA = new TPut(wrap(rowName), columnValuesA);
  putA.setColumnValues(columnValuesA);

  handler.put(table,putA);

  TGet get = new TGet(wrap(rowName));
  TResult result = handler.get(table, get);
  assertArrayEquals(rowName, result.getRow());
  List<TColumnValue> returnedColumnValues = result.getColumnValues();

  List<TColumnValue> expectedColumnValues = new ArrayList<TColumnValue>();
  expectedColumnValues.add(columnValueA);
  assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);

  List<TColumnValue> columnValuesB = new ArrayList<TColumnValue>();
  TColumnValue columnValueB = new TColumnValue(wrap(familyAname), wrap(qualifierBname),
      wrap(valueBname));
  columnValuesB.add(columnValueB);
  TPut putB = new TPut(wrap(rowName), columnValuesB);
  putB.setColumnValues(columnValuesB);

  TDelete delete = new TDelete(wrap(rowName));
  List<TColumn> deleteColumns = new ArrayList<TColumn>();
  TColumn deleteColumn = new TColumn(wrap(familyAname));
  deleteColumn.setQualifier(qualifierAname);
  deleteColumns.add(deleteColumn);
  delete.setColumns(deleteColumns);

  List<TMutation> mutations = new ArrayList<TMutation>();
  TMutation mutationA = TMutation.put(putB);
  mutations.add(mutationA);

  TMutation mutationB = TMutation.deleteSingle(delete);
  mutations.add(mutationB);

  TRowMutations tRowMutations = new TRowMutations(wrap(rowName),mutations);
  handler.mutateRow(table,tRowMutations);

  result = handler.get(table, get);
  assertArrayEquals(rowName, result.getRow());
  returnedColumnValues = result.getColumnValues();

  expectedColumnValues = new ArrayList<TColumnValue>();
  expectedColumnValues.add(columnValueB);
  assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:63,代码来源:TestThriftHBaseServiceHandler.java

示例8: testMutateRow

import org.apache.hadoop.hbase.thrift2.generated.TDelete; //导入方法依赖的package包/类
/**
 * Put valueA to a row, make sure put has happened, then create a mutation object to put valueB
 * and delete ValueA, then check that the row value is only valueB.
 */
@Test
public void testMutateRow() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = Bytes.toBytes("testMutateRow");
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValuesA = new ArrayList<>(1);
  TColumnValue columnValueA = new TColumnValue(wrap(familyAname), wrap(qualifierAname),
      wrap(valueAname));
  columnValuesA.add(columnValueA);
  TPut putA = new TPut(wrap(rowName), columnValuesA);
  putA.setColumnValues(columnValuesA);

  handler.put(table,putA);

  TGet get = new TGet(wrap(rowName));
  TResult result = handler.get(table, get);
  assertArrayEquals(rowName, result.getRow());
  List<TColumnValue> returnedColumnValues = result.getColumnValues();

  List<TColumnValue> expectedColumnValues = new ArrayList<>(1);
  expectedColumnValues.add(columnValueA);
  assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);

  List<TColumnValue> columnValuesB = new ArrayList<>(1);
  TColumnValue columnValueB = new TColumnValue(wrap(familyAname), wrap(qualifierBname),
      wrap(valueBname));
  columnValuesB.add(columnValueB);
  TPut putB = new TPut(wrap(rowName), columnValuesB);
  putB.setColumnValues(columnValuesB);

  TDelete delete = new TDelete(wrap(rowName));
  List<TColumn> deleteColumns = new ArrayList<>(1);
  TColumn deleteColumn = new TColumn(wrap(familyAname));
  deleteColumn.setQualifier(qualifierAname);
  deleteColumns.add(deleteColumn);
  delete.setColumns(deleteColumns);

  List<TMutation> mutations = new ArrayList<>(2);
  TMutation mutationA = TMutation.put(putB);
  mutations.add(mutationA);

  TMutation mutationB = TMutation.deleteSingle(delete);
  mutations.add(mutationB);

  TRowMutations tRowMutations = new TRowMutations(wrap(rowName),mutations);
  handler.mutateRow(table,tRowMutations);

  result = handler.get(table, get);
  assertArrayEquals(rowName, result.getRow());
  returnedColumnValues = result.getColumnValues();

  expectedColumnValues = new ArrayList<>(1);
  expectedColumnValues.add(columnValueB);
  assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);
}
 
开发者ID:apache,项目名称:hbase,代码行数:61,代码来源:TestThriftHBaseServiceHandler.java


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