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

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

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

Append.<init>介绍

[英]Constructor for Writable. DO NOT USE
[中]可写的构造函数。不要使用

代码示例

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

  1. private Append newAppendWithSkipWAL() {
  2. Append append = new Append(Bytes.toBytes("row"));
  3. append.addColumn(CF, CQ, Bytes.toBytes("value"));
  4. append.setDurability(Durability.SKIP_WAL);
  5. return append;
  6. }

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

  1. @Test
  2. public void testNoInsertsWithAppend() throws Exception {
  3. Append a = new Append(Bytes.toBytes("to_reject"));
  4. a.addColumn(
  5. Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"), Bytes.toBytes("reject"));
  6. writeUntilViolationAndVerifyViolation(SpaceViolationPolicy.NO_INSERTS, a);
  7. }

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

  1. @Test
  2. public void testNoWritesWithAppend() throws Exception {
  3. Append a = new Append(Bytes.toBytes("to_reject"));
  4. a.addColumn(
  5. Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"), Bytes.toBytes("reject"));
  6. writeUntilViolationAndVerifyViolation(SpaceViolationPolicy.NO_WRITES, a);
  7. }

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

  1. @Override
  2. public Object run() throws Exception {
  3. ACCESS_CONTROLLER.preAppend(ObserverContextImpl.createAndPrepare(RCP_ENV),
  4. new Append(TEST_ROW));
  5. return null;
  6. }
  7. }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE);

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

  1. @Test(expected = DoNotRetryIOException.class)
  2. public void testAppendWithDoNotRetryIOException() throws Exception {
  3. tableDoNotRetry
  4. .append(new Append(Bytes.toBytes("row")).addColumn(CF, CQ, Bytes.toBytes("value")));
  5. }

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

  1. @Override
  2. public void run() {
  3. int count = 0;
  4. while (count < appendCounter) {
  5. Append app = new Append(appendRow);
  6. app.addColumn(family, qualifier, CHAR);
  7. count++;
  8. try {
  9. region.append(app);
  10. } catch (IOException e) {
  11. LOG.info("Count=" + count + ", max=" + appendCounter + ", " + e);
  12. break;
  13. }
  14. }
  15. }
  16. }

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

  1. @Test
  2. public void testAppend() {
  3. test(row -> new Append(row));
  4. }

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

  1. @Test(expected = RetriesExhaustedException.class)
  2. public void testAppendWithIOException() throws Exception {
  3. tableRetry.append(new Append(Bytes.toBytes("row")).addColumn(CF, CQ, Bytes.toBytes("value")));
  4. }

代码示例来源: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. @Test
  2. public void testAppend() throws InterruptedException, ExecutionException {
  3. AsyncTable<?> table = ASYNC_CONN.getTable(TABLE_NAME);
  4. Result result = table.append(new Append(row).addColumn(FAMILY, QUALIFIER, VALUE)).get();
  5. assertArrayEquals(VALUE, result.getValue(FAMILY, QUALIFIER));
  6. result = table.append(new Append(row).addColumn(FAMILY, QUALIFIER, VALUE)).get();
  7. // the second call should have no effect as we always generate the same nonce.
  8. assertArrayEquals(VALUE, result.getValue(FAMILY, QUALIFIER));
  9. result = table.get(new Get(row)).get();
  10. assertArrayEquals(VALUE, result.getValue(FAMILY, QUALIFIER));
  11. }

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

  1. @Override
  2. public Void run() throws Exception {
  3. try (Connection connection = ConnectionFactory.createConnection(conf);
  4. Table table = connection.getTable(tableName)) {
  5. Append append = new Append(row1);
  6. append.addColumn(fam, qual, Bytes.toBytes("b"));
  7. table.append(append);
  8. }
  9. return null;
  10. }
  11. };

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

  1. @Test
  2. public void testAppendWithReadOnlyTable() throws Exception {
  3. final TableName tableName = TableName.valueOf(name.getMethodName());
  4. this.region = initHRegion(tableName, method, CONF, true, Bytes.toBytes("somefamily"));
  5. boolean exceptionCaught = false;
  6. Append append = new Append(Bytes.toBytes("somerow"));
  7. append.setDurability(Durability.SKIP_WAL);
  8. append.addColumn(Bytes.toBytes("somefamily"), Bytes.toBytes("somequalifier"),
  9. Bytes.toBytes("somevalue"));
  10. try {
  11. region.append(append);
  12. } catch (IOException e) {
  13. exceptionCaught = true;
  14. }
  15. assertTrue(exceptionCaught == true);
  16. }

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

  1. @Override
  2. public Object run() throws Exception {
  3. byte[] row = TEST_ROW;
  4. byte[] qualifier = TEST_QUALIFIER;
  5. Put put = new Put(row);
  6. put.addColumn(TEST_FAMILY, qualifier, Bytes.toBytes(1));
  7. Append append = new Append(row);
  8. append.addColumn(TEST_FAMILY, qualifier, Bytes.toBytes(2));
  9. try(Connection conn = ConnectionFactory.createConnection(conf);
  10. Table t = conn.getTable(TEST_TABLE)) {
  11. t.put(put);
  12. t.append(append);
  13. }
  14. return null;
  15. }
  16. };

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

  1. @Test
  2. public void testAppendId() {
  3. Append append = new Append(ROW);
  4. Assert.assertNull("Make sure id is null if unset", append.toMap().get("id"));
  5. append.setId("myId");
  6. Assert.assertEquals("myId", append.toMap().get("id"));
  7. }

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

  1. @Override
  2. boolean testRow(final int i) throws IOException {
  3. byte [] bytes = format(i);
  4. Append append = new Append(bytes);
  5. // unlike checkAndXXX tests, which make most sense to do on a single value,
  6. // if multiple families are specified for an append test we assume it is
  7. // meant to raise the work factor
  8. for (int family = 0; family < opts.families; family++) {
  9. byte[] familyName = Bytes.toBytes(FAMILY_NAME_BASE + family);
  10. append.addColumn(familyName, getQualifier(), bytes);
  11. }
  12. updateValueSize(this.table.append(append));
  13. return true;
  14. }
  15. }

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

  1. @Override
  2. public Void run() throws Exception {
  3. try (Connection connection = ConnectionFactory.createConnection(conf);
  4. Table table = connection.getTable(tableName)) {
  5. Append append = new Append(row1);
  6. append.addColumn(fam, qual, Bytes.toBytes("c"));
  7. append.setCellVisibility(new CellVisibility(PUBLIC));
  8. table.append(append);
  9. Assert.fail("Testcase should fail with AccesDeniedException");
  10. } catch (Throwable t) {
  11. assertTrue(t.getMessage().contains("AccessDeniedException"));
  12. }
  13. return null;
  14. }
  15. };

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

  1. @Test
  2. public void testAppend() throws Exception {
  3. doNPuts(1, false);
  4. for(int count = 0; count< 73; count++) {
  5. Append append = new Append(row);
  6. append.addColumn(cf, qualifier, Bytes.toBytes(",Test"));
  7. table.append(append);
  8. }
  9. metricsRegionServer.getRegionServerWrapper().forceRecompute();
  10. assertCounter("appendNumOps", 73);
  11. }

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

  1. @Test
  2. public void testAppend() throws IOException {
  3. try (Table t = TEST_UTIL.getConnection().getTable(TABLE_NAME)) {
  4. Put put = new Put(ROW);
  5. put.addColumn(FAMILY, QUAL, VALUE);
  6. t.put(put);
  7. assertRowAndValue(t.get(new Get(ROW)), ROW, VALUE);
  8. Append append = new Append(ROW);
  9. append.addColumn(FAMILY, QUAL, FIXED_VALUE);
  10. assertRowAndValue(t.append(append), ROW, FIXED_VALUE);
  11. assertRowAndValue(t.get(new Get(ROW)), ROW, Bytes.add(VALUE, FIXED_VALUE));
  12. }
  13. }

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

  1. @Test
  2. public void testAppendWithNonExistingFamily() throws IOException {
  3. initHRegion(tableName, name.getMethodName(), fam1);
  4. final String v1 = "Value";
  5. final Append a = new Append(row);
  6. a.addColumn(fam1, qual1, Bytes.toBytes(v1));
  7. a.addColumn(fam2, qual2, Bytes.toBytes(v1));
  8. Result result = null;
  9. try {
  10. result = region.append(a, HConstants.NO_NONCE, HConstants.NO_NONCE);
  11. fail("Append operation should fail with NoSuchColumnFamilyException.");
  12. } catch (NoSuchColumnFamilyException e) {
  13. assertEquals(null, result);
  14. } catch (Exception e) {
  15. fail("Append operation should fail with NoSuchColumnFamilyException.");
  16. }
  17. }

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

  1. @Test
  2. public void testAppendIteration() throws IOException {
  3. Append a = new Append(ROW);
  4. for (int i = 0; i < COUNT; i++) {
  5. byte [] bytes = Bytes.toBytes(i);
  6. a.addColumn(bytes, bytes, bytes);
  7. }
  8. int index = 0;
  9. for (CellScanner cellScanner = a.cellScanner(); cellScanner.advance();) {
  10. Cell cell = cellScanner.current();
  11. byte [] bytes = Bytes.toBytes(index++);
  12. KeyValue kv = (KeyValue)cell;
  13. assertTrue(Bytes.equals(CellUtil.cloneFamily(kv), bytes));
  14. assertTrue(Bytes.equals(CellUtil.cloneValue(kv), bytes));
  15. }
  16. assertEquals(COUNT, index);
  17. }

相关文章