org.apache.kylin.common.util.Bytes.putLongUnsafe()方法的使用及代码示例

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

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

Bytes.putLongUnsafe介绍

[英]Put a long value out to the specified byte array position (Unsafe).
[中]将长值输出到指定的字节数组位置(不安全)。

代码示例

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

/**
 * Put a long value out to the specified byte array position.
 *
 * @param bytes  the byte array
 * @param offset position in the array
 * @param val    long to write out
 * @return incremented offset
 * @throws IllegalArgumentException if the byte array given doesn't have
 *                                  enough room at the offset specified.
 */
public static int putLong(byte[] bytes, int offset, long val) {
  if (bytes.length - offset < SIZEOF_LONG) {
    throw new IllegalArgumentException(
        "Not enough room to put a long at" + " offset " + offset + " in a " + bytes.length + " byte array");
  }
  if (org.apache.kylin.common.util.Bytes.LexicographicalComparerHolder.UnsafeComparer.isAvailable()) {
    return putLongUnsafe(bytes, offset, val);
  } else {
    for (int i = offset + 7; i > offset; i--) {
      bytes[i] = (byte) val;
      val >>>= 8;
    }
    bytes[offset] = (byte) val;
    return offset + SIZEOF_LONG;
  }
}

代码示例来源:origin: org.apache.kylin/kylin-core-common

/**
 * Put a long value out to the specified byte array position.
 *
 * @param bytes  the byte array
 * @param offset position in the array
 * @param val    long to write out
 * @return incremented offset
 * @throws IllegalArgumentException if the byte array given doesn't have
 *                                  enough room at the offset specified.
 */
public static int putLong(byte[] bytes, int offset, long val) {
  if (bytes.length - offset < SIZEOF_LONG) {
    throw new IllegalArgumentException(
        "Not enough room to put a long at" + " offset " + offset + " in a " + bytes.length + " byte array");
  }
  if (org.apache.kylin.common.util.Bytes.LexicographicalComparerHolder.UnsafeComparer.isAvailable()) {
    return putLongUnsafe(bytes, offset, val);
  } else {
    for (int i = offset + 7; i > offset; i--) {
      bytes[i] = (byte) val;
      val >>>= 8;
    }
    bytes[offset] = (byte) val;
    return offset + SIZEOF_LONG;
  }
}

代码示例来源:origin: org.apache.kylin/kylin-common

/**
 * Put a long value out to the specified byte array position.
 *
 * @param bytes  the byte array
 * @param offset position in the array
 * @param val    long to write out
 * @return incremented offset
 * @throws IllegalArgumentException if the byte array given doesn't have
 *                                  enough room at the offset specified.
 */
public static int putLong(byte[] bytes, int offset, long val) {
  if (bytes.length - offset < SIZEOF_LONG) {
    throw new IllegalArgumentException("Not enough room to put a long at" + " offset " + offset + " in a " + bytes.length + " byte array");
  }
  if (org.apache.kylin.common.util.Bytes.LexicographicalComparerHolder.UnsafeComparer.isAvailable()) {
    return putLongUnsafe(bytes, offset, val);
  } else {
    for (int i = offset + 7; i > offset; i--) {
      bytes[i] = (byte) val;
      val >>>= 8;
    }
    bytes[offset] = (byte) val;
    return offset + SIZEOF_LONG;
  }
}

相关文章