本文整理了Java中org.apache.hadoop.hbase.client.Put.addColumn()
方法的一些代码示例,展示了Put.addColumn()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Put.addColumn()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Put
类名称:Put
方法名:addColumn
[英]Add the specified column and value, with the specified timestamp as its version to this Put operation.
[中]将指定的列和值以及指定的时间戳作为其版本添加到此Put操作。
代码示例来源:origin: apache/hbase
private void writeData(Table t) throws IOException {
List<Put> puts = new ArrayList<>(NUM_ROWS);
for (int i = 0; i < NUM_ROWS; i++) {
Put p = new Put(Bytes.toBytes(i + 1));
p.addColumn(FAMILY, EXPLICIT_QUAL, EXPLICIT_VAL);
p.addColumn(FAMILY, IMPLICIT_QUAL, IMPLICIT_VAL);
puts.add(p);
}
t.put(puts);
}
代码示例来源:origin: apache/nifi
@Override
public boolean checkAndPut(final String tableName, final byte[] rowId, final byte[] family, final byte[] qualifier, final byte[] value, final PutColumn column) throws IOException {
try (final Table table = connection.getTable(TableName.valueOf(tableName))) {
Put put = new Put(rowId);
put.addColumn(
column.getColumnFamily(),
column.getColumnQualifier(),
column.getBuffer());
return table.checkAndPut(rowId, family, qualifier, value, put);
}
}
代码示例来源:origin: apache/hbase
private void putOneRow(Table table) throws IOException {
Put put = new Put(ROWKEY);
put.addColumn(FAMILY, Bytes.toBytes("A"), Bytes.toBytes("a"));
put.addColumn(FAMILY, Bytes.toBytes("B"), Bytes.toBytes("b"));
put.addColumn(FAMILY, Bytes.toBytes("C"), Bytes.toBytes("c"));
table.put(put);
}
代码示例来源:origin: apache/nifi
@Override
public boolean checkAndPut(final String tableName, final byte[] rowId, final byte[] family, final byte[] qualifier, final byte[] value, final PutColumn column) throws IOException {
try (final Table table = connection.getTable(TableName.valueOf(tableName))) {
Put put = new Put(rowId);
put.addColumn(
column.getColumnFamily(),
column.getColumnQualifier(),
column.getBuffer());
return table.checkAndPut(rowId, family, qualifier, value, put);
}
}
代码示例来源:origin: apache/hbase
private void loadData(Table t, byte[] family, byte[] column) throws IOException {
for (int i = 0; i < 10; i++) {
byte[] row = Bytes.toBytes("row" + i);
Put p = new Put(row);
p.addColumn(family, column, row);
t.put(p);
}
}
代码示例来源:origin: apache/hbase
/**
* Tests that a put on a table throws {@link SocketTimeoutException} when the operation takes
* longer than 'hbase.client.operation.timeout'.
*/
@Test(expected = SocketTimeoutException.class)
public void testPutTimeout() throws Exception {
DELAY_MUTATE = 600;
Put put = new Put(ROW);
put.addColumn(FAMILY, QUALIFIER, VALUE);
table.put(put);
}
代码示例来源:origin: apache/hbase
private void put(int start, int end, long ts) throws IOException {
for (int i = start; i < end; i++) {
TABLE.put(new Put(Bytes.toBytes(i)).addColumn(FAMILY, QUALIFIER, ts, Bytes.toBytes(i)));
}
}
代码示例来源:origin: apache/hbase
@Test(expected = DoNotRetryIOException.class)
public void testPutWithDoNotRetryIOException() throws Exception {
tableDoNotRetry.put(new Put(Bytes.toBytes("row")).addColumn(CF, CQ, Bytes.toBytes("value")));
}
代码示例来源:origin: apache/hbase
@Test(expected = RetriesExhaustedException.class)
public void testPutWithIOException() throws Exception {
tableRetry.put(new Put(Bytes.toBytes("row")).addColumn(CF, CQ, Bytes.toBytes("value")));
}
代码示例来源:origin: apache/hbase
protected void doPut(Table table, int i) throws IOException {
Put put = new Put(Bytes.toBytes("row" + String.format("%1$04d", i)));
put.addColumn(HConstants.CATALOG_FAMILY, null, value);
table.put(put);
}
代码示例来源:origin: apache/hbase
@Override
public Object run() throws Exception {
Put put = new Put(Bytes.toBytes("test"));
put.addColumn(TEST_FAMILY, Bytes.toBytes("qual"), Bytes.toBytes("value"));
table.put(put);
return null;
}
};
代码示例来源:origin: apache/hbase
private void writeData(Table t) throws IOException {
List<Put> puts = new ArrayList<>(NUM_ROWS);
for (int i = 0; i < NUM_ROWS; i++) {
Put p = new Put(Bytes.toBytes(i + 1));
p.addColumn(FAMILY, QUALIFIER, Bytes.toBytes(value));
puts.add(p);
}
t.put(puts);
}
代码示例来源:origin: apache/hbase
private void randomCFPuts(Table table, byte[] row, byte[] family, int nPuts)
throws Exception {
Put put = new Put(row);
for (int i = 0; i < nPuts; i++) {
byte[] qualifier = Bytes.toBytes(random.nextInt());
byte[] value = Bytes.toBytes(random.nextInt());
put.addColumn(family, qualifier, value);
}
table.put(put);
}
代码示例来源:origin: apache/hbase
private void writeData(Table t) throws IOException {
List<Put> puts = new ArrayList<>(NUM_ROWS);
for (int i = 0; i < NUM_ROWS; i++) {
Put p = new Put(Bytes.toBytes(i + 1));
p.addColumn(FAMILY, QUALIFIER, Bytes.toBytes(value));
puts.add(p);
}
t.put(puts);
}
代码示例来源:origin: apache/hbase
void addData(int start) throws IOException {
List<Put> puts = new ArrayList<>();
for (int i=start; i< start + 100; i++) {
Put put = new Put(Bytes.toBytes(i));
put.addColumn(family, family, Bytes.toBytes(i));
puts.add(put);
}
table.put(puts);
}
}
代码示例来源:origin: apache/hbase
protected static void loadData(String prefix, byte[] row) throws IOException {
List<Put> puts = new ArrayList<>(NB_ROWS_IN_BATCH);
for (int i = 0; i < NB_ROWS_IN_BATCH; i++) {
Put put = new Put(Bytes.toBytes(prefix + Integer.toString(i)));
put.addColumn(famName, row, row);
puts.add(put);
}
htable1.put(puts);
}
代码示例来源:origin: apache/hbase
public void loadTable(final Table table, int numRows) throws IOException {
List<Put> puts = new ArrayList<>(numRows);
for (int i = 0; i < numRows; ++i) {
byte[] row = Bytes.toBytes(String.format("%09d", i));
Put put = new Put(row);
put.setDurability(Durability.SKIP_WAL);
put.addColumn(FAMILY_NAME, null, row);
table.put(put);
}
}
代码示例来源:origin: alibaba/canal
/**
* 插入一行数据
*
* @param tableName 表名
* @param hRow 行数据对象
* @return 是否成功
*/
public Boolean put(String tableName, HRow hRow) {
boolean flag = false;
try {
HTable table = (HTable) getConnection().getTable(TableName.valueOf(tableName));
Put put = new Put(hRow.getRowKey());
for (HRow.HCell hCell : hRow.getCells()) {
put.addColumn(Bytes.toBytes(hCell.getFamily()), Bytes.toBytes(hCell.getQualifier()), hCell.getValue());
}
table.put(put);
flag = true;
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new RuntimeException(e);
}
return flag;
}
代码示例来源:origin: apache/hbase
@Test
public void testNoInsertsWithPut() throws Exception {
Put p = new Put(Bytes.toBytes("to_reject"));
p.addColumn(
Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"), Bytes.toBytes("reject"));
writeUntilViolationAndVerifyViolation(SpaceViolationPolicy.NO_INSERTS, p);
}
代码示例来源:origin: apache/hbase
@Test
public void testNoWritesWithPut() throws Exception {
Put p = new Put(Bytes.toBytes("to_reject"));
p.addColumn(
Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"), Bytes.toBytes("reject"));
writeUntilViolationAndVerifyViolation(SpaceViolationPolicy.NO_WRITES, p);
}
内容来源于网络,如有侵权,请联系作者删除!