本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}