co.cask.cdap.api.common.Bytes.toInt()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(121)

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

Bytes.toInt介绍

[英]Converts a byte array to an int value.
[中]将字节数组转换为int值。

代码示例

代码示例来源:origin: cdapio/cdap

public int getKeyLength() {
 if (keyLength == 0) {
  keyLength = Bytes.toInt(this.bytes, this.offset);
 }
 return keyLength;
}

代码示例来源:origin: cdapio/cdap

/**
 * Converts a byte array to an int value.
 * @param bytes byte array
 * @return the int value
 */
public static int toInt(byte[] bytes) {
 return toInt(bytes, 0, SIZEOF_INT);
}

代码示例来源:origin: cdapio/cdap

/**
 * Converts a byte array to an int value.
 * @param bytes byte array
 * @param offset offset into array
 * @return the int value
 */
public static int toInt(byte[] bytes, int offset) {
 return toInt(bytes, offset, SIZEOF_INT);
}

代码示例来源:origin: co.cask.cdap/cdap-data-fabric

/**
  * Decodes the instance id from the column name.
  */
 private int getInstanceId(byte[] columnName) {
  return Bytes.toInt(columnName, Longs.BYTES);
 }
}

代码示例来源:origin: co.cask.cdap/cdap-data-fabric

public int getKeyLength() {
 if (keyLength == 0) {
  keyLength = Bytes.toInt(this.bytes, this.offset);
 }
 return keyLength;
}

代码示例来源:origin: cdapio/cdap

/**
 * Determines the total length of the KeyValue stored in the specified
 * byte array and offset.  Includes all headers.
 * @param bytes byte array
 * @param offset offset to start of the KeyValue
 * @return length of entire KeyValue, in bytes
 */
private static int getLength(byte [] bytes, int offset) {
 return ROW_OFFSET +
   Bytes.toInt(bytes, offset) +
   Bytes.toInt(bytes, offset + Bytes.SIZEOF_INT);
}

代码示例来源:origin: co.cask.cdap/cdap-data-fabric

/**
 * @param stateValue value of the state column
 * @return state instance id
 */
public static int getStateInstanceId(byte[] stateValue) {
 return Bytes.toInt(stateValue, Longs.BYTES, Ints.BYTES);
}

代码示例来源:origin: co.cask.cdap/cdap-api-common

/**
 * Converts a byte array to an int value.
 * @param bytes byte array
 * @return the int value
 */
public static int toInt(byte[] bytes) {
 return toInt(bytes, 0, SIZEOF_INT);
}

代码示例来源:origin: cdapio/cdap

/**
 * @return Value length
 */
public int getValueLength() {
 return Bytes.toInt(this.bytes, this.offset + Bytes.SIZEOF_INT);
}

代码示例来源:origin: co.cask.cdap/cdap-api-common

/**
 * Presumes float encoded as IEEE 754 floating-point "single format".
 * @param bytes array to convert
 * @param offset offset into array
 * @return Float made from passed byte array.
 */
public static float toFloat(byte [] bytes, int offset) {
 return Float.intBitsToFloat(toInt(bytes, offset, SIZEOF_INT));
}

代码示例来源:origin: cdapio/cdap

/**
 * Presumes float encoded as IEEE 754 floating-point "single format".
 * @param bytes array to convert
 * @param offset offset into array
 * @return Float made from passed byte array.
 */
public static float toFloat(byte [] bytes, int offset) {
 return Float.intBitsToFloat(toInt(bytes, offset, SIZEOF_INT));
}

代码示例来源:origin: cdapio/cdap

@Override
@Nullable
public Integer getInt(byte[] column) {
 byte[] val = get(column);
 return val == null ? null : Bytes.toInt(columns.get(column));
}

代码示例来源:origin: cdapio/cdap

@Override
 public Integer decode(byte[] data) throws IOException {
  return Bytes.toInt(data);
 }
};

代码示例来源:origin: cdapio/cdap

public long getTimestamp(byte[] rowKey, byte[] column) {
 // timebase is encoded as int after the encoded agg group
 int timebase = Bytes.toInt(rowKey, VERSION.length + entityTable.getIdSize());
 // time leftover is encoded as 2 byte column name
 int leftover = Bytes.toShort(column) * resolution;
 return timebase + leftover;
}

代码示例来源:origin: co.cask.cdap/cdap-data-fabric

public long getTimestamp(byte[] rowKey, byte[] column) {
 // timebase is encoded as int after the encoded agg group
 int timebase = Bytes.toInt(rowKey, VERSION.length + entityTable.getIdSize());
 // time leftover is encoded as 2 byte column name
 int leftover = Bytes.toShort(column) * resolution;
 return timebase + leftover;
}

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

private void checkOutputData(DataSetManager<KeyValueTable> manager) {
 KeyValueTable count = manager.get();
 //read output and verify result
 byte[] val = count.read(Bytes.toBytes(TEST_STRING_1));
 Assert.assertTrue(val != null);
 Assert.assertEquals(Bytes.toInt(val), TEST_STRING_1.length());
 val = count.read(Bytes.toBytes(TEST_STRING_2));
 Assert.assertTrue(val != null);
 Assert.assertEquals(Bytes.toInt(val), TEST_STRING_2.length());
}

代码示例来源:origin: cdapio/cdap

@Override
 public void apply() {
  Assert.assertNull(outputKvTable.read("a"));
  Assert.assertNull(outputKvTable.read("the"));
  Assert.assertNull(outputKvTable.read("an"));
  Assert.assertEquals(2, Bytes.toInt(outputKvTable.read("test")));
  Assert.assertEquals(2, Bytes.toInt(outputKvTable.read("record")));
  Assert.assertEquals(1, Bytes.toInt(outputKvTable.read("table")));
  Assert.assertEquals(1, Bytes.toInt(outputKvTable.read("end")));
 }
}

相关文章