本文整理了Java中java.nio.ByteBuffer.getDouble()
方法的一些代码示例,展示了ByteBuffer.getDouble()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuffer.getDouble()
方法的具体详情如下:
包路径:java.nio.ByteBuffer
类名称:ByteBuffer
方法名:getDouble
[英]Returns the double at the current position and increases the position by 8.
The 8 bytes starting from the current position are composed into a double according to the current byte order and returned.
[中]返回当前位置的双精度,并将该位置增加8。
从当前位置开始的8个字节根据当前字节顺序组合成一个双精度字节并返回。
代码示例来源:origin: neo4j/neo4j
private static DoubleArray readDoubleArray( ByteBuffer bb, int offset )
{
final int len = bb.getInt( offset );
offset += Integer.BYTES;
final double[] array = new double[len];
for ( int i = 0; i < len; i++ )
{
array[i] = bb.getDouble( offset );
offset += Long.BYTES;
}
return doubleArray( array );
}
代码示例来源:origin: apache/incubator-druid
double lowerLimit = buf.getDouble();
double upperLimit = buf.getDouble();
int numBuckets = buf.getInt();
OutlierHandlingMode outlierHandlingMode = OutlierHandlingMode.values()[buf.get()];
long missingValueCount = buf.getLong();
double max = buf.getDouble();
double min = buf.getDouble();
int nonEmptyBuckets = buf.getInt();
long histogram[] = new long[numBuckets];
for (int i = 0; i < nonEmptyBuckets; i++) {
int bucket = buf.getInt();
long bucketCount = buf.getLong();
histogram[bucket] = bucketCount;
代码示例来源:origin: apache/incubator-druid
double lowerLimit = buf.getDouble();
double upperLimit = buf.getDouble();
int numBuckets = buf.getInt();
OutlierHandlingMode outlierHandlingMode = OutlierHandlingMode.values()[buf.get()];
long missingValueCount = buf.getLong();
double max = buf.getDouble();
double min = buf.getDouble();
代码示例来源:origin: debezium/debezium
/**
* Parses a 2D WKB Point into a {x,y} coordinate array.
* Returns null for any non-point or points with Z/M/etc modifiers.
* @param wkb OGC WKB geometry
* @return x,y coordinate array
*/
public static double[] parseWKBPoint(byte[] wkb) throws IllegalArgumentException {
if (wkb.length != WKB_POINT_SIZE) {
throw new IllegalArgumentException(String.format("Invalid WKB for Point (length %d < %d)", wkb.length, WKB_POINT_SIZE));
}
final ByteBuffer reader = ByteBuffer.wrap(wkb);
// Read the BOM
reader.order((reader.get() != 0) ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
int geomType = reader.getInt();
if (geomType != WKB_POINT) {
// we only parse 2D points
throw new IllegalArgumentException(String.format("Invalid WKB for 2D Point (wrong type %d)", geomType));
}
double x = reader.getDouble();
double y = reader.getDouble();
return new double[] {x, y};
}
代码示例来源:origin: neo4j/neo4j
@Override
public void readHeader( SpaceFillingCurveSettings.SettingsFromIndexHeader settings, ByteBuffer headerBytes )
{
try
{
settings.maxLevels = headerBytes.getInt();
settings.dimensions = headerBytes.getInt();
double[] min = new double[settings.dimensions];
double[] max = new double[settings.dimensions];
for ( int i = 0; i < settings.dimensions; i++ )
{
min[i] = headerBytes.getDouble();
max[i] = headerBytes.getDouble();
}
settings.extents = new Envelope( min, max );
}
catch ( BufferUnderflowException e )
{
settings.markAsFailed( "Failed to read settings from GBPTree header: " + e.getMessage() );
}
}
};
代码示例来源:origin: apache/incubator-pinot
@Override
public DoubleArrayList deserialize(ByteBuffer byteBuffer) {
int numValues = byteBuffer.getInt();
DoubleArrayList doubleArrayList = new DoubleArrayList(numValues);
for (int i = 0; i < numValues; i++) {
doubleArrayList.add(byteBuffer.getDouble());
}
return doubleArrayList;
}
};
代码示例来源:origin: apache/incubator-pinot
public static QuantileDigest fromByteBuffer(ByteBuffer byteBuffer) {
double maxError = byteBuffer.getDouble();
double alpha = byteBuffer.getDouble();
quantileDigest.min = byteBuffer.getLong();
quantileDigest.max = byteBuffer.getLong();
int numNodes = byteBuffer.getInt();
quantileDigest.totalNodeCount = numNodes;
if (numNodes == 0) {
int level = byteBuffer.get() & 0xFF;
long bits = byteBuffer.getLong();
double weightedCount = byteBuffer.getDouble();
代码示例来源:origin: neo4j/neo4j
private static PointValue readPoint( ByteBuffer chunk, int offset )
{
final int crsCode = chunk.getInt( offset );
offset += Integer.BYTES;
final CoordinateReferenceSystem crs = CoordinateReferenceSystem.get( crsCode );
final double[] coordinate = new double[crs.getDimension()];
for ( int i = 0; i < coordinate.length; i++ )
{
coordinate[i] = chunk.getDouble( offset );
offset += Double.BYTES;
}
return pointValue( crs, coordinate );
}
代码示例来源:origin: linkedin/cruise-control
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);
}
RawMetricType rawMetricType = RawMetricType.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(rawMetricType, time, brokerId, topic, value);
}
代码示例来源:origin: linkedin/cruise-control
static PartitionMetric 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);
}
RawMetricType rawMetricType = RawMetricType.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);
int partition = buffer.getInt();
double value = buffer.getDouble();
return new PartitionMetric(rawMetricType, time, brokerId, topic, partition, value);
}
代码示例来源:origin: linkedin/cruise-control
static BrokerMetric 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);
}
RawMetricType rawMetricType = RawMetricType.forId(buffer.get());
long time = buffer.getLong();
int brokerId = buffer.getInt();
double value = buffer.getDouble();
return new BrokerMetric(rawMetricType, time, brokerId, value);
}
代码示例来源:origin: tdunning/t-digest
@SuppressWarnings("WeakerAccess")
public static MergingDigest fromBytes(ByteBuffer buf) {
int encoding = buf.getInt();
if (encoding == Encoding.VERBOSE_ENCODING.code) {
double min = buf.getDouble();
double max = buf.getDouble();
double compression = buf.getDouble();
int n = buf.getInt();
MergingDigest r = new MergingDigest(compression);
r.setMinMax(min, max);
r.lastUsedCell = n;
for (int i = 0; i < n; i++) {
r.weight[i] = buf.getDouble();
r.mean[i] = buf.getDouble();
double min = buf.getDouble();
double max = buf.getDouble();
double compression = buf.getFloat();
int n = buf.getShort();
代码示例来源:origin: apache/incubator-pinot
switch (_dataSchema.getColumnDataType(colId)) {
case INT:
stringBuilder.append(_fixedSizeData.getInt());
break;
case LONG:
break;
case DOUBLE:
stringBuilder.append(_fixedSizeData.getDouble());
break;
case STRING:
stringBuilder.append(_fixedSizeData.getInt());
break;
stringBuilder.append(String.format("(%s:%s)", _fixedSizeData.getInt(), _fixedSizeData.getInt()));
break;
代码示例来源:origin: apache/usergrid
return bytes.slice().getInt();
return bytes.slice().getDouble();
代码示例来源:origin: apache/usergrid
return bytes.slice().getInt();
return bytes.slice().getDouble();
代码示例来源:origin: tdunning/t-digest
int encoding = buf.getInt();
if (encoding == VERBOSE_ENCODING) {
double min = buf.getDouble();
double max = buf.getDouble();
double compression = buf.getDouble();
AVLTreeDigest r = new AVLTreeDigest(compression);
r.setMinMax(min, max);
int n = buf.getInt();
double[] means = new double[n];
for (int i = 0; i < n; i++) {
means[i] = buf.getDouble();
r.add(means[i], buf.getInt());
double min = buf.getDouble();
double max = buf.getDouble();
double compression = buf.getDouble();
AVLTreeDigest r = new AVLTreeDigest(compression);
r.setMinMax(min, max);
代码示例来源:origin: addthis/stream-lib
int encoding = buf.getInt();
if (encoding == VERBOSE_ENCODING) {
double compression = buf.getDouble();
TDigest r = new TDigest(compression);
int n = buf.getInt();
double[] means = new double[n];
for (int i = 0; i < n; i++) {
means[i] = buf.getDouble();
r.add(means[i], buf.getInt());
double compression = buf.getDouble();
TDigest r = new TDigest(compression);
int n = buf.getInt();
代码示例来源:origin: linkedin/cruise-control
private static PartitionMetricSample readV0(ByteBuffer buffer) {
MetricDef metricDef = KafkaMetricDef.commonMetricDef();
int brokerId = buffer.getInt();
int partition = buffer.getInt(45);
String topic = new String(buffer.array(), 49, buffer.array().length - 49, UTF_8);
PartitionMetricSample sample = new PartitionMetricSample(brokerId, new TopicPartition(topic, partition));
sample.record(metricDef.metricInfo(CPU_USAGE.name()), buffer.getDouble());
sample.record(metricDef.metricInfo(DISK_USAGE.name()), buffer.getDouble());
sample.record(metricDef.metricInfo(LEADER_BYTES_IN.name()), buffer.getDouble());
sample.record(metricDef.metricInfo(LEADER_BYTES_OUT.name()), buffer.getDouble());
sample.close(buffer.getLong());
return sample;
}
代码示例来源:origin: apache/incubator-pinot
switch (metricFieldSpec.getDataType()) {
case INT:
values[i] = buffer.getInt();
break;
case LONG:
break;
case DOUBLE:
values[i] = buffer.getDouble();
break;
case STRING:
代码示例来源:origin: apache/ignite
val = buf.getInt();
val = buf.getDouble();
int dataLen = buf.getInt();
int nanos = buf.getInt();
内容来源于网络,如有侵权,请联系作者删除!