本文整理了Java中co.cask.cdap.api.common.Bytes.add()
方法的一些代码示例,展示了Bytes.add()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytes.add()
方法的具体详情如下:
包路径:co.cask.cdap.api.common.Bytes
类名称:Bytes
方法名:add
[英]Concatenate two byte arrays.
[中]连接两个字节数组。
代码示例来源:origin: cdapio/cdap
/**
* Concatenate two byte arrays.
* @param a lower half
* @param b upper half
* @return New array that has a in lower half and b in upper half.
*/
public static byte [] add(final byte [] a, final byte [] b) {
return add(a, b, EMPTY_BYTE_ARRAY);
}
代码示例来源:origin: co.cask.cdap/cdap-api-common
/**
* Concatenate two byte arrays.
* @param a lower half
* @param b upper half
* @return New array that has a in lower half and b in upper half.
*/
public static byte [] add(final byte [] a, final byte [] b) {
return add(a, b, EMPTY_BYTE_ARRAY);
}
代码示例来源:origin: co.cask.cdap/cdap-api-common
/**
* Return a byte array with value in <code>a</code> plus <code>length</code> prepended 0 bytes.
* @param a array
* @param length new array size
* @return Value in <code>a</code> plus <code>length</code> prepended 0 bytes
*/
public static byte [] padHead(final byte [] a, final int length) {
byte [] padding = new byte[length];
for (int i = 0; i < length; i++) {
padding[i] = 0;
}
return add(padding, a);
}
代码示例来源:origin: cdapio/cdap
/**
* Return a byte array with value in <code>a</code> plus <code>length</code> appended 0 bytes.
* @param a array
* @param length new array size
* @return Value in <code>a</code> plus <code>length</code> appended 0 bytes
*/
public static byte [] padTail(final byte [] a, final int length) {
byte [] padding = new byte[length];
for (int i = 0; i < length; i++) {
padding[i] = 0;
}
return add(a, padding);
}
代码示例来源:origin: cdapio/cdap
public Builder add(byte[] part) {
key = Bytes.add(key, Bytes.toBytes(part.length), part);
return this;
}
代码示例来源:origin: co.cask.cdap/cdap-data-fabric
public Builder add(long part) {
key = Bytes.add(key, Bytes.toBytes(part));
return this;
}
代码示例来源:origin: cdapio/cdap
public Builder add(int part) {
key = Bytes.add(key, Bytes.toBytes(part));
return this;
}
代码示例来源:origin: co.cask.cdap/cdap-data-fabric
public Builder add(byte[] part) {
key = Bytes.add(key, Bytes.toBytes(part.length), part);
return this;
}
代码示例来源:origin: cdapio/cdap
private Collection<byte[]> getRowChanges() {
// we resolve conflicts on row level of individual table
List<byte[]> changes = new ArrayList<>(buff.size());
for (byte[] changedRow : buff.keySet()) {
changes.add(Bytes.add(getNameAsTxChangePrefix(), changedRow));
}
return changes;
}
代码示例来源:origin: co.cask.cdap/cdap-data-fabric
private Collection<byte[]> getRowChanges() {
// we resolve conflicts on row level of individual table
List<byte[]> changes = new ArrayList<>(buff.size());
for (byte[] changedRow : buff.keySet()) {
changes.add(Bytes.add(getNameAsTxChangePrefix(), changedRow));
}
return changes;
}
代码示例来源:origin: co.cask.cdap/cdap-data-fabric
/**
* Gets the stop row for scan up to the read pointer of a transaction. Stop row is queueName + (readPointer + 1).
*/
public static byte[] getStopRowForTransaction(byte[] queueRowPrefix, Transaction transaction) {
return Bytes.add(queueRowPrefix, Bytes.toBytes(transaction.getReadPointer() + 1));
}
代码示例来源:origin: cdapio/cdap
public ReplicationStatusKey(String rowType, String regionName, UUID regionServerID) {
byte[] rowKey;
rowKey = Bytes.add(Bytes.toBytes(Bytes.toBytes(rowType).length), Bytes.toBytes(rowType));
rowKey = Bytes.add(rowKey, Bytes.toBytes(Bytes.toBytes(regionName).length), Bytes.toBytes(regionName));
rowKey = Bytes.add(rowKey, Bytes.toBytes(regionServerID));
this.rowType = rowType;
this.regionName = regionName;
this.rsID = regionServerID;
this.key = rowKey;
}
代码示例来源:origin: co.cask.cdap/cdap-hbase-compat-base
public ReplicationStatusKey(String rowType, String regionName, UUID regionServerID) {
byte[] rowKey;
rowKey = Bytes.add(Bytes.toBytes(Bytes.toBytes(rowType).length), Bytes.toBytes(rowType));
rowKey = Bytes.add(rowKey, Bytes.toBytes(Bytes.toBytes(regionName).length), Bytes.toBytes(regionName));
rowKey = Bytes.add(rowKey, Bytes.toBytes(regionServerID));
this.rowType = rowType;
this.regionName = regionName;
this.rsID = regionServerID;
this.key = rowKey;
}
代码示例来源:origin: co.cask.cdap/cdap-data-fabric
HBaseConsumerStateStore(String datasetName, QueueName queueName, Table table) {
super(datasetName, table);
this.queueName = queueName;
this.table = table;
this.barrierScanStartRow = Bytes.add(queueName.toBytes(), QueueEntryRow.getQueueEntryRowKey(queueName, 0L, 0));
this.barrierScanEndRow = Bytes.stopKeyForPrefix(
Bytes.add(queueName.toBytes(), QueueEntryRow.getQueueEntryRowKey(queueName, Long.MAX_VALUE, 0)));
}
代码示例来源:origin: co.cask.cdap/cdap-watchdog
@Override
public Map<Integer, Checkpoint> getCheckpoint(final Set<Integer> partitions) throws Exception {
return Transactionals.execute(transactional, context -> {
Table table = getCheckpointTable(context);
Map<Integer, Checkpoint> checkpoints = new HashMap<>();
for (final int partition : partitions) {
Row result = table.get(Bytes.add(rowKeyPrefix, Bytes.toBytes(partition)));
checkpoints.put(partition, createFromRow(result));
}
return checkpoints;
}, ServiceUnavailableException.class);
}
代码示例来源:origin: caskdata/cdap
@Override
public Map<Integer, Checkpoint> getCheckpoint(final Set<Integer> partitions) throws Exception {
return Transactionals.execute(transactional, context -> {
Table table = getCheckpointTable(context);
Map<Integer, Checkpoint> checkpoints = new HashMap<>();
for (final int partition : partitions) {
Row result = table.get(Bytes.add(rowKeyPrefix, Bytes.toBytes(partition)));
checkpoints.put(partition, createFromRow(result));
}
return checkpoints;
}, ServiceUnavailableException.class);
}
代码示例来源:origin: co.cask.cdap/cdap-data-fabric
/**
* Simple method to return a queue entry row key. This method is not for performance usage (e.g. in enqueue).
*/
public static byte[] getQueueEntryRowKey(QueueName queueName, long writePoint, int count) {
return Bytes.add(QueueEntryRow.getQueueRowPrefix(queueName), Bytes.toBytes(writePoint), Bytes.toBytes(count));
}
代码示例来源:origin: caskdata/cdap
@Inject
DefaultCheckpointManager(DatasetFramework datasetFramework, TransactionSystemClient txClient,
String topic, byte[] prefix) {
this.rowKeyPrefix = Bytes.add(prefix, Bytes.toBytes(topic));
this.lastCheckpoint = new HashMap<>();
this.datasetFramework = datasetFramework;
this.transactional = Transactions.createTransactionalWithRetry(
Transactions.createTransactional(new MultiThreadDatasetCache(
new SystemDatasetInstantiator(datasetFramework), txClient,
NamespaceId.SYSTEM, ImmutableMap.of(), null, null)),
RetryStrategies.retryOnConflict(20, 100)
);
}
代码示例来源:origin: caskdata/cdap
@Override
public Checkpoint getCheckpoint(final int partition) throws Exception {
Checkpoint checkpoint = Transactionals.execute(transactional, context -> {
Row result = getCheckpointTable(context).get(Bytes.add(rowKeyPrefix, Bytes.toBytes(partition)));
return createFromRow(result);
}, ServiceUnavailableException.class);
LOG.trace("Read checkpoint {} for partition {}", checkpoint, partition);
return checkpoint;
}
代码示例来源:origin: co.cask.cdap/cdap-watchdog
@Override
public Checkpoint getCheckpoint(final int partition) throws Exception {
Checkpoint checkpoint = Transactionals.execute(transactional, context -> {
Row result = getCheckpointTable(context).get(Bytes.add(rowKeyPrefix, Bytes.toBytes(partition)));
return createFromRow(result);
}, ServiceUnavailableException.class);
LOG.trace("Read checkpoint {} for partition {}", checkpoint, partition);
return checkpoint;
}
内容来源于网络,如有侵权,请联系作者删除!