本文整理汇总了Java中java.nio.ByteBuffer.getDouble方法的典型用法代码示例。如果您正苦于以下问题:Java ByteBuffer.getDouble方法的具体用法?Java ByteBuffer.getDouble怎么用?Java ByteBuffer.getDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.getDouble方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readIn
import java.nio.ByteBuffer; //导入方法依赖的package包/类
public static ImageDesc readIn(ByteBuffer buf)
{
FastQueue<BrightFeature> des = UtilFeature.createQueue(detDesc,0);
int dts = buf.getInt();
for(int i=0;i<dts;i++)
{
int vs = buf.getInt();
BrightFeature f = new BrightFeature(vs);
double[] vls = new double[vs];
for(int j=0;j<vs;j++)
{
vls[j]=buf.getDouble();
}
f.set(vls);
des.add(f);
}
AverageHash h = AverageHash.readIn(buf);
return new ImageDesc(des,h);
}
示例2: getDoubleFromByteBuffer
import java.nio.ByteBuffer; //导入方法依赖的package包/类
public static double getDoubleFromByteBuffer(ByteBuffer byteBuffer)
{
byte flag = byteBuffer.get();
double ret = 0;
if (flag == FLOAT_VALUE)
ret = byteBuffer.getFloat();
else
ret = byteBuffer.getDouble();
return (ret);
}
示例3: alignedReadSnippet
import java.nio.ByteBuffer; //导入方法依赖的package包/类
Ret alignedReadSnippet(byte[] arg) {
ByteBuffer buffer = ByteBuffer.wrap(arg).order(byteOrder);
Ret ret = new Ret();
ret.byteValue = buffer.get();
ret.byteValue += buffer.get();
ret.shortValue = buffer.getShort();
ret.intValue = buffer.getInt();
ret.longValue = buffer.getLong();
ret.doubleValue = buffer.getDouble();
ret.floatValue = buffer.getFloat();
return ret;
}
示例4: unalignedReadSnippet
import java.nio.ByteBuffer; //导入方法依赖的package包/类
Ret unalignedReadSnippet(byte[] arg) {
ByteBuffer buffer = makeDirect(arg, byteOrder);
Ret ret = new Ret();
ret.byteValue = buffer.get();
ret.shortValue = buffer.getShort();
ret.intValue = buffer.getInt();
ret.longValue = buffer.getLong();
ret.doubleValue = buffer.getDouble();
ret.floatValue = buffer.getFloat();
return ret;
}
示例5: decodeInternal
import java.nio.ByteBuffer; //导入方法依赖的package包/类
@Override
Double decodeInternal(ByteBuffer input) {
if (input == null || input.remaining() == 0) return 0.0;
if (input.remaining() != 8)
throw new InvalidTypeException(
"Invalid 64-bits double value, expecting 8 bytes but got " + input.remaining());
return input.getDouble(input.position());
}
示例6: readFrom
import java.nio.ByteBuffer; //导入方法依赖的package包/类
/**
* Creates a Stats instance from the byte representation read from the given {@link ByteBuffer}.
*
* <p><b>Note:</b> No guarantees are made regarding stability of the representation between
* versions.
*
* @param buffer A {@link ByteBuffer} with at least BYTES {@link ByteBuffer#remaining}, ordered as
* {@link ByteOrder#LITTLE_ENDIAN}, from which a BYTES-long byte representation of this
* instance is read. In the process increases the position of {@link ByteBuffer} by BYTES.
*/
static Stats readFrom(ByteBuffer buffer) {
checkNotNull(buffer);
checkArgument(
buffer.remaining() >= BYTES,
"Expected at least Stats.BYTES = %s remaining , got %s",
BYTES,
buffer.remaining());
return new Stats(
buffer.getLong(),
buffer.getDouble(),
buffer.getDouble(),
buffer.getDouble(),
buffer.getDouble());
}
示例7: fromByteArray
import java.nio.ByteBuffer; //导入方法依赖的package包/类
/**
* Creates a {@link PairedStats} instance from the given byte representation which was obtained by
* {@link #toByteArray}.
*
* <p><b>Note:</b> No guarantees are made regarding stability of the representation between
* versions.
*/
public static PairedStats fromByteArray(byte[] byteArray) {
checkNotNull(byteArray);
checkArgument(
byteArray.length == BYTES,
"Expected PairedStats.BYTES = %s, got %s",
BYTES,
byteArray.length);
ByteBuffer buffer = ByteBuffer.wrap(byteArray).order(ByteOrder.LITTLE_ENDIAN);
Stats xStats = Stats.readFrom(buffer);
Stats yStats = Stats.readFrom(buffer);
double sumOfProductsOfDeltas = buffer.getDouble();
return new PairedStats(xStats, yStats, sumOfProductsOfDeltas);
}
示例8: readDouble
import java.nio.ByteBuffer; //导入方法依赖的package包/类
/**
* Reads an 8-byte little endian double.
*/
public double readDouble() throws IOException {
byte[] bytes = new byte[8];
this.reader.readFully(bytes);
ByteBuffer bb = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN);
return bb.getDouble();
}
示例9: byteArray2MatrixArray
import java.nio.ByteBuffer; //导入方法依赖的package包/类
@Nullable
private static Matrix[] byteArray2MatrixArray(byte... array) {
if (array == null) {
return null;
}
Matrix[] res = null;
try {
final ByteBuffer buffer = ByteBuffer.wrap(array);
final int len = buffer.getInt();
res = new Matrix[len];
for (int i = 0; i < len; ++i) {
final int row = buffer.getInt();
final int col = buffer.getInt();
final double[] doubles = new double[row * col];
for (int j = 0, jLen = doubles.length; j < jLen; ++j) {
doubles[j] = buffer.getDouble();
}
res[i] = Matrix.array(doubles, row);
}
} catch (Exception e) {
e.printStackTrace();
res = null;
}
return res;
}
示例10: fromBuffer
import java.nio.ByteBuffer; //导入方法依赖的package包/类
static TopicMetric fromBuffer(ByteBuffer buffer) throws UnknownVersionException {
byte version = buffer.get();
if (version > METRIC_VERSION) {
throw new UnknownVersionException("Cannot deserialize the topic metrics for version " + version + ". "
+ "Current version is " + METRIC_VERSION);
}
MetricType metricType = MetricType.forId(buffer.get());
long time = buffer.getLong();
int brokerId = buffer.getInt();
int topicLength = buffer.getInt();
String topic = new String(buffer.array(), buffer.arrayOffset() + buffer.position(), topicLength, StandardCharsets.UTF_8);
buffer.position(buffer.position() + topicLength);
double value = buffer.getDouble();
return new TopicMetric(metricType, time, brokerId, topic, value);
}
示例11: loadInMemoryStorage
import java.nio.ByteBuffer; //导入方法依赖的package包/类
@Override
public void loadInMemoryStorage( final ColumnBinary columnBinary , final IMemoryAllocator allocator ) throws IOException{
ByteBuffer wrapBuffer = ByteBuffer.wrap( columnBinary.binary , columnBinary.binaryStart , columnBinary.binaryLength );
switch( columnBinary.columnType ){
case BOOLEAN:
boolean booleanObj = wrapBuffer.get() == 1;
for( int i = 0 ; i < columnBinary.rowCount ; i++ ){
allocator.setBoolean( i , booleanObj );
}
break;
case BYTE:
byte byteObj = wrapBuffer.get();
for( int i = 0 ; i < columnBinary.rowCount ; i++ ){
allocator.setByte( i , byteObj );
}
break;
case SHORT:
short shortObj = wrapBuffer.getShort();
for( int i = 0 ; i < columnBinary.rowCount ; i++ ){
allocator.setShort( i , shortObj );
}
break;
case INTEGER:
int intObj = wrapBuffer.getInt();
for( int i = 0 ; i < columnBinary.rowCount ; i++ ){
allocator.setInteger( i , intObj );
}
break;
case LONG:
long longObj = wrapBuffer.getLong();
for( int i = 0 ; i < columnBinary.rowCount ; i++ ){
allocator.setLong( i , longObj );
}
break;
case FLOAT:
float floatObj = wrapBuffer.getFloat();
for( int i = 0 ; i < columnBinary.rowCount ; i++ ){
allocator.setFloat( i , floatObj );
}
break;
case DOUBLE:
double doubleObj = wrapBuffer.getDouble();
for( int i = 0 ; i < columnBinary.rowCount ; i++ ){
allocator.setDouble( i , doubleObj );
}
break;
case STRING:
int stringLength = wrapBuffer.getInt();
byte[] stringBytes = new byte[stringLength];
wrapBuffer.get( stringBytes );
String utf8 = new String( stringBytes , "UTF-8" );
for( int i = 0 ; i < columnBinary.rowCount ; i++ ){
allocator.setString( i , utf8 );
}
break;
case BYTES:
int byteLength = wrapBuffer.getInt();
byte[] byteBytes = new byte[byteLength];
wrapBuffer.get( byteBytes );
for( int i = 0 ; i < columnBinary.rowCount ; i++ ){
allocator.setBytes( i , byteBytes );
}
break;
default:
throw new IOException( "Unknown primitive type." );
}
allocator.setValueCount( columnBinary.rowCount );
}
示例12: toDouble
import java.nio.ByteBuffer; //导入方法依赖的package包/类
public static double toDouble(ByteBuffer bytes) {
return bytes.getDouble(bytes.position());
}
示例13: toDouble
import java.nio.ByteBuffer; //导入方法依赖的package包/类
public static double toDouble(ByteBuffer bytes)
{
return bytes.getDouble(bytes.position());
}
示例14: decodeData
import java.nio.ByteBuffer; //导入方法依赖的package包/类
@Override
public void decodeData(ByteBuffer buffer, int length) {
data = buffer.getDouble();
addDataLength(length);
}
示例15: readFeature
import java.nio.ByteBuffer; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
protected Object readFeature(ByteBuffer buffer) {
int typeValue = buffer.getInt();
ReadWriteType type = ReadWriteType.getType(typeValue);
Object value = null;
switch (type) {
case String:
int length = buffer.getInt();
if (length != -1) {
value = BinUtils.readString(buffer, length);
}
break;
case Integer:
value = buffer.getInt();
break;
case Double:
value = buffer.getDouble();
break;
case Float:
value = buffer.getFloat();
break;
case Long:
value = buffer.getLong();
break;
case Boolean:
value = (buffer.get() == 1);
break;
case List:
List list = new ArrayList<>();
int size = buffer.getInt();
for (int i = 0; i < size; i++) {
Object valueInList = readFeature(buffer);
list.add(valueInList);
}
value = list;
break;
case ByteArray:
int byteLength = buffer.getInt();
if (byteLength != 0) {
byte[] valueByte = new byte[byteLength];
buffer.get(valueByte);
value = valueByte;
}
break;
case ReadWriteVirtualObject:
ReadWriteVirtualObject readWriteVirtualObject = createReadWriteVirtualObject();
readWriteVirtualObject.read(buffer);
value = readWriteVirtualObject;
break;
default:
break;
}
return value;
}