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

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

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

Bytes.toInt介绍

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

代码示例

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

/**
 * 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: apache/kylin

/**
 * 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: apache/kylin

/**
 * 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: apache/kylin

/**
 * Converts a byte array to a BigDecimal value
 *
 * @param bytes
 * @param offset
 * @param length
 * @return the char value
 */
public static BigDecimal toBigDecimal(byte[] bytes, int offset, final int length) {
  if (bytes == null || length < SIZEOF_INT + 1 || (offset + length > bytes.length)) {
    return null;
  }
  int scale = toInt(bytes, offset);
  byte[] tcBytes = new byte[length - SIZEOF_INT];
  System.arraycopy(bytes, offset + SIZEOF_INT, tcBytes, 0, length - SIZEOF_INT);
  return new BigDecimal(new BigInteger(tcBytes), scale);
}

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

public CubeStatsResult(Path path, int precision) throws IOException {
  Configuration hadoopConf = HadoopUtil.getCurrentConfiguration();
  Option seqInput = SequenceFile.Reader.file(path);
  try (Reader reader = new SequenceFile.Reader(hadoopConf, seqInput)) {
    LongWritable key = (LongWritable) ReflectionUtils.newInstance(reader.getKeyClass(), hadoopConf);
    BytesWritable value = (BytesWritable) ReflectionUtils.newInstance(reader.getValueClass(), hadoopConf);
    while (reader.next(key, value)) {
      if (key.get() == 0L) {
        percentage = Bytes.toInt(value.getBytes());
      } else if (key.get() == -1) {
        mapperOverlapRatio = Bytes.toDouble(value.getBytes());
      } else if (key.get() == -2) {
        mapperNumber = Bytes.toInt(value.getBytes());
      } else if (key.get() == -3) {
        sourceRecordCount = Bytes.toLong(value.getBytes());
      } else if (key.get() > 0) {
        HLLCounter hll = new HLLCounter(precision);
        ByteArray byteArray = new ByteArray(value.getBytes());
        hll.readRegisters(byteArray.asBuffer());
        counterMap.put(key.get(), hll);
      }
    }
  }
}

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

if (keyW.get() == 0L) {
  averageSamplingPercentage += Bytes.toInt(valueW.getBytes());
} else if (keyW.get() > 0) {
  HLLCounter hll = new HLLCounter(kylinConfig.getCubeStatsHLLPrecision());

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

if (key.get() == 0L) {
  averageSamplingPercentage += Bytes.toInt(value.getBytes());
} else if (key.get() > 0) {
  HLLCounter hll = new HLLCounter(kylinConfig.getCubeStatsHLLPrecision());

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

if (key.get() == 0L) {
  averageSamplingPercentage += Bytes.toInt(value.getBytes());
} else if (key.get() > 0) {
  HLLCounter hll = new HLLCounter(kylinConf.getCubeStatsHLLPrecision());

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

/**
 * 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: org.apache.kylin/kylin-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: org.apache.kylin/kylin-core-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: org.apache.kylin/kylin-common

/**
 * 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: org.apache.kylin/kylin-core-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: org.apache.kylin/kylin-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: org.apache.kylin/kylin-common

/**
 * Converts a byte array to a BigDecimal value
 *
 * @param bytes
 * @param offset
 * @param length
 * @return the char value
 */
public static BigDecimal toBigDecimal(byte[] bytes, int offset, final int length) {
  if (bytes == null || length < SIZEOF_INT + 1 || (offset + length > bytes.length)) {
    return null;
  }
  int scale = toInt(bytes, offset);
  byte[] tcBytes = new byte[length - SIZEOF_INT];
  System.arraycopy(bytes, offset + SIZEOF_INT, tcBytes, 0, length - SIZEOF_INT);
  return new BigDecimal(new BigInteger(tcBytes), scale);
}

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

/**
 * Converts a byte array to a BigDecimal value
 *
 * @param bytes
 * @param offset
 * @param length
 * @return the char value
 */
public static BigDecimal toBigDecimal(byte[] bytes, int offset, final int length) {
  if (bytes == null || length < SIZEOF_INT + 1 || (offset + length > bytes.length)) {
    return null;
  }
  int scale = toInt(bytes, offset);
  byte[] tcBytes = new byte[length - SIZEOF_INT];
  System.arraycopy(bytes, offset + SIZEOF_INT, tcBytes, 0, length - SIZEOF_INT);
  return new BigDecimal(new BigInteger(tcBytes), scale);
}

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

public CubeStatsResult(Path path, int precision) throws IOException {
  Configuration hadoopConf = HadoopUtil.getCurrentConfiguration();
  Option seqInput = SequenceFile.Reader.file(path);
  try (Reader reader = new SequenceFile.Reader(hadoopConf, seqInput)) {
    LongWritable key = (LongWritable) ReflectionUtils.newInstance(reader.getKeyClass(), hadoopConf);
    BytesWritable value = (BytesWritable) ReflectionUtils.newInstance(reader.getValueClass(), hadoopConf);
    while (reader.next(key, value)) {
      if (key.get() == 0L) {
        percentage = Bytes.toInt(value.getBytes());
      } else if (key.get() == -1) {
        mapperOverlapRatio = Bytes.toDouble(value.getBytes());
      } else if (key.get() == -2) {
        mapperNumber = Bytes.toInt(value.getBytes());
      } else if (key.get() == -3) {
        sourceRecordCount = Bytes.toLong(value.getBytes());
      } else if (key.get() > 0) {
        HLLCounter hll = new HLLCounter(precision);
        ByteArray byteArray = new ByteArray(value.getBytes());
        hll.readRegisters(byteArray.asBuffer());
        counterMap.put(key.get(), hll);
      }
    }
  }
}

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

if (keyW.get() == 0L) {
  averageSamplingPercentage += Bytes.toInt(valueW.getBytes());
} else if (keyW.get() > 0) {
  HLLCounter hll = new HLLCounter(kylinConfig.getCubeStatsHLLPrecision());

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

if (key.get() == 0L) {
  averageSamplingPercentage += Bytes.toInt(value.getBytes());
} else if (key.get() > 0) {
  HLLCounter hll = new HLLCounter(kylinConfig.getCubeStatsHLLPrecision());

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

if (key.get() == 0L) {
  averageSamplingPercentage += Bytes.toInt(value.getBytes());
} else if (key.get() > 0) {
  HLLCounter hll = new HLLCounter(kylinConf.getCubeStatsHLLPrecision());

相关文章