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

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

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

Append.addColumn介绍

[英]Add the specified column and value to this Append operation.
[中]将指定的列和值添加到此追加操作。

代码示例

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

/**
 * Add the specified column and value to this Append operation.
 * @param family family name
 * @param qualifier column qualifier
 * @param value value to append to specified column
 * @return this
 * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
 *             Use {@link #addColumn(byte[], byte[], byte[])} instead
 */
@Deprecated
public Append add(byte [] family, byte [] qualifier, byte [] value) {
 return this.addColumn(family, qualifier, value);
}

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

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

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

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

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

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

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

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

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

@Override
 public void run() {
  int count = 0;
  while (count < appendCounter) {
   Append app = new Append(appendRow);
   app.addColumn(family, qualifier, CHAR);
   count++;
   try {
    region.append(app);
   } catch (IOException e) {
    LOG.info("Count=" + count + ", max=" + appendCounter + ", " + e);
    break;
   }
  }
 }
}

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

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

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

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

@Override
 public Void run() throws Exception {
  try (Connection connection = ConnectionFactory.createConnection(conf);
     Table table = connection.getTable(tableName)) {
   Append append = new Append(row1);
   append.addColumn(fam, qual, Bytes.toBytes("b"));
   table.append(append);
  }
  return null;
 }
};

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

@Test
public void testAppendWithReadOnlyTable() throws Exception {
 final TableName tableName = TableName.valueOf(name.getMethodName());
 this.region = initHRegion(tableName, method, CONF, true, Bytes.toBytes("somefamily"));
 boolean exceptionCaught = false;
 Append append = new Append(Bytes.toBytes("somerow"));
 append.setDurability(Durability.SKIP_WAL);
 append.addColumn(Bytes.toBytes("somefamily"), Bytes.toBytes("somequalifier"),
   Bytes.toBytes("somevalue"));
 try {
  region.append(append);
 } catch (IOException e) {
  exceptionCaught = true;
 }
 assertTrue(exceptionCaught == true);
}

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

@Override
 public Object run() throws Exception {
  byte[] row = TEST_ROW;
  byte[] qualifier = TEST_QUALIFIER;
  Put put = new Put(row);
  put.addColumn(TEST_FAMILY, qualifier, Bytes.toBytes(1));
  Append append = new Append(row);
  append.addColumn(TEST_FAMILY, qualifier, Bytes.toBytes(2));
  try(Connection conn = ConnectionFactory.createConnection(conf);
    Table t = conn.getTable(TEST_TABLE)) {
   t.put(put);
   t.append(append);
  }
  return null;
 }
};

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

@Test
public void testAppendWithNonExistingFamily() throws IOException {
 initHRegion(tableName, name.getMethodName(), fam1);
 final String v1 = "Value";
 final Append a = new Append(row);
 a.addColumn(fam1, qual1, Bytes.toBytes(v1));
 a.addColumn(fam2, qual2, Bytes.toBytes(v1));
 Result result = null;
 try {
  result = region.append(a, HConstants.NO_NONCE, HConstants.NO_NONCE);
  fail("Append operation should fail with NoSuchColumnFamilyException.");
 } catch (NoSuchColumnFamilyException e) {
  assertEquals(null, result);
 } catch (Exception e) {
  fail("Append operation should fail with NoSuchColumnFamilyException.");
 }
}

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

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

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

@Override
 public Void run() throws Exception {
  try (Connection connection = ConnectionFactory.createConnection(conf);
     Table table = connection.getTable(tableName)) {
   Append append = new Append(row1);
   append.addColumn(fam, qual, Bytes.toBytes("c"));
   append.setCellVisibility(new CellVisibility(PUBLIC));
   table.append(append);
   Assert.fail("Testcase should fail with AccesDeniedException");
  } catch (Throwable t) {
   assertTrue(t.getMessage().contains("AccessDeniedException"));
  }
  return null;
 }
};

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

@Test
public void testAppendCopyConstructor() throws IOException {
 Append origin = new Append(Bytes.toBytes("ROW-01"));
 origin.setPriority(100);
 byte[] family = Bytes.toBytes("CF-01");
 origin.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
  .setRow(origin.getRow())
  .setFamily(family)
  .setQualifier(Bytes.toBytes("q"))
  .setType(Type.Put)
  .setValue(Bytes.toBytes(100))
  .build());
 origin.addColumn(family, Bytes.toBytes("q0"), Bytes.toBytes("value"));
 origin.setTimeRange(100, 1000);
 Append clone = new Append(origin);
 assertEquals(origin, clone);
 origin.addColumn(family, Bytes.toBytes("q1"), Bytes.toBytes("value"));
 //They should have different cell lists
 assertNotEquals(origin.getCellList(family), clone.getCellList(family));
}

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

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

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

@Test
public void testAppend() throws IOException {
 try (Table t = TEST_UTIL.getConnection().getTable(TABLE_NAME)) {
  Put put = new Put(ROW);
  put.addColumn(FAMILY, QUAL, VALUE);
  t.put(put);
  assertRowAndValue(t.get(new Get(ROW)), ROW, VALUE);
  Append append = new Append(ROW);
  append.addColumn(FAMILY, QUAL, FIXED_VALUE);
  assertRowAndValue(t.append(append), ROW, FIXED_VALUE);
  assertRowAndValue(t.get(new Get(ROW)), ROW, Bytes.add(VALUE, FIXED_VALUE));
 }
}

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

@Test
public void testAppendIteration() throws IOException {
 Append a = new Append(ROW);
 for (int i = 0; i < COUNT; i++) {
  byte [] bytes = Bytes.toBytes(i);
  a.addColumn(bytes, bytes, bytes);
 }
 int index = 0;
 for (CellScanner cellScanner = a.cellScanner(); cellScanner.advance();) {
  Cell cell = cellScanner.current();
  byte [] bytes = Bytes.toBytes(index++);
  KeyValue kv = (KeyValue)cell;
  assertTrue(Bytes.equals(CellUtil.cloneFamily(kv), bytes));
  assertTrue(Bytes.equals(CellUtil.cloneValue(kv), bytes));
 }
 assertEquals(COUNT, index);
}

代码示例来源: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;
}

相关文章