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

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

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

Put.setWriteToWAL介绍

暂无

代码示例

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

@Override
 public Void run() throws Exception {
  for (Row r : actions) {
   if (r instanceof Put) {
    ((Put) r).setWriteToWAL(enableWal);
   }
   // Newer versions of HBase - Increment implements Row.
   if (r instanceof Increment) {
    ((Increment) r).setWriteToWAL(enableWal);
   }
  }
  table.batch(actions);
  return null;
 }
});

代码示例来源:origin: klout/brickhouse

public void addKeyValue(String key, String val) throws HiveException {
    Put thePut = new Put(key.getBytes());
    thePut.add(getFamily(), getQualifier(), val.getBytes());
    thePut.setWriteToWAL(false);
    putList.add(thePut);
  }
}

代码示例来源:origin: forcedotcom/phoenix

@SuppressWarnings("deprecation")
private void newMutations() {
  this.setValues = new Put(this.key);
  this.unsetValues = new Delete(this.key);
  this.setValues.setWriteToWAL(!isWALDisabled());
  this.unsetValues.setWriteToWAL(!isWALDisabled());
}

代码示例来源:origin: forcedotcom/phoenix

@SuppressWarnings("deprecation")
public Put buildUpdateMutation(ValueGetter valueGetter, ImmutableBytesWritable dataRowKeyPtr, long ts) throws IOException {
  Put put = null;
  // New row being inserted: add the empty key value
  if (valueGetter.getLatestValue(dataEmptyKeyValueRef) == null) {
    byte[] indexRowKey = this.buildRowKey(valueGetter, dataRowKeyPtr);
    put = new Put(indexRowKey);
    // add the keyvalue for the empty row
    put.add(this.kvBuilder.buildPut(new ImmutableBytesPtr(indexRowKey),
      this.getEmptyKeyValueFamily(), QueryConstants.EMPTY_COLUMN_BYTES_PTR, ts,
      ByteUtil.EMPTY_BYTE_ARRAY_PTR));
    put.setWriteToWAL(!indexWALDisabled);
  }
  int i = 0;
  for (ColumnReference ref : this.getCoverededColumns()) {
    ImmutableBytesPtr cq = this.indexQualifiers.get(i++);
    ImmutableBytesPtr value = valueGetter.getLatestValue(ref);
    byte[] indexRowKey = this.buildRowKey(valueGetter, dataRowKeyPtr);
    ImmutableBytesPtr rowKey = new ImmutableBytesPtr(indexRowKey);
    if (value != null) {
      if (put == null) {
        put = new Put(indexRowKey);
        put.setWriteToWAL(!indexWALDisabled);
      }
      //this is a little bit of extra work for installations that are running <0.94.14, but that should be rare and is a short-term set of wrappers - it shouldn't kill GC
      put.add(this.kvBuilder.buildPut(rowKey, ref.getFamilyWritable(), cq, ts, value));
    }
  }
  return put;
}

代码示例来源:origin: edu.berkeley.cs.shark/hive-hbase-handler

@Override
 public void write(Writable w) throws IOException {
  Put put = (Put) w;
  put.setWriteToWAL(walEnabled);
  table.put(put);
 }
};

代码示例来源:origin: domino-succ/domino

private void _writeTid() {
 try {
  byte[] value = Bytes.toBytes(preAlloc.get());
  Put put = new Put(TidDef.EP_ROW);
  put.add(TidDef.EP_FAMILY, TidDef.EP_COLUMN, TidDef.EP_VERSION, value);
  put.setWriteToWAL(true);
  region.put(put);
 }
 catch (Exception e) {
  LOG.error("Error writing pre-allocated tid to HBase.", e);
 }
}

代码示例来源:origin: org.apache.pig/pig

/**
 * Public method to initialize a Put. Used to allow assertions of how Puts
 * are initialized by unit tests.
 *
 * @param key
 * @param type
 * @return new put
 * @throws IOException
 */
public Put createPut(Object key, byte type) throws IOException {
  Put put = new Put(objToBytes(key, type));
  if(noWAL_) {
    put.setWriteToWAL(false);
  }
  return put;
}

代码示例来源:origin: org.apache.flume.flume-ng-sinks/flume-ng-hbase-sink

@Override
 public Void run() throws Exception {
  for (Row r : actions) {
   if (r instanceof Put) {
    ((Put) r).setWriteToWAL(enableWal);
   }
   // Newer versions of HBase - Increment implements Row.
   if (r instanceof Increment) {
    ((Increment) r).setWriteToWAL(enableWal);
   }
  }
  table.batch(actions);
  return null;
 }
});

代码示例来源:origin: jrkinley/storm-hbase

/**
 * Creates a HBase {@link Put} from a Storm {@link Tuple}
 * @param tuple The {@link Tuple}
 * @return {@link Put}
 */
public Put getPutFromTuple(final Tuple tuple) {
 byte[] rowKey = Bytes.toBytes(tuple.getStringByField(tupleRowKeyField));
 long ts = 0;
 if (!tupleTimestampField.equals("")) {
  ts = tuple.getLongByField(tupleTimestampField);
 }
 Put p = new Put(rowKey);
 p.setWriteToWAL(writeToWAL);
 if (columnFamilies.size() > 0) {
  for (String cf : columnFamilies.keySet()) {
   byte[] cfBytes = Bytes.toBytes(cf);
   for (String cq : columnFamilies.get(cf)) {
    byte[] cqBytes = Bytes.toBytes(cq);
    byte[] val = Bytes.toBytes(tuple.getStringByField(cq));
    if (ts > 0) {
     p.add(cfBytes, cqBytes, ts, val);
    } else {
     p.add(cfBytes, cqBytes, val);
    }
   }
  }
 }
 return p;
}

代码示例来源:origin: jrkinley/storm-hbase

/**
 * Creates a HBase {@link Put} from a Storm {@link TridentTuple}
 * @param tuple The {@link TridentTuple}
 * @return {@link Put}
 */
public Put getPutFromTridentTuple(final TridentTuple tuple) {
 byte[] rowKey = Bytes.toBytes(tuple.getStringByField(tupleRowKeyField));
 long ts = 0;
 if (!tupleTimestampField.equals("")) {
  ts = tuple.getLongByField(tupleTimestampField);
 }
 Put p = new Put(rowKey);
 p.setWriteToWAL(writeToWAL);
 if (columnFamilies.size() > 0) {
  for (String cf : columnFamilies.keySet()) {
   byte[] cfBytes = Bytes.toBytes(cf);
   for (String cq : columnFamilies.get(cf)) {
    byte[] cqBytes = Bytes.toBytes(cq);
    byte[] val = Bytes.toBytes(tuple.getStringByField(cq));
    if (ts > 0) {
     p.add(cfBytes, cqBytes, ts, val);
    } else {
     p.add(cfBytes, cqBytes, val);
    }
   }
  }
 }
 return p;
}

代码示例来源:origin: co.cask.hbase/hbase

/**
 * Add updates first to the hlog and then add values to memstore.
 * Warning: Assumption is caller has lock on passed in row.
 * @param family
 * @param edits Cell updates by column
 * @praram now
 * @throws IOException
 */
private void put(byte [] family, List<KeyValue> edits)
throws IOException {
 Map<byte[], List<KeyValue>> familyMap;
 familyMap = new HashMap<byte[], List<KeyValue>>();
 familyMap.put(family, edits);
 Put p = new Put();
 p.setFamilyMap(familyMap);
 p.setClusterId(HConstants.DEFAULT_CLUSTER_ID);
 p.setWriteToWAL(true);
 this.internalPut(p, HConstants.DEFAULT_CLUSTER_ID, true);
}

代码示例来源:origin: co.cask.hbase/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, Writable action) throws IOException {
  HTable table = getTable(tableName);
  // The actions are not immutable, so we defensively copy them
  if (action instanceof Put) {
   Put put = new Put((Put) action);
   put.setWriteToWAL(useWriteAheadLogging);
   table.put(put);
  } else if (action instanceof Delete) {
   Delete delete = new Delete((Delete) action);
   table.delete(delete);
  } else
   throw new IllegalArgumentException(
     "action must be either Delete or Put");
 }
}

代码示例来源:origin: NGDATA/lilyproject

Put put = new Put(k);
put.add(f, null, k);
if (r.getLog() == null) put.setWriteToWAL(false);
r.put(put);
rowCount++;

代码示例来源:origin: domino-succ/domino

DominoConst.VERSION_COL);
Put commit = new Put(row);
commit.setWriteToWAL(true);
boolean isFresh = true;
if (versions.size() >= DominoConst.MAX_VERSION) {

代码示例来源:origin: ECNU-1X/DataX-Masking

if(this.versionColumn == null){
  put = new Put(rowkey);
  put.setWriteToWAL(super.walFlag);
}else {
  long timestamp = getVersion(record);

代码示例来源:origin: co.cask.hbase/hbase

: HConstants.EMPTY_BYTE_ARRAY);
put.setWriteToWAL(m.writeToWAL);

代码示例来源:origin: co.cask.hbase/hbase

: HConstants.EMPTY_BYTE_ARRAY);
put.setWriteToWAL(m.writeToWAL);

代码示例来源:origin: co.cask.hbase/hbase

/**
 * Creates a {@link Put} (HBase) from a {@link TPut} (Thrift)
 * 
 * @param in the <code>TPut</code> to convert
 * 
 * @return converted <code>Put</code>
 */
public static Put putFromThrift(TPut in) {
 Put out;
 if (in.isSetTimestamp()) {
  out = new Put(in.getRow(), in.getTimestamp(), null);
 } else {
  out = new Put(in.getRow());
 }
 out.setWriteToWAL(in.isWriteToWal());
 for (TColumnValue columnValue : in.getColumnValues()) {
  if (columnValue.isSetTimestamp()) {
   out.add(columnValue.getFamily(), columnValue.getQualifier(), columnValue.getTimestamp(),
     columnValue.getValue());
  } else {
   out.add(columnValue.getFamily(), columnValue.getQualifier(), columnValue.getValue());
  }
 }
 return out;
}

代码示例来源:origin: alibaba/wasp

put.setWriteToWAL(proto.getWriteToWAL());
for (WaspProtos.StringBytesPair attribute : proto.getAttributeList()) {
 put.setAttribute(attribute.getName(), attribute.getValue().toByteArray());

相关文章