下面列出了java.io.DataInput#readDouble ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void readUltraSparseBlock(DataInput in)
throws IOException
{
//allocate ultra-sparse block in CSR to avoid unnecessary size overhead
//and to allow efficient reset without repeated sparse row allocation
//adjust size and ensure reuse block is in CSR format
allocateAndResetSparseBlock(false, SparseBlock.Type.CSR);
if( clen > 1 ) { //ULTRA-SPARSE BLOCK
//block: read ijv-triples (ordered by row and column) via custom
//init to avoid repeated updates of row pointers per append
SparseBlockCSR sblockCSR = (SparseBlockCSR) sparseBlock;
sblockCSR.initUltraSparse((int)nonZeros, in);
}
else { //ULTRA-SPARSE COL
//col: read iv-pairs (should never happen since always dense)
for(long i=0; i<nonZeros; i++) {
int r = in.readInt();
double val = in.readDouble();
sparseBlock.allocate(r, 1, 1);
sparseBlock.append(r, 0, val);
}
}
}
/**
* Initializes the CSR sparse block from an ordered input
* stream of sparse rows (rownnz, jv-pairs*).
*
* @param rlen number of rows
* @param nnz number of non-zeros to read
* @param in data input stream of sparse rows, ordered by i
* @throws IOException if deserialization error occurs
*/
public void initSparse(int rlen, int nnz, DataInput in)
throws IOException
{
//allocate space if necessary
if( _values.length < nnz )
resize(newCapacity(nnz));
//read sparse rows, append and update pointers
_ptr[0] = 0;
for( int r=0, pos=0; r<rlen; r++ ) {
int lnnz = in.readInt();
for( int j=0; j<lnnz; j++, pos++ ) {
_indexes[pos] = in.readInt();
_values[pos] = in.readDouble();
}
_ptr[r+1] = pos;
}
//update meta data
_size = nnz;
}
@Override
public TripLine deserialize(DataInput in, int available) throws IOException {
long id = in.readLong();
int geomSize = in.readInt();
Coordinate coords[] = new Coordinate[geomSize];
for(int i = 0; i < geomSize; i++) {
coords[i] = new Coordinate(in.readDouble(), in.readDouble());
}
long segmentId = in.readLong();
int tripLineIndex = in.readInt();
double dist = in.readDouble();
TripLine item = new TripLine(id, coords, segmentId, tripLineIndex, dist);
return item;
}
@Override
public void readFields(DataInput in) throws IOException {
_numRows = in.readInt();
int numCols = in.readInt();
int numVals = in.readInt();
// read col indices
_colIndexes = new int[numCols];
for(int i = 0; i < numCols; i++)
_colIndexes[i] = in.readInt();
// read distinct values
double[] values = new double[numVals * numCols];
for(int i = 0; i < numVals * numCols; i++)
values[i] = in.readDouble();
_dict = new Dictionary(values);
// read data
_data = new char[_numRows];
for(int i = 0; i < _numRows; i++)
_data[i] = in.readChar();
}
/**
* Reads a primitive <code>double</code> from a
* <code>DataInput</code>.
*
* @throws IOException
* A problem occurs while reading from <code>in</code>
* @see DataInput#readDouble
* @since 5.1
*/
public static double readPrimitiveDouble(DataInput in) throws IOException {
InternalDataSerializer.checkIn(in);
double value = in.readDouble();
if (DEBUG) {
InternalDataSerializer.logger.info( LocalizedStrings.DEBUG, "Read Double " + value);
}
return value;
}
public void fromDelta(DataInput in)
throws IOException {
if (getBeforeUpdate) {
this.netWorth = in.readDouble();
} else {
this.netWorth += in.readDouble();
}
if (encodeTimestamp) {
this.timestamp = in.readLong();
}
if (fineEnabled) {
Log.getLogWriter().info("INVOKED: fromDelta on key " + this.acctId);
}
}
@Override
public void readFrom(DataInput in)
throws IOException {
for (int i=0; i<coefficients.size(); i++) {
coefficients.set(i, in.readDouble());
}
maxe = in.readDouble();
}
@Override
public void readFields(DataInput dataInput) throws IOException {
this.n = dataInput.readInt();
this.coord = new double[n];
for (int i = 0; i < n; i++)
this.coord[i] = dataInput.readDouble();
}
@Override
public void readFields(DataInput in) throws IOException {
super.readFields(in);
id = WritableUtils.readVInt(in);
maps = WritableUtils.readVInt(in);
inputRecords = WritableUtils.readVLong(in);
outputBytes = WritableUtils.readVLong(in);
outputRecords = WritableUtils.readVLong(in);
maxMemory = WritableUtils.readVLong(in);
reduces = WritableUtils.readVInt(in);
if (reduceBytes.length < reduces) {
reduceBytes = new double[reduces];
reduceRecords = new double[reduces];
}
for (int i = 0; i < reduces; ++i) {
reduceBytes[i] = in.readDouble();
reduceRecords[i] = in.readDouble();
}
nSpec = WritableUtils.readVInt(in);
if (reduceOutputBytes.length < nSpec) {
reduceOutputBytes = new long[nSpec];
reduceOutputRecords = new long[nSpec];
}
for (int i = 0; i < nSpec; ++i) {
reduceOutputBytes[i] = WritableUtils.readVLong(in);
reduceOutputRecords[i] = WritableUtils.readVLong(in);
}
mapMetrics = new ResourceUsageMetrics();
mapMetrics.readFields(in);
int numReduceMetrics = WritableUtils.readVInt(in);
reduceMetrics = new ResourceUsageMetrics[numReduceMetrics];
for (int i = 0; i < numReduceMetrics; ++i) {
reduceMetrics[i] = new ResourceUsageMetrics();
reduceMetrics[i].readFields(in);
}
}
public void fromDelta(DataInput in)
throws IOException {
if (getBeforeUpdate) {
this.netWorth = in.readDouble();
} else {
this.netWorth += in.readDouble();
}
if (encodeTimestamp) {
this.timestamp = in.readLong();
}
if (fineEnabled) {
Log.getLogWriter().info("INVOKED: fromDelta on key " + this.acctId);
}
}
public void fromData(DataInput in)
throws IOException, ClassNotFoundException {
this.acctId = in.readInt();
this.customerName = DataSerializer.readString(in);
this.netWorth = in.readDouble();
this.assets = DataSerializer.readHashMap(in);
this.timestamp = in.readLong();
if (fineEnabled) {
Log.getLogWriter().fine("INVOKED: fromData on key " + this.acctId);
}
}
@Override
public void read(DataInput in) throws IOException {
this.value = in.readDouble();
}
public void readFields(DataInput in) throws IOException {
value = in.readDouble();
}
public void readFields(DataInput in) throws IOException {
this.bytes = new byte[in.readInt()];
in.readFully(this.bytes);
weight = in.readDouble();
}
public StatsMetadata deserialize(Descriptor.Version version, DataInput in) throws IOException
{
EstimatedHistogram rowSizes = EstimatedHistogram.serializer.deserialize(in);
EstimatedHistogram columnCounts = EstimatedHistogram.serializer.deserialize(in);
ReplayPosition replayPosition = ReplayPosition.serializer.deserialize(in);
long minTimestamp = in.readLong();
long maxTimestamp = in.readLong();
int maxLocalDeletionTime = in.readInt();
double compressionRatio = in.readDouble();
StreamingHistogram tombstoneHistogram = StreamingHistogram.serializer.deserialize(in);
int sstableLevel = in.readInt();
long repairedAt = 0;
if (version.hasRepairedAt)
repairedAt = in.readLong();
int colCount = in.readInt();
List<ByteBuffer> minColumnNames = new ArrayList<>(colCount);
for (int i = 0; i < colCount; i++)
minColumnNames.add(ByteBufferUtil.readWithShortLength(in));
colCount = in.readInt();
List<ByteBuffer> maxColumnNames = new ArrayList<>(colCount);
for (int i = 0; i < colCount; i++)
maxColumnNames.add(ByteBufferUtil.readWithShortLength(in));
boolean hasLegacyCounterShards = true;
if (version.tracksLegacyCounterShards)
hasLegacyCounterShards = in.readBoolean();
return new StatsMetadata(rowSizes,
columnCounts,
replayPosition,
minTimestamp,
maxTimestamp,
maxLocalDeletionTime,
compressionRatio,
tombstoneHistogram,
sstableLevel,
minColumnNames,
maxColumnNames,
hasLegacyCounterShards,
repairedAt);
}
@Override
public void readFields(DataInput in) throws IOException {
value=in.readDouble();
weight=in.readDouble();
}
public void read(DataInput in) throws IOException
{
_sum=in.readDouble();
_correction=in.readDouble();
}
public void readFields(DataInput in) throws IOException
{
value=in.readDouble();
sign=in.readBoolean();
}
public static Double readDouble(DataInput input) throws IOException
{
return input.readDouble();
}
/**
* Initialize instance from file data.
*
* @param file Input stream
* @throws IOException
*/
ConstantDouble(final DataInput file) throws IOException {
super(Const.CONSTANT_Double);
this.bytes = file.readDouble();
}