org.apache.hadoop.hbase.client.Append.setReturnResults()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.apache.hadoop.hbase.client.Append.setReturnResults()方法的一些代码示例,展示了Append.setReturnResults()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Append.setReturnResults()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Append
类名称:Append
方法名:setReturnResults

Append.setReturnResults介绍

暂无

代码示例

代码示例来源:origin: apache/hbase

@Test
public void testBatchAppendWithReturnResultFalse() throws Exception {
 LOG.info("Starting testBatchAppendWithReturnResultFalse");
 final TableName tableName = TableName.valueOf(name.getMethodName());
 Table table = TEST_UTIL.createTable(tableName, FAMILY);
 Append append1 = new Append(Bytes.toBytes("row1"));
 append1.setReturnResults(false);
 append1.addColumn(FAMILY, Bytes.toBytes("f1"), Bytes.toBytes("value1"));
 Append append2 = new Append(Bytes.toBytes("row1"));
 append2.setReturnResults(false);
 append2.addColumn(FAMILY, Bytes.toBytes("f1"), Bytes.toBytes("value2"));
 List<Append> appends = new ArrayList<>();
 appends.add(append1);
 appends.add(append2);
 Object[] results = new Object[2];
 table.batch(appends, results);
 assertTrue(results.length == 2);
 for(Object r : results) {
  Result result = (Result)r;
  assertTrue(result.isEmpty());
 }
 table.close();
}

代码示例来源:origin: apache/hbase

append.setReturnResults(returnResult);
int i = 0;
for (CellModel cell: rowModel.getCells()) {

代码示例来源:origin: apache/hbase

@Test
public void testAppend() throws Exception {
 testAppend(new Append(ROW_A).addColumn(TEST_FAMILY, qualifierCol1,
   Bytes.toBytes("value")));
 testAppend(new Append(ROW_A).addColumn(TEST_FAMILY, qualifierCol1,
   Bytes.toBytes("value")).setReturnResults(false));
}

代码示例来源:origin: apache/hbase

/**
 * Test basic append operation.
 * More tests in
 * @see org.apache.hadoop.hbase.client.TestFromClientSide#testAppend()
 */
@Test
public void testAppend() throws IOException {
 initHRegion(tableName, name.getMethodName(), fam1);
 String v1 = "Ultimate Answer to the Ultimate Question of Life,"+
 " The Universe, and Everything";
 String v2 = " is... 42.";
 Append a = new Append(row);
 a.setReturnResults(false);
 a.addColumn(fam1, qual1, Bytes.toBytes(v1));
 a.addColumn(fam1, qual2, Bytes.toBytes(v2));
 assertTrue(region.append(a, HConstants.NO_NONCE, HConstants.NO_NONCE).isEmpty());
 a = new Append(row);
 a.addColumn(fam1, qual1, Bytes.toBytes(v2));
 a.addColumn(fam1, qual2, Bytes.toBytes(v1));
 Result result = region.append(a, HConstants.NO_NONCE, HConstants.NO_NONCE);
 assertEquals(0, Bytes.compareTo(Bytes.toBytes(v1+v2), result.getValue(fam1, qual1)));
 assertEquals(0, Bytes.compareTo(Bytes.toBytes(v2+v1), result.getValue(fam1, qual2)));
}

代码示例来源:origin: apache/hbase

a.setReturnResults(false);
a.addColumn(fam1, qual1, Bytes.toBytes(v1));
a.addColumn(fam2, qual2, Bytes.toBytes(v2));

代码示例来源:origin: apache/hbase

@Test
public void testAppend() throws Exception {
 LOG.info("Starting testAppend");
 final TableName tableName = TableName.valueOf(name.getMethodName());
 Table t = TEST_UTIL.createTable(tableName, FAMILY);
 byte[] v1 = Bytes.toBytes("42");
 byte[] v2 = Bytes.toBytes("23");
 byte [][] QUALIFIERS = new byte [][] {
   Bytes.toBytes("b"), Bytes.toBytes("a"), Bytes.toBytes("c")
 };
 Append a = new Append(ROW);
 a.addColumn(FAMILY, QUALIFIERS[0], v1);
 a.addColumn(FAMILY, QUALIFIERS[1], v2);
 a.setReturnResults(false);
 assertEmptyResult(t.append(a));
 a = new Append(ROW);
 a.addColumn(FAMILY, QUALIFIERS[0], v2);
 a.addColumn(FAMILY, QUALIFIERS[1], v1);
 a.addColumn(FAMILY, QUALIFIERS[2], v2);
 Result r = t.append(a);
 assertEquals(0, Bytes.compareTo(Bytes.add(v1, v2), r.getValue(FAMILY, QUALIFIERS[0])));
 assertEquals(0, Bytes.compareTo(Bytes.add(v2, v1), r.getValue(FAMILY, QUALIFIERS[1])));
 // QUALIFIERS[2] previously not exist, verify both value and timestamp are correct
 assertEquals(0, Bytes.compareTo(v2, r.getValue(FAMILY, QUALIFIERS[2])));
 assertEquals(r.getColumnLatestCell(FAMILY, QUALIFIERS[0]).getTimestamp(),
   r.getColumnLatestCell(FAMILY, QUALIFIERS[2]).getTimestamp());
}
private List<Result> doAppend(final boolean walUsed) throws IOException {

代码示例来源:origin: apache/hbase

public static Append appendFromThrift(TAppend append) throws IOException {
 Append out = new Append(append.getRow());
 for (TColumnValue column : append.getColumns()) {
  out.addColumn(column.getFamily(), column.getQualifier(), column.getValue());
 }
 if (append.isSetAttributes()) {
  addAttributes(out, append.getAttributes());
 }
 if (append.isSetDurability()) {
  out.setDurability(durabilityFromThrift(append.getDurability()));
 }
 if(append.getCellVisibility() != null) {
  out.setCellVisibility(new CellVisibility(append.getCellVisibility().getExpression()));
 }
 if (append.isSetReturnResults()) {
  out.setReturnResults(append.isReturnResults());
 }
 return out;
}

代码示例来源:origin: com.aliyun.hbase/alihbase-rest

append.setReturnResults(returnResult);
int i = 0;
for (CellModel cell: rowModel.getCells()) {

代码示例来源:origin: org.apache.hbase/hbase-server

@Test
public void testBatchAppendWithReturnResultFalse() throws Exception {
 LOG.info("Starting testBatchAppendWithReturnResultFalse");
 final TableName tableName = TableName.valueOf(name.getMethodName());
 Table table = TEST_UTIL.createTable(tableName, FAMILY);
 Append append1 = new Append(Bytes.toBytes("row1"));
 append1.setReturnResults(false);
 append1.addColumn(FAMILY, Bytes.toBytes("f1"), Bytes.toBytes("value1"));
 Append append2 = new Append(Bytes.toBytes("row1"));
 append2.setReturnResults(false);
 append2.addColumn(FAMILY, Bytes.toBytes("f1"), Bytes.toBytes("value2"));
 List<Append> appends = new ArrayList<>();
 appends.add(append1);
 appends.add(append2);
 Object[] results = new Object[2];
 table.batch(appends, results);
 assertTrue(results.length == 2);
 for(Object r : results) {
  Result result = (Result)r;
  assertTrue(result.isEmpty());
 }
 table.close();
}

代码示例来源:origin: org.apache.hbase/hbase-rest

append.setReturnResults(returnResult);
int i = 0;
for (CellModel cell: rowModel.getCells()) {

代码示例来源:origin: org.apache.hbase/hbase-server

@Test
public void testAppend() throws Exception {
 testAppend(new Append(ROW_A).addColumn(TEST_FAMILY, qualifierCol1,
   Bytes.toBytes("value")));
 testAppend(new Append(ROW_A).addColumn(TEST_FAMILY, qualifierCol1,
   Bytes.toBytes("value")).setReturnResults(false));
}

代码示例来源:origin: org.apache.hbase/hbase-server

/**
 * Test basic append operation.
 * More tests in
 * @see org.apache.hadoop.hbase.client.TestFromClientSide#testAppend()
 */
@Test
public void testAppend() throws IOException {
 initHRegion(tableName, name.getMethodName(), fam1);
 String v1 = "Ultimate Answer to the Ultimate Question of Life,"+
 " The Universe, and Everything";
 String v2 = " is... 42.";
 Append a = new Append(row);
 a.setReturnResults(false);
 a.addColumn(fam1, qual1, Bytes.toBytes(v1));
 a.addColumn(fam1, qual2, Bytes.toBytes(v2));
 assertTrue(region.append(a, HConstants.NO_NONCE, HConstants.NO_NONCE).isEmpty());
 a = new Append(row);
 a.addColumn(fam1, qual1, Bytes.toBytes(v2));
 a.addColumn(fam1, qual2, Bytes.toBytes(v1));
 Result result = region.append(a, HConstants.NO_NONCE, HConstants.NO_NONCE);
 assertEquals(0, Bytes.compareTo(Bytes.toBytes(v1+v2), result.getValue(fam1, qual1)));
 assertEquals(0, Bytes.compareTo(Bytes.toBytes(v2+v1), result.getValue(fam1, qual2)));
}

代码示例来源:origin: org.apache.hbase/hbase-server

@Test
public void testAppend() throws Exception {
 LOG.info("Starting testAppend");
 final TableName tableName = TableName.valueOf(name.getMethodName());
 Table t = TEST_UTIL.createTable(tableName, FAMILY);
 byte[] v1 = Bytes.toBytes("42");
 byte[] v2 = Bytes.toBytes("23");
 byte [][] QUALIFIERS = new byte [][] {
   Bytes.toBytes("b"), Bytes.toBytes("a"), Bytes.toBytes("c")
 };
 Append a = new Append(ROW);
 a.addColumn(FAMILY, QUALIFIERS[0], v1);
 a.addColumn(FAMILY, QUALIFIERS[1], v2);
 a.setReturnResults(false);
 assertEmptyResult(t.append(a));
 a = new Append(ROW);
 a.addColumn(FAMILY, QUALIFIERS[0], v2);
 a.addColumn(FAMILY, QUALIFIERS[1], v1);
 a.addColumn(FAMILY, QUALIFIERS[2], v2);
 Result r = t.append(a);
 assertEquals(0, Bytes.compareTo(Bytes.add(v1, v2), r.getValue(FAMILY, QUALIFIERS[0])));
 assertEquals(0, Bytes.compareTo(Bytes.add(v2, v1), r.getValue(FAMILY, QUALIFIERS[1])));
 // QUALIFIERS[2] previously not exist, verify both value and timestamp are correct
 assertEquals(0, Bytes.compareTo(v2, r.getValue(FAMILY, QUALIFIERS[2])));
 assertEquals(r.getColumnLatestCell(FAMILY, QUALIFIERS[0]).getTimestamp(),
   r.getColumnLatestCell(FAMILY, QUALIFIERS[2]).getTimestamp());
}
private List<Result> doAppend(final boolean walUsed) throws IOException {

代码示例来源:origin: GoogleCloudPlatform/cloud-bigtable-client

@Test
public void testAppendNoResult() throws Exception {
 // Initialize
 Table table = getDefaultTable();
 byte[] rowKey = dataHelper.randomData("rowKey-");
 byte[] qual = dataHelper.randomData("qualifier-");
 byte[] value1 = dataHelper.randomData("value-");
 byte[] value2 = dataHelper.randomData("value-");
 // Put then append
 Put put = new Put(rowKey).addColumn(SharedTestEnvRule.COLUMN_FAMILY, qual, value1);
 table.put(put);
 Append append = new Append(rowKey);
 appendAdd(append, SharedTestEnvRule.COLUMN_FAMILY, qual, value2);
 append.setReturnResults(false);
 Result result = table.append(append);
 if(result != null) {
  Assert.assertTrue("Should be empty", result.isEmpty());
 } else {
  Assert.assertNull("Should not return result", result);      
 }
}

相关文章