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

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

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

Table.put介绍

[英]Puts some data in the table, in batch.

This can be used for group commit, or for submitting user defined batches. The writeBuffer will be periodically inspected while the List is processed, so depending on the List size the writeBuffer may flush not at all, or more than once.
[中]将一些数据批量放入表中。
这可以用于组提交,也可以用于提交用户定义的批。在处理列表时,将定期检查writeBuffer,因此根据列表大小,writeBuffer可能根本不会刷新,或多次刷新。

代码示例

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

  1. private void loadData(Table t, byte[] family, byte[] column) throws IOException {
  2. for (int i = 0; i < 10; i++) {
  3. byte[] row = Bytes.toBytes("row" + i);
  4. Put p = new Put(row);
  5. p.addColumn(family, column, row);
  6. t.put(p);
  7. }
  8. }

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

  1. /**
  2. * Tests that a put on a table throws {@link SocketTimeoutException} when the operation takes
  3. * longer than 'hbase.client.operation.timeout'.
  4. */
  5. @Test(expected = SocketTimeoutException.class)
  6. public void testPutTimeout() throws Exception {
  7. DELAY_MUTATE = 600;
  8. Put put = new Put(ROW);
  9. put.addColumn(FAMILY, QUALIFIER, VALUE);
  10. table.put(put);
  11. }

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

  1. private void put(int start, int end, long ts) throws IOException {
  2. for (int i = start; i < end; i++) {
  3. TABLE.put(new Put(Bytes.toBytes(i)).addColumn(FAMILY, QUALIFIER, ts, Bytes.toBytes(i)));
  4. }
  5. }

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

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

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

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

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

  1. protected void doPut(Table table, int i) throws IOException {
  2. Put put = new Put(Bytes.toBytes("row" + String.format("%1$04d", i)));
  3. put.addColumn(HConstants.CATALOG_FAMILY, null, value);
  4. table.put(put);
  5. }

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

  1. public void loadNumericRows(final Table t, final byte[] f, int startRow, int endRow)
  2. throws IOException {
  3. for (int i = startRow; i < endRow; i++) {
  4. byte[] data = Bytes.toBytes(String.valueOf(i));
  5. Put put = new Put(data);
  6. put.addColumn(f, null, data);
  7. t.put(put);
  8. }
  9. }

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

  1. @Override
  2. public Object run() throws Exception {
  3. Put put = new Put(Bytes.toBytes("test"));
  4. put.addColumn(TEST_FAMILY, Bytes.toBytes("qual"), Bytes.toBytes("value"));
  5. table.put(put);
  6. return null;
  7. }
  8. };

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

  1. private void writeData(Table t) throws IOException {
  2. List<Put> puts = new ArrayList<>(NUM_ROWS);
  3. for (int i = 0; i < NUM_ROWS; i++) {
  4. Put p = new Put(Bytes.toBytes(i + 1));
  5. p.addColumn(FAMILY, QUALIFIER, Bytes.toBytes(value));
  6. puts.add(p);
  7. }
  8. t.put(puts);
  9. }

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

  1. private void writeData(Table t) throws IOException {
  2. List<Put> puts = new ArrayList<>(NUM_ROWS);
  3. for (int i = 0; i < NUM_ROWS; i++) {
  4. Put p = new Put(Bytes.toBytes(i + 1));
  5. p.addColumn(FAMILY, EXPLICIT_QUAL, EXPLICIT_VAL);
  6. p.addColumn(FAMILY, IMPLICIT_QUAL, IMPLICIT_VAL);
  7. puts.add(p);
  8. }
  9. t.put(puts);
  10. }

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

  1. void addData(int start) throws IOException {
  2. List<Put> puts = new ArrayList<>();
  3. for (int i=start; i< start + 100; i++) {
  4. Put put = new Put(Bytes.toBytes(i));
  5. put.addColumn(family, family, Bytes.toBytes(i));
  6. puts.add(put);
  7. }
  8. table.put(puts);
  9. }
  10. }

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

  1. protected static void loadData(String prefix, byte[] row) throws IOException {
  2. List<Put> puts = new ArrayList<>(NB_ROWS_IN_BATCH);
  3. for (int i = 0; i < NB_ROWS_IN_BATCH; i++) {
  4. Put put = new Put(Bytes.toBytes(prefix + Integer.toString(i)));
  5. put.addColumn(famName, row, row);
  6. puts.add(put);
  7. }
  8. htable1.put(puts);
  9. }

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

  1. private void writeData(Table t) throws IOException {
  2. List<Put> puts = new ArrayList<>(NUM_ROWS);
  3. for (int i = 0; i < NUM_ROWS; i++) {
  4. Put p = new Put(Bytes.toBytes(i + 1));
  5. p.addColumn(FAMILY, QUALIFIER, Bytes.toBytes(value));
  6. puts.add(p);
  7. }
  8. t.put(puts);
  9. }

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

  1. private void randomCFPuts(Table table, byte[] row, byte[] family, int nPuts)
  2. throws Exception {
  3. Put put = new Put(row);
  4. for (int i = 0; i < nPuts; i++) {
  5. byte[] qualifier = Bytes.toBytes(random.nextInt());
  6. byte[] value = Bytes.toBytes(random.nextInt());
  7. put.addColumn(family, qualifier, value);
  8. }
  9. table.put(put);
  10. }

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

  1. @Before
  2. public void before() throws Exception {
  3. table = util.createTable(TEST_TABLE, TEST_FAMILY);
  4. Put puta = new Put(ROW_A);
  5. puta.addColumn(TEST_FAMILY, qualifierCol1, bytes1);
  6. table.put(puta);
  7. Put putb = new Put(ROW_B);
  8. putb.addColumn(TEST_FAMILY, qualifierCol1, bytes2);
  9. table.put(putb);
  10. Put putc = new Put(ROW_C);
  11. putc.addColumn(TEST_FAMILY, qualifierCol1, bytes3);
  12. table.put(putc);
  13. }

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

  1. private void putOneRow(Table table) throws IOException {
  2. Put put = new Put(ROWKEY);
  3. put.addColumn(FAMILY, Bytes.toBytes("A"), Bytes.toBytes("a"));
  4. put.addColumn(FAMILY, Bytes.toBytes("B"), Bytes.toBytes("b"));
  5. put.addColumn(FAMILY, Bytes.toBytes("C"), Bytes.toBytes("c"));
  6. table.put(put);
  7. }

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

  1. @Before
  2. public void before() throws Exception {
  3. final byte[][] SPLIT_KEYS = new byte[][] { ROW_B, ROW_C };
  4. Table table = util.createTable(TEST_TABLE, TEST_FAMILY, SPLIT_KEYS);
  5. Put puta = new Put(ROW_A);
  6. puta.addColumn(TEST_FAMILY, Bytes.toBytes("col1"), Bytes.toBytes(1));
  7. table.put(puta);
  8. Put putb = new Put(ROW_B);
  9. putb.addColumn(TEST_FAMILY, Bytes.toBytes("col1"), Bytes.toBytes(1));
  10. table.put(putb);
  11. Put putc = new Put(ROW_C);
  12. putc.addColumn(TEST_FAMILY, Bytes.toBytes("col1"), Bytes.toBytes(1));
  13. table.put(putc);
  14. }

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

  1. public void loadTable(final Table table, int numRows) throws IOException {
  2. List<Put> puts = new ArrayList<>(numRows);
  3. for (int i = 0; i < numRows; ++i) {
  4. byte[] row = Bytes.toBytes(String.format("%09d", i));
  5. Put put = new Put(row);
  6. put.setDurability(Durability.SKIP_WAL);
  7. put.addColumn(FAMILY_NAME, null, row);
  8. table.put(put);
  9. }
  10. }

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

  1. private void generateRows(int numberOfRows, Table ht, byte[] family, byte[] qf, byte[] value)
  2. throws IOException {
  3. for (int i = 0; i < numberOfRows; i++) {
  4. byte[] row = Bytes.toBytes(i);
  5. Put p = new Put(row);
  6. p.addColumn(family, qf, value);
  7. ht.put(p);
  8. }
  9. TEST_UTIL.flush();
  10. }

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

  1. protected static void loadTable(Table table) throws Exception {
  2. Put p; // 100 + 1 row to t1_syncup
  3. for (int i = 0; i < NB_ROWS_IN_BATCH; i++) {
  4. p = new Put(Bytes.toBytes("row" + i));
  5. p.setDurability(Durability.SKIP_WAL);
  6. p.addColumn(famName, qualName, Bytes.toBytes("val" + i));
  7. table.put(p);
  8. }
  9. }

相关文章