本文整理了Java中co.cask.cdap.api.common.Bytes.toLong()
方法的一些代码示例,展示了Bytes.toLong()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytes.toLong()
方法的具体详情如下:
包路径:co.cask.cdap.api.common.Bytes
类名称:Bytes
方法名:toLong
[英]Converts a byte array to a long value. Reverses #toBytes(long)
[中]将字节数组转换为长值。反转#toBytes(长)
代码示例来源:origin: cdapio/cdap
/**
* Converts a byte array to a long value. Reverses
* {@link #toBytes(long)}
* @param bytes array
* @return the long value
*/
public static long toLong(byte[] bytes) {
return toLong(bytes, 0, SIZEOF_LONG);
}
代码示例来源:origin: caskdata/cdap
@Override
public Long convert(byte[] rowKey) {
return Bytes.toLong(rowKey);
}
})
代码示例来源:origin: co.cask.cdap/cdap-api-common
/**
* Converts a byte array to a long value. Assumes there will be
* {@link #SIZEOF_LONG} bytes available.
*
* @param bytes bytes
* @param offset offset
* @return the long value
*/
public static long toLong(byte[] bytes, int offset) {
return toLong(bytes, offset, SIZEOF_LONG);
}
代码示例来源:origin: co.cask.cdap/cdap-data-fabric
/**
* @param stateValue value of the state column
* @return write pointer of the latest change of the state value
*/
public static long getStateWritePointer(byte[] stateValue) {
return Bytes.toLong(stateValue, 0, Longs.BYTES);
}
代码示例来源:origin: co.cask.cdap/cdap-api-common
/**
* Return double made from passed bytes.
* @param bytes byte array
* @param offset offset where double is
* @return Return double made from passed bytes.
*/
public static double toDouble(final byte [] bytes, final int offset) {
return Double.longBitsToDouble(toLong(bytes, offset, SIZEOF_LONG));
}
代码示例来源:origin: caskdata/cdap
private synchronized long getLong(byte[] rowKey, byte[] column) {
byte[] result = metaTable.get(rowKey, column);
if (result == null) {
return 0;
}
return Bytes.toLong(result);
}
代码示例来源:origin: caskdata/cdap
private MessageFilter.Result accept(@Nullable byte[] txPtr) {
// No transaction info available, so accept this message (it must have been published non-transactionally)
if (filter == null || txPtr == null) {
return MessageFilter.Result.ACCEPT;
}
return filter.filter(Bytes.toLong(txPtr));
}
}
代码示例来源:origin: cdapio/cdap
/**
* Fetch the publish timestamp from the message table row key.
*
* @param messageTableRowKey byte array containing message table row key
* @param offset start of the row key in the byte array
* @param rowKeyLength length of the row key byte array
* @return publish timestamp
*/
public static long getPublishTimestamp(byte[] messageTableRowKey, int offset, int rowKeyLength) {
return Bytes.toLong(messageTableRowKey, offset + getTopicLengthMessageEntry(rowKeyLength));
}
代码示例来源:origin: co.cask.cdap/cdap-watchdog
private synchronized long getLong(byte[] rowKey, byte[] column) {
byte[] result = metaTable.get(rowKey, column);
if (result == null) {
return 0;
}
return Bytes.toLong(result);
}
代码示例来源:origin: cdapio/cdap
/**
* @param keylength Pass if you have it to save on a int creation.
* @return Timestamp
*/
long getTimestamp(final int keylength) {
int tsOffset = getTimestampOffset(keylength);
return Bytes.toLong(this.bytes, tsOffset);
}
代码示例来源:origin: caskdata/cdap
public ImmutablePayloadTableEntry(byte[] row, byte[] payload) {
this.topicId = MessagingUtils.toTopicId(row, 0, row.length - Bytes.SIZEOF_SHORT - (2 * Bytes.SIZEOF_LONG)
- Bytes.SIZEOF_INT);
this.generation = Bytes.toInt(row, row.length - Bytes.SIZEOF_SHORT - (2 * Bytes.SIZEOF_LONG) - Bytes.SIZEOF_INT);
this.transactionWriterPointer = Bytes.toLong(row, row.length - Bytes.SIZEOF_SHORT - (2 * Bytes.SIZEOF_LONG));
this.writeTimestamp = Bytes.toLong(row, row.length - Bytes.SIZEOF_SHORT - Bytes.SIZEOF_LONG);
this.sequenceId = Bytes.toShort(row, row.length - Bytes.SIZEOF_SHORT);
this.payload = payload;
}
代码示例来源:origin: co.cask.cdap/cdap-tms
public ImmutableMessageTableEntry(byte[] row, @Nullable byte[] payload, @Nullable byte[] txPtr) {
this.topicId = MessagingUtils.toTopicId(row, 0,
row.length - Bytes.SIZEOF_SHORT - Bytes.SIZEOF_LONG - Bytes.SIZEOF_INT);
this.generation = Bytes.toInt(row, row.length - Bytes.SIZEOF_SHORT - Bytes.SIZEOF_LONG - Bytes.SIZEOF_INT);
int topicLength = MessagingUtils.getTopicLengthMessageEntry(row.length);
this.publishTimestamp = Bytes.toLong(row, topicLength);
this.sequenceId = Bytes.toShort(row, topicLength + Bytes.SIZEOF_LONG);
this.transactional = (txPtr != null);
// since we mark tx as negative when tx is rolled back, we return the absolute value of tx
this.transactionWritePointer = txPtr == null ? -1 : Math.abs(Bytes.toLong(txPtr));
this.payload = payload;
}
代码示例来源:origin: caskdata/cdap
public ImmutableMessageTableEntry(byte[] row, @Nullable byte[] payload, @Nullable byte[] txPtr) {
this.topicId = MessagingUtils.toTopicId(row, 0,
row.length - Bytes.SIZEOF_SHORT - Bytes.SIZEOF_LONG - Bytes.SIZEOF_INT);
this.generation = Bytes.toInt(row, row.length - Bytes.SIZEOF_SHORT - Bytes.SIZEOF_LONG - Bytes.SIZEOF_INT);
int topicLength = MessagingUtils.getTopicLengthMessageEntry(row.length);
this.publishTimestamp = Bytes.toLong(row, topicLength);
this.sequenceId = Bytes.toShort(row, topicLength + Bytes.SIZEOF_LONG);
this.transactional = (txPtr != null);
// since we mark tx as negative when tx is rolled back, we return the absolute value of tx
this.transactionWritePointer = txPtr == null ? -1 : Math.abs(Bytes.toLong(txPtr));
this.payload = payload;
}
代码示例来源:origin: co.cask.cdap/cdap-data-fabric
/**
* For a queue entry consumer state, serialized to byte array, return whether it is processed and committed.
*/
public static boolean isCommittedProcessed(byte[] stateBytes, Transaction tx) {
long writePointer = Bytes.toLong(stateBytes, 0, Longs.BYTES);
if (!tx.isVisible(writePointer)) {
return false;
}
byte state = stateBytes[Longs.BYTES + Ints.BYTES];
return state == ConsumerEntryState.PROCESSED.getState();
}
代码示例来源:origin: cdapio/cdap
/**
* Get the run count of the given program.
*
* @param programId the program to get the count
* @return the number of run count
*/
public long getProgramRunCount(ProgramId programId) {
MDSKey key = getProgramKeyBuilder(TYPE_COUNT, programId).build();
byte[] count = getValue(key);
return count == null ? 0 : Bytes.toLong(count);
}
代码示例来源:origin: cdapio/cdap
@ReadWrite
@Override
public long incrementAndGet(byte[] row, byte[] column, long amount) {
byte[] result = incrementAndGet(row, new byte[][]{column}, new long[]{amount}).get(column);
return Bytes.toLong(result);
}
代码示例来源:origin: cdapio/cdap
@Nullable
public Long read(String key) {
byte[] read = keyValueTable.read(key);
return read == null ? null : Bytes.toLong(read);
}
}
代码示例来源:origin: cdapio/cdap
private long getCounts(String word, TimeseriesTable tsTable) {
long result = 0;
Iterator<TimeseriesTable.Entry> itor = tsTable.read(Bytes.toBytes(word), 0, Long.MAX_VALUE);
while (itor.hasNext()) {
result += Bytes.toLong(itor.next().getValue());
}
return result;
}
}
代码示例来源:origin: cdapio/cdap
@GET
@Path("/query")
public void query(HttpServiceRequest request,
HttpServiceResponder responder, @QueryParam("type") Record record) {
long count = Bytes.toLong(records.read(Bytes.toBytes(record.getType().name())));
responder.sendString(200, Long.toString(count), Charsets.UTF_8);
}
}
代码示例来源:origin: caskdata/cdap
private void verifyIncrements() throws Exception {
Map<byte[], byte[]> result = table.get(ROW_TO_INCREMENT, new byte[][]{COLUMN_TO_INCREMENT}).getColumns();
Assert.assertFalse(result.isEmpty());
byte[] val = result.get(COLUMN_TO_INCREMENT);
long sum1to100 = ((1 + 99) * 99 / 2);
Assert.assertEquals(n * sum1to100, Bytes.toLong(val));
}
});
内容来源于网络,如有侵权,请联系作者删除!