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

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

本文整理了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

  1. @Test
  2. public void testBatchAppendWithReturnResultFalse() throws Exception {
  3. LOG.info("Starting testBatchAppendWithReturnResultFalse");
  4. final TableName tableName = TableName.valueOf(name.getMethodName());
  5. Table table = TEST_UTIL.createTable(tableName, FAMILY);
  6. Append append1 = new Append(Bytes.toBytes("row1"));
  7. append1.setReturnResults(false);
  8. append1.addColumn(FAMILY, Bytes.toBytes("f1"), Bytes.toBytes("value1"));
  9. Append append2 = new Append(Bytes.toBytes("row1"));
  10. append2.setReturnResults(false);
  11. append2.addColumn(FAMILY, Bytes.toBytes("f1"), Bytes.toBytes("value2"));
  12. List<Append> appends = new ArrayList<>();
  13. appends.add(append1);
  14. appends.add(append2);
  15. Object[] results = new Object[2];
  16. table.batch(appends, results);
  17. assertTrue(results.length == 2);
  18. for(Object r : results) {
  19. Result result = (Result)r;
  20. assertTrue(result.isEmpty());
  21. }
  22. table.close();
  23. }

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

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

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

  1. @Test
  2. public void testAppend() throws Exception {
  3. testAppend(new Append(ROW_A).addColumn(TEST_FAMILY, qualifierCol1,
  4. Bytes.toBytes("value")));
  5. testAppend(new Append(ROW_A).addColumn(TEST_FAMILY, qualifierCol1,
  6. Bytes.toBytes("value")).setReturnResults(false));
  7. }

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

  1. /**
  2. * Test basic append operation.
  3. * More tests in
  4. * @see org.apache.hadoop.hbase.client.TestFromClientSide#testAppend()
  5. */
  6. @Test
  7. public void testAppend() throws IOException {
  8. initHRegion(tableName, name.getMethodName(), fam1);
  9. String v1 = "Ultimate Answer to the Ultimate Question of Life,"+
  10. " The Universe, and Everything";
  11. String v2 = " is... 42.";
  12. Append a = new Append(row);
  13. a.setReturnResults(false);
  14. a.addColumn(fam1, qual1, Bytes.toBytes(v1));
  15. a.addColumn(fam1, qual2, Bytes.toBytes(v2));
  16. assertTrue(region.append(a, HConstants.NO_NONCE, HConstants.NO_NONCE).isEmpty());
  17. a = new Append(row);
  18. a.addColumn(fam1, qual1, Bytes.toBytes(v2));
  19. a.addColumn(fam1, qual2, Bytes.toBytes(v1));
  20. Result result = region.append(a, HConstants.NO_NONCE, HConstants.NO_NONCE);
  21. assertEquals(0, Bytes.compareTo(Bytes.toBytes(v1+v2), result.getValue(fam1, qual1)));
  22. assertEquals(0, Bytes.compareTo(Bytes.toBytes(v2+v1), result.getValue(fam1, qual2)));
  23. }

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

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

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

  1. @Test
  2. public void testAppend() throws Exception {
  3. LOG.info("Starting testAppend");
  4. final TableName tableName = TableName.valueOf(name.getMethodName());
  5. Table t = TEST_UTIL.createTable(tableName, FAMILY);
  6. byte[] v1 = Bytes.toBytes("42");
  7. byte[] v2 = Bytes.toBytes("23");
  8. byte [][] QUALIFIERS = new byte [][] {
  9. Bytes.toBytes("b"), Bytes.toBytes("a"), Bytes.toBytes("c")
  10. };
  11. Append a = new Append(ROW);
  12. a.addColumn(FAMILY, QUALIFIERS[0], v1);
  13. a.addColumn(FAMILY, QUALIFIERS[1], v2);
  14. a.setReturnResults(false);
  15. assertEmptyResult(t.append(a));
  16. a = new Append(ROW);
  17. a.addColumn(FAMILY, QUALIFIERS[0], v2);
  18. a.addColumn(FAMILY, QUALIFIERS[1], v1);
  19. a.addColumn(FAMILY, QUALIFIERS[2], v2);
  20. Result r = t.append(a);
  21. assertEquals(0, Bytes.compareTo(Bytes.add(v1, v2), r.getValue(FAMILY, QUALIFIERS[0])));
  22. assertEquals(0, Bytes.compareTo(Bytes.add(v2, v1), r.getValue(FAMILY, QUALIFIERS[1])));
  23. // QUALIFIERS[2] previously not exist, verify both value and timestamp are correct
  24. assertEquals(0, Bytes.compareTo(v2, r.getValue(FAMILY, QUALIFIERS[2])));
  25. assertEquals(r.getColumnLatestCell(FAMILY, QUALIFIERS[0]).getTimestamp(),
  26. r.getColumnLatestCell(FAMILY, QUALIFIERS[2]).getTimestamp());
  27. }
  28. private List<Result> doAppend(final boolean walUsed) throws IOException {

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

  1. public static Append appendFromThrift(TAppend append) throws IOException {
  2. Append out = new Append(append.getRow());
  3. for (TColumnValue column : append.getColumns()) {
  4. out.addColumn(column.getFamily(), column.getQualifier(), column.getValue());
  5. }
  6. if (append.isSetAttributes()) {
  7. addAttributes(out, append.getAttributes());
  8. }
  9. if (append.isSetDurability()) {
  10. out.setDurability(durabilityFromThrift(append.getDurability()));
  11. }
  12. if(append.getCellVisibility() != null) {
  13. out.setCellVisibility(new CellVisibility(append.getCellVisibility().getExpression()));
  14. }
  15. if (append.isSetReturnResults()) {
  16. out.setReturnResults(append.isReturnResults());
  17. }
  18. return out;
  19. }

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

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

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

  1. @Test
  2. public void testBatchAppendWithReturnResultFalse() throws Exception {
  3. LOG.info("Starting testBatchAppendWithReturnResultFalse");
  4. final TableName tableName = TableName.valueOf(name.getMethodName());
  5. Table table = TEST_UTIL.createTable(tableName, FAMILY);
  6. Append append1 = new Append(Bytes.toBytes("row1"));
  7. append1.setReturnResults(false);
  8. append1.addColumn(FAMILY, Bytes.toBytes("f1"), Bytes.toBytes("value1"));
  9. Append append2 = new Append(Bytes.toBytes("row1"));
  10. append2.setReturnResults(false);
  11. append2.addColumn(FAMILY, Bytes.toBytes("f1"), Bytes.toBytes("value2"));
  12. List<Append> appends = new ArrayList<>();
  13. appends.add(append1);
  14. appends.add(append2);
  15. Object[] results = new Object[2];
  16. table.batch(appends, results);
  17. assertTrue(results.length == 2);
  18. for(Object r : results) {
  19. Result result = (Result)r;
  20. assertTrue(result.isEmpty());
  21. }
  22. table.close();
  23. }

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

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

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

  1. @Test
  2. public void testAppend() throws Exception {
  3. testAppend(new Append(ROW_A).addColumn(TEST_FAMILY, qualifierCol1,
  4. Bytes.toBytes("value")));
  5. testAppend(new Append(ROW_A).addColumn(TEST_FAMILY, qualifierCol1,
  6. Bytes.toBytes("value")).setReturnResults(false));
  7. }

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

  1. /**
  2. * Test basic append operation.
  3. * More tests in
  4. * @see org.apache.hadoop.hbase.client.TestFromClientSide#testAppend()
  5. */
  6. @Test
  7. public void testAppend() throws IOException {
  8. initHRegion(tableName, name.getMethodName(), fam1);
  9. String v1 = "Ultimate Answer to the Ultimate Question of Life,"+
  10. " The Universe, and Everything";
  11. String v2 = " is... 42.";
  12. Append a = new Append(row);
  13. a.setReturnResults(false);
  14. a.addColumn(fam1, qual1, Bytes.toBytes(v1));
  15. a.addColumn(fam1, qual2, Bytes.toBytes(v2));
  16. assertTrue(region.append(a, HConstants.NO_NONCE, HConstants.NO_NONCE).isEmpty());
  17. a = new Append(row);
  18. a.addColumn(fam1, qual1, Bytes.toBytes(v2));
  19. a.addColumn(fam1, qual2, Bytes.toBytes(v1));
  20. Result result = region.append(a, HConstants.NO_NONCE, HConstants.NO_NONCE);
  21. assertEquals(0, Bytes.compareTo(Bytes.toBytes(v1+v2), result.getValue(fam1, qual1)));
  22. assertEquals(0, Bytes.compareTo(Bytes.toBytes(v2+v1), result.getValue(fam1, qual2)));
  23. }

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

  1. @Test
  2. public void testAppend() throws Exception {
  3. LOG.info("Starting testAppend");
  4. final TableName tableName = TableName.valueOf(name.getMethodName());
  5. Table t = TEST_UTIL.createTable(tableName, FAMILY);
  6. byte[] v1 = Bytes.toBytes("42");
  7. byte[] v2 = Bytes.toBytes("23");
  8. byte [][] QUALIFIERS = new byte [][] {
  9. Bytes.toBytes("b"), Bytes.toBytes("a"), Bytes.toBytes("c")
  10. };
  11. Append a = new Append(ROW);
  12. a.addColumn(FAMILY, QUALIFIERS[0], v1);
  13. a.addColumn(FAMILY, QUALIFIERS[1], v2);
  14. a.setReturnResults(false);
  15. assertEmptyResult(t.append(a));
  16. a = new Append(ROW);
  17. a.addColumn(FAMILY, QUALIFIERS[0], v2);
  18. a.addColumn(FAMILY, QUALIFIERS[1], v1);
  19. a.addColumn(FAMILY, QUALIFIERS[2], v2);
  20. Result r = t.append(a);
  21. assertEquals(0, Bytes.compareTo(Bytes.add(v1, v2), r.getValue(FAMILY, QUALIFIERS[0])));
  22. assertEquals(0, Bytes.compareTo(Bytes.add(v2, v1), r.getValue(FAMILY, QUALIFIERS[1])));
  23. // QUALIFIERS[2] previously not exist, verify both value and timestamp are correct
  24. assertEquals(0, Bytes.compareTo(v2, r.getValue(FAMILY, QUALIFIERS[2])));
  25. assertEquals(r.getColumnLatestCell(FAMILY, QUALIFIERS[0]).getTimestamp(),
  26. r.getColumnLatestCell(FAMILY, QUALIFIERS[2]).getTimestamp());
  27. }
  28. private List<Result> doAppend(final boolean walUsed) throws IOException {

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

  1. @Test
  2. public void testAppendNoResult() throws Exception {
  3. // Initialize
  4. Table table = getDefaultTable();
  5. byte[] rowKey = dataHelper.randomData("rowKey-");
  6. byte[] qual = dataHelper.randomData("qualifier-");
  7. byte[] value1 = dataHelper.randomData("value-");
  8. byte[] value2 = dataHelper.randomData("value-");
  9. // Put then append
  10. Put put = new Put(rowKey).addColumn(SharedTestEnvRule.COLUMN_FAMILY, qual, value1);
  11. table.put(put);
  12. Append append = new Append(rowKey);
  13. appendAdd(append, SharedTestEnvRule.COLUMN_FAMILY, qual, value2);
  14. append.setReturnResults(false);
  15. Result result = table.append(append);
  16. if(result != null) {
  17. Assert.assertTrue("Should be empty", result.isEmpty());
  18. } else {
  19. Assert.assertNull("Should not return result", result);
  20. }
  21. }

相关文章