org.apache.hadoop.hbase.util.Bytes.toFloat()方法的使用及代码示例

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

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

Bytes.toFloat介绍

[英]Presumes float encoded as IEEE 754 floating-point "single format"
[中]假定浮点编码为IEEE 754浮点“单格式”

代码示例

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

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

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

/**
 * Read a {@code float} value from the buffer {@code buff}.
 */
public float decodeFloat(byte[] buff, int offset) {
 return Bytes.toFloat(buff, offset);
}

代码示例来源:origin: alibaba/canal

private static float decodeUnsignedFloat(byte[] b, int o) {
  checkForSufficientLength(b, o, Bytes.SIZEOF_FLOAT);
  float v = Bytes.toFloat(b, o);
  if (v < 0) {
    throw new RuntimeException();
  }
  return v;
}

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

public void testToFloat() throws Exception {
 float [] floats = {-1f, 123.123f, Float.MAX_VALUE};
 for (int i = 0; i < floats.length; i++) {
  byte [] b = Bytes.toBytes(floats[i]);
  assertEquals(floats[i], Bytes.toFloat(b), 0.0f);
  byte [] b2 = bytesWithOffset(b);
  assertEquals(floats[i], Bytes.toFloat(b2, 1), 0.0f);
 }
}

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

return Bytes.toLong(value);
case 6:
  return Bytes.toFloat(value);
case 7:
  return Bytes.toDouble(value);

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

@Override
public Float decode(PositionedByteRange src) {
 float val = Bytes.toFloat(src.getBytes(), src.getOffset() + src.getPosition());
 skip(src);
 return val;
}

代码示例来源:origin: alibaba/canal

res = Bytes.toBoolean(bytes);
} else if (Float.class == clazz || float.class == clazz) {
  res = Bytes.toFloat(bytes);
} else if (Double.class == clazz || double.class == clazz) {
  res = Bytes.toDouble(bytes);

代码示例来源:origin: alibaba/canal

res = Bytes.toFloat(bytes);

代码示例来源:origin: forcedotcom/phoenix

@Override
  public float decodeFloat(byte[] b, int o, ColumnModifier columnModifier) {
    if (columnModifier != null) {
      b = columnModifier.apply(b, o, new byte[Bytes.SIZEOF_FLOAT], 0, Bytes.SIZEOF_FLOAT);
    }
    float v = Bytes.toFloat(b, o);
    if (v < 0) {
      throw new IllegalDataException();
    }
    return v;
  }
}

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

@Override
 public float decodeFloat(byte[] b, int o, SortOrder sortOrder) {
  Preconditions.checkNotNull(sortOrder);
  checkForSufficientLength(b, o, Bytes.SIZEOF_FLOAT);
  if (sortOrder == SortOrder.DESC) {
   b = SortOrder.invert(b, o, new byte[Bytes.SIZEOF_FLOAT], 0, Bytes.SIZEOF_FLOAT);
   o = 0;
  }
  float v = Bytes.toFloat(b, o);
  if (v < 0) {
   throw newIllegalDataException();
  }
  return v;
 }
}

代码示例来源:origin: Impetus/Kundera

return Bytes.toFloat(b);

代码示例来源:origin: Impetus/Kundera

return Bytes.toFloat(b);

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

/**
 * Read a {@code float} value from the buffer {@code buff}.
 */
public float decodeFloat(byte[] buff, int offset) {
 return Bytes.toFloat(buff, offset);
}

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

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

代码示例来源:origin: com.aliyun.hbase/alihbase-common

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

代码示例来源:origin: co.cask.hbase/hbase

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

代码示例来源:origin: org.apache.pig/pig

@Override
public Float bytesToFloat(byte[] b) throws IOException {
  if (Bytes.SIZEOF_FLOAT > b.length){
    return Bytes.toFloat(Bytes.padHead(b, Bytes.SIZEOF_FLOAT - b.length));
  } else {
    return Bytes.toFloat(Bytes.head(b, Bytes.SIZEOF_FLOAT));
  }
}

代码示例来源:origin: org.apache.camel/camel-hbase

@Converter
  public static Float bytesToFloat(byte[] bytes) {
    return Bytes.toFloat(bytes);
  }
}

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

public void testToFloat() throws Exception {
 float [] floats = {-1f, 123.123f, Float.MAX_VALUE};
 for (int i = 0; i < floats.length; i++) {
  byte [] b = Bytes.toBytes(floats[i]);
  assertEquals(floats[i], Bytes.toFloat(b), 0.0f);
  byte [] b2 = bytesWithOffset(b);
  assertEquals(floats[i], Bytes.toFloat(b2, 1), 0.0f);
 }
}

代码示例来源:origin: com.aliyun.hbase/alihbase-common

public void testToFloat() throws Exception {
 float [] floats = {-1f, 123.123f, Float.MAX_VALUE};
 for (int i = 0; i < floats.length; i++) {
  byte [] b = Bytes.toBytes(floats[i]);
  assertEquals(floats[i], Bytes.toFloat(b), 0.0f);
  byte [] b2 = bytesWithOffset(b);
  assertEquals(floats[i], Bytes.toFloat(b2, 1), 0.0f);
 }
}

相关文章

微信公众号

最新文章

更多