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

x33g5p2x  于2022-01-26 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(224)

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

Put.setDurability介绍

暂无

代码示例

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

public void write(ImmutableBytesWritable key,
  Object value) throws IOException {
 Put put;
 if (value instanceof Put){
  put = (Put)value;
 } else if (value instanceof PutWritable) {
  put = new Put(((PutWritable)value).getPut());
 } else {
  throw new IllegalArgumentException("Illegal Argument " + (value == null ? "null" : value.getClass().getName()));
 }
 if(m_walEnabled) {
  put.setDurability(Durability.SYNC_WAL);
 } else {
  put.setDurability(Durability.SKIP_WAL);
 }
 m_table.mutate(put);
}

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

private Put newPut(Durability durability) {
 Put p = new Put(ROW);
 p.addColumn(FAMILY, COL, COL);
 if (durability != null) {
  p.setDurability(durability);
 }
 return p;
}

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

private static Put createPut(final byte[][] families, final byte[] key, final byte[] value) {
 byte[] q = Bytes.toBytes("q");
 Put put = new Put(key);
 put.setDurability(Durability.SKIP_WAL);
 for (byte[] family: families) {
  put.addColumn(family, q, value);
 }
 return put;
}

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

Put put = new Put(rowKey);
put.setDurability(durability);
for (ColumnList.Column col : cols.getColumns()) {
  if (col.getTs() > 0) {
    put.add(
      col.getFamily(),
      col.getQualifier(),
    );
  } else {
    put.add(
      col.getFamily(),
      col.getQualifier(),
mutations.add(new Put(rowKey));

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

private static Put createPut(final byte[][] families, final byte[] key, final byte[] value) {
 byte[] q = Bytes.toBytes("q");
 Put put = new Put(key);
 put.setDurability(Durability.SKIP_WAL);
 for (byte[] family: families) {
  put.addColumn(family, q, value);
 }
 return put;
}

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

Delete delete = new Delete(row);
addAttributes(delete, attributes);
Put put = new Put(row, timestamp);
addAttributes(put, attributes);
for (Mutation m : mutations) {
    put.add(builder.clear()
      .setRow(put.getRow())
      .setFamily(famAndQf[0])
   throw new IllegalArgumentException("Invalid famAndQf provided.");
  put.setDurability(m.writeToWAL ? Durability.SYNC_WAL : Durability.SKIP_WAL);

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

public static void put(final Table loader, final byte [] bytes,
 final long ts)
throws IOException {
 Put put = new Put(ROW, ts);
 put.setDurability(Durability.SKIP_WAL);
 put.addColumn(FAMILY_NAME, QUALIFIER_NAME, bytes);
 loader.put(put);
}

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

/**
  * Writes an action (Put or Delete) to the specified table.
  *
  * @param tableName
  *          the table being updated.
  * @param action
  *          the update, either a put or a delete.
  * @throws IllegalArgumentException
  *          if the action is not a put or a delete.
  */
 @Override
 public void write(ImmutableBytesWritable tableName, Mutation action) throws IOException {
  BufferedMutator mutator = getBufferedMutator(tableName);
  // The actions are not immutable, so we defensively copy them
  if (action instanceof Put) {
   Put put = new Put((Put) action);
   put.setDurability(useWriteAheadLogging ? Durability.SYNC_WAL
     : Durability.SKIP_WAL);
   mutator.mutate(put);
  } else if (action instanceof Delete) {
   Delete delete = new Delete((Delete) action);
   mutator.mutate(delete);
  } else
   throw new IllegalArgumentException(
     "action must be either Delete or Put");
 }
}

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

private Put newPutWithSkipWAL() {
 Put put = new Put(Bytes.toBytes("row"));
 put.addColumn(CF, CQ, Bytes.toBytes("value"));
 put.setDurability(Durability.SKIP_WAL);
 return put;
}

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

static int replayEdit(HRegion region, WAL.Entry entry) throws IOException {
 if (WALEdit.isMetaEditFamily(entry.getEdit().getCells().get(0))) {
  return 0; // handled elsewhere
 }
 Put put = new Put(CellUtil.cloneRow(entry.getEdit().getCells().get(0)));
 for (Cell cell : entry.getEdit().getCells()) put.add(cell);
 put.setDurability(Durability.SKIP_WAL);
 MutationReplay mutation = new MutationReplay(MutationType.PUT, put, 0, 0);
 region.batchReplay(new MutationReplay[] {mutation},
  entry.getKey().getSequenceId());
 return Integer.parseInt(Bytes.toString(put.getRow()));
}

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

/**
 * Load table of multiple column families with rows from 'aaa' to 'zzz'.
 * @param t Table
 * @param f Array of Families to load
 * @param value the values of the cells. If null is passed, the row key is used as value
 * @return Count of rows loaded.
 * @throws IOException
 */
public int loadTable(final Table t, final byte[][] f, byte[] value,
  boolean writeToWAL) throws IOException {
 List<Put> puts = new ArrayList<>();
 for (byte[] row : HBaseTestingUtility.ROWS) {
  Put put = new Put(row);
  put.setDurability(writeToWAL ? Durability.USE_DEFAULT : Durability.SKIP_WAL);
  for (int i = 0; i < f.length; i++) {
   byte[] value1 = value != null ? value : row;
   put.addColumn(f[i], f[i], value1);
  }
  puts.add(put);
 }
 t.put(puts);
 return puts.size();
}

代码示例来源: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: apache/hbase

try {
 table = getTable(tableName);
 Put put = new Put(getBytes(row), timestamp);
 addAttributes(put, attributes);
      + "over the whole column family.");
   } else {
    put.add(builder.clear()
      .setRow(put.getRow())
      .setFamily(famAndQf[0])
      .build());
   put.setDurability(m.writeToWAL ? Durability.SYNC_WAL : Durability.SKIP_WAL);

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

static void writeTestDataBatch(TableName tableName,
  int batchId) throws Exception {
 LOG.debug("Writing test data batch " + batchId);
 List<Put> puts = new ArrayList<>();
 for (int i = 0; i < NUM_ROWS_PER_BATCH; ++i) {
  Put put = new Put(getRowKey(batchId, i));
  for (int j = 0; j < NUM_COLS_PER_ROW; ++j) {
   put.addColumn(CF_BYTES, getQualifier(j), getValue(batchId, i, j));
  }
  put.setDurability(Durability.SKIP_WAL);
  puts.add(put);
 }
 try (Connection conn = ConnectionFactory.createConnection(conf);
   Table table = conn.getTable(tableName)) {
  table.put(puts);
 }
}

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

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

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

Put put;
try {
 put = new Put(getBytes(row), HConstants.LATEST_TIMESTAMP);
 addAttributes(put, attributes);
 put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
   .setRow(put.getRow())
   .setFamily(famAndQf[0])
     : HConstants.EMPTY_BYTE_ARRAY)
   .build());
 put.setDurability(mput.writeToWAL ? Durability.SYNC_WAL : Durability.SKIP_WAL);
} catch (IOException | IllegalArgumentException e) {
 LOG.warn(e.getMessage(), e);

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

@Test
public void testMutationsWithoutWal() throws Exception {
 Put p = new Put(row).addColumn(cf, qualifier, val)
   .setDurability(Durability.SKIP_WAL);
 table.put(p);
 metricsRegionServer.getRegionServerWrapper().forceRecompute();
 assertGauge("mutationsWithoutWALCount", 1);
 long minLength = row.length + cf.length + qualifier.length + val.length;
 metricsHelper.assertGaugeGt("mutationsWithoutWALSize", minLength, serverSource);
}

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

private void putData(Region region, int startRow, int numRows, byte[] qf, byte[]... families)
  throws IOException {
 for (int i = startRow; i < startRow + numRows; i++) {
  Put put = new Put(Bytes.toBytes("" + i));
  put.setDurability(Durability.SKIP_WAL);
  for (byte[] family : families) {
   put.addColumn(family, qf, null);
  }
  region.put(put);
 }
}

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

assert type == MutationType.PUT: type.name();
long timestamp = proto.hasTimestamp()? proto.getTimestamp(): HConstants.LATEST_TIMESTAMP;
Put put = proto.hasRow() ? new Put(proto.getRow().toByteArray(), timestamp) : null;
int cellCount = proto.hasAssociatedCellCount()? proto.getAssociatedCellCount(): 0;
if (cellCount > 0) {
   put = new Put(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), timestamp);
  put.add(cell);
    allTagsBytes = qv.getTags().toByteArray();
    if(qv.hasDeleteType()) {
     put.add(cellBuilder.clear()
       .setRow(put.getRow())
       .setFamily(family)
       .build());
    } else {
     put.add(cellBuilder.clear()
       .setRow(put.getRow())
       .setFamily(family)
put.setDurability(toDurability(proto.getDurability()));
for (NameBytesPair attribute: proto.getAttributeList()) {
 put.setAttribute(attribute.getName(), attribute.getValue().toByteArray());

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

@Test
public void testCheckAndMutateTimestampsAreMonotonic() throws IOException {
 region = initHRegion(tableName, method, CONF, fam1);
 ManualEnvironmentEdge edge = new ManualEnvironmentEdge();
 EnvironmentEdgeManager.injectEdge(edge);
 edge.setValue(10);
 Put p = new Put(row);
 p.setDurability(Durability.SKIP_WAL);
 p.addColumn(fam1, qual1, qual1);
 region.put(p);
 Result result = region.get(new Get(row));
 Cell c = result.getColumnLatestCell(fam1, qual1);
 assertNotNull(c);
 assertEquals(10L, c.getTimestamp());
 edge.setValue(1); // clock goes back
 p = new Put(row);
 p.setDurability(Durability.SKIP_WAL);
 p.addColumn(fam1, qual1, qual2);
 region.checkAndMutate(row, fam1, qual1, CompareOperator.EQUAL, new BinaryComparator(qual1), p);
 result = region.get(new Get(row));
 c = result.getColumnLatestCell(fam1, qual1);
 assertEquals(10L, c.getTimestamp());
 assertTrue(Bytes.equals(c.getValueArray(), c.getValueOffset(), c.getValueLength(),
  qual2, 0, qual2.length));
}

相关文章