本文整理了Java中org.apache.hadoop.hbase.client.Put.setTTL()
方法的一些代码示例,展示了Put.setTTL()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Put.setTTL()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Put
类名称:Put
方法名:setTTL
暂无
代码示例来源:origin: apache/hbase
@Override
public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c,
MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException {
Mutation mut = miniBatchOp.getOperation(0);
List<Cell> cells = mut.getFamilyCellMap().get(test);
Put[] puts = new Put[] {
new Put(Bytes.toBytes("cpPut")).addColumn(test, dummy, cells.get(0).getTimestamp(),
Bytes.toBytes("cpdummy")).setTTL(mut.getTTL())
};
LOG.info("Putting:" + Arrays.toString(puts));
miniBatchOp.addOperationsFromCP(0, puts);
}
}
代码示例来源:origin: apache/hbase
@Test
public void testPutWithTTL() throws Exception {
createTable(TestPutWithTTLCoprocessor.class.getName());
try (Table t = util.getConnection().getTable(tableName)) {
t.put(new Put(row1).addColumn(test, dummy, dummy).setTTL(3000));
assertRowCount(t, 2);
// wait long enough for the TTL to expire
Thread.sleep(5000);
assertRowCount(t, 0);
}
}
代码示例来源:origin: apache/hbase
p.addColumn(family, QUALIFIER, valBytes);
p.setTTL(1l);
context.write(new ImmutableBytesWritable(key), p);
代码示例来源:origin: apache/hbase
protected void populatePut(byte[] lineBytes, ImportTsv.TsvParser.ParsedLine parsed, Put put,
int i) throws BadTsvLineException, IOException {
Cell cell = null;
if (hfileOutPath == null) {
cell = new KeyValue(lineBytes, parsed.getRowKeyOffset(), parsed.getRowKeyLength(),
parser.getFamily(i), 0, parser.getFamily(i).length, parser.getQualifier(i), 0,
parser.getQualifier(i).length, ts, KeyValue.Type.Put, lineBytes,
parsed.getColumnOffset(i), parsed.getColumnLength(i));
if (cellVisibilityExpr != null) {
// We won't be validating the expression here. The Visibility CP will do
// the validation
put.setCellVisibility(new CellVisibility(cellVisibilityExpr));
}
if (ttl > 0) {
put.setTTL(ttl);
}
} else {
// Creating the KV which needs to be directly written to HFiles. Using the Facade
// KVCreator for creation of kvs.
cell = this.kvCreator.create(lineBytes, parsed.getRowKeyOffset(), parsed.getRowKeyLength(),
parser.getFamily(i), 0, parser.getFamily(i).length, parser.getQualifier(i), 0,
parser.getQualifier(i).length, ts, lineBytes, parsed.getColumnOffset(i),
parsed.getColumnLength(i), tags);
}
put.add(cell);
}
}
代码示例来源:origin: apache/metron
/**
* Creates an HBase Put.
*
* @param rowKey The row key.
* @param cols The columns to put.
* @param durability The durability of the put.
* @param timeToLiveMillis The TTL in milliseconds.
*/
private Put createPut(byte[] rowKey, ColumnList cols, Durability durability, long timeToLiveMillis) {
Put put = new Put(rowKey);
put.setDurability(durability);
put.setTTL(timeToLiveMillis);
addColumns(cols, put);
return put;
}
代码示例来源:origin: apache/metron
/**
* Adds a Mutation such as a Put or Increment with a time to live. The Mutation is only queued
* for later execution.
*
* @param rowKey The row key of the Mutation.
* @param cols The columns affected by the Mutation.
* @param durability The durability of the mutation.
* @param timeToLiveMillis The time to live in milliseconds.
*/
public void addMutation(byte[] rowKey, ColumnList cols, Durability durability, Long timeToLiveMillis) {
if (cols.hasColumns()) {
Put put = createPut(rowKey, cols, durability, timeToLiveMillis);
mutations.add(put);
}
if (cols.hasCounters()) {
Increment inc = createIncrement(rowKey, cols, durability, timeToLiveMillis);
mutations.add(inc);
}
if (mutations.isEmpty()) {
Put put = new Put(rowKey);
put.setTTL(timeToLiveMillis);
mutations.add(put);
}
}
代码示例来源:origin: org.apache.hbase/hbase-mapreduce
p.addColumn(family, QUALIFIER, valBytes);
p.setTTL(1l);
context.write(new ImmutableBytesWritable(key), p);
代码示例来源:origin: com.aliyun.hbase/alihbase-mapreduce
p.addColumn(family, QUALIFIER, valBytes);
p.setTTL(1l);
context.write(new ImmutableBytesWritable(key), p);
代码示例来源:origin: org.apache.hbase/hbase-mapreduce
p.addColumn(family, QUALIFIER, valBytes);
p.setTTL(1l);
context.write(new ImmutableBytesWritable(key), p);
代码示例来源:origin: com.aliyun.hbase/alihbase-mapreduce
p.addColumn(family, QUALIFIER, valBytes);
p.setTTL(1l);
context.write(new ImmutableBytesWritable(key), p);
代码示例来源:origin: harbby/presto-connectors
put.setTTL(ttl);
代码示例来源:origin: org.apache.hbase/hbase-mapreduce
protected void populatePut(byte[] lineBytes, ImportTsv.TsvParser.ParsedLine parsed, Put put,
int i) throws BadTsvLineException, IOException {
Cell cell = null;
if (hfileOutPath == null) {
cell = new KeyValue(lineBytes, parsed.getRowKeyOffset(), parsed.getRowKeyLength(),
parser.getFamily(i), 0, parser.getFamily(i).length, parser.getQualifier(i), 0,
parser.getQualifier(i).length, ts, KeyValue.Type.Put, lineBytes,
parsed.getColumnOffset(i), parsed.getColumnLength(i));
if (cellVisibilityExpr != null) {
// We won't be validating the expression here. The Visibility CP will do
// the validation
put.setCellVisibility(new CellVisibility(cellVisibilityExpr));
}
if (ttl > 0) {
put.setTTL(ttl);
}
} else {
// Creating the KV which needs to be directly written to HFiles. Using the Facade
// KVCreator for creation of kvs.
cell = this.kvCreator.create(lineBytes, parsed.getRowKeyOffset(), parsed.getRowKeyLength(),
parser.getFamily(i), 0, parser.getFamily(i).length, parser.getQualifier(i), 0,
parser.getQualifier(i).length, ts, lineBytes, parsed.getColumnOffset(i),
parsed.getColumnLength(i), tags);
}
put.add(cell);
}
}
代码示例来源:origin: com.aliyun.hbase/alihbase-mapreduce
protected void populatePut(byte[] lineBytes, ImportTsv.TsvParser.ParsedLine parsed, Put put,
int i) throws BadTsvLineException, IOException {
Cell cell = null;
if (hfileOutPath == null) {
cell = new KeyValue(lineBytes, parsed.getRowKeyOffset(), parsed.getRowKeyLength(),
parser.getFamily(i), 0, parser.getFamily(i).length, parser.getQualifier(i), 0,
parser.getQualifier(i).length, ts, KeyValue.Type.Put, lineBytes,
parsed.getColumnOffset(i), parsed.getColumnLength(i));
if (cellVisibilityExpr != null) {
// We won't be validating the expression here. The Visibility CP will do
// the validation
put.setCellVisibility(new CellVisibility(cellVisibilityExpr));
}
if (ttl > 0) {
put.setTTL(ttl);
}
} else {
// Creating the KV which needs to be directly written to HFiles. Using the Facade
// KVCreator for creation of kvs.
cell = this.kvCreator.create(lineBytes, parsed.getRowKeyOffset(), parsed.getRowKeyLength(),
parser.getFamily(i), 0, parser.getFamily(i).length, parser.getQualifier(i), 0,
parser.getQualifier(i).length, ts, lineBytes, parsed.getColumnOffset(i),
parsed.getColumnLength(i), tags);
}
put.add(cell);
}
}
内容来源于网络,如有侵权,请联系作者删除!