Example usage for java.io ObjectInput readDouble

List of usage examples for java.io ObjectInput readDouble

Introduction

In this page you can find the example usage for java.io ObjectInput readDouble.

Prototype

double readDouble() throws IOException;

Source Link

Document

Reads eight input bytes and returns a double value.

Usage

From source file:net.openhft.chronicle.wire.benchmarks.Data.java

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    setPrice(in.readDouble());
    setLongInt(in.readLong());/*from  w  w w.j a  v  a2 s. c o m*/
    setSmallInt(in.readInt());
    setFlag(in.readBoolean());
    setSide((Side) in.readObject());
    setText((String) in.readObject());
}

From source file:hivemall.fm.FFMPredictionModel.java

@Override
public void readExternal(@Nonnull final ObjectInput in) throws IOException, ClassNotFoundException {
    this._w0 = in.readDouble();
    final int factors = in.readInt();
    this._factors = factors;
    this._numFeatures = in.readInt();
    this._numFields = in.readInt();

    final int used = in.readInt();
    final int size = in.readInt();
    final int[] keys = new int[size];
    final long[] values = new long[size];
    final byte[] states = new byte[size];
    readStates(in, states);//from w w  w  . j  a va  2s  .com

    final int entrySize = Entry.sizeOf(factors);
    int numChunks = (entrySize * used) / HeapBuffer.DEFAULT_CHUNK_BYTES + 1;
    final HeapBuffer buf = new HeapBuffer(HeapBuffer.DEFAULT_CHUNK_SIZE, numChunks);
    final Entry e = new Entry(buf, factors);
    final float[] Vf = new float[factors];
    for (int i = 0; i < size; i++) {
        if (states[i] != IntOpenHashTable.FULL) {
            continue;
        }
        keys[i] = ZigZagLEB128Codec.readSignedInt(in);
        long ptr = buf.allocate(entrySize);
        e.setOffset(ptr);
        readEntry(in, factors, Vf, e);
        values[i] = ptr;
    }

    this._map = new Int2LongOpenHashTable(keys, values, states, used);
    this._buf = buf;
}

From source file:com.splicemachine.derby.impl.sql.execute.operations.SpliceBaseOperation.java

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    this.optimizerEstimatedCost = in.readDouble();
    this.optimizerEstimatedRowCount = in.readDouble();
    this.operationInformation = (OperationInformation) in.readObject();
    isTopResultSet = in.readBoolean();/*  w w w.j a  v a 2  s  .com*/
}

From source file:es.udc.gii.common.eaf.algorithm.population.Individual.java

/**
 * This method is called whenever an instance of this class has to be
 * de-serialized.<p>//w w w  .j a  v  a  2s. c  o m
 * 
 * It sets the values of Individual#getSerializeEvalResults and
 * Individual#getSerializeGenotype accordingly to the information received
 * so that subclasses can rely on them to know what kind of information is
 * to be read.<p>
 * 
 * Subclasses should override this method if they introduce new attibutes.
 * Remember to call <code>super.readExternal()</code> in order to
 * be sure that the state of the parent class is de-serialized and the values
 * of Individual#getSerializeEvalResults and Individual#getSerializeGenotype
 * contain the right information.
 * 
 * @param in - DataInput from which the bytes are read.
 * @throws java.io.IOException
 * @throws java.lang.ClassNotFoundException
 */
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {

    /* Retrieve the type of information comming in */
    boolean evals = in.readBoolean();
    boolean genotype = in.readBoolean();

    this.serializeEvalResults = evals;
    this.serializeGenotype = genotype;

    /* Read the evaluation results, if present */
    if (evals) {
        /* Read number of violated constraints */
        this.violatedConstraints = in.readInt();

        /* Read the fitness value */
        this.fitness = in.readDouble();

        /* Read the number of objectives (-1 means no objective values) */
        int nObjs = in.readInt();

        if (nObjs == -1) {
            this.objectives = null;
        } else {
            /* Read all objective values */
            this.objectives = new ArrayList<Double>(nObjs);
            for (int i = 0; i < nObjs; i++) {
                this.objectives.add(in.readDouble());
            }
        }

        /* Read the number of constraints (-1 means no constraint values) */
        int nConstr = in.readInt();

        if (nConstr == -1) {
            this.constraints = null;
        } else {
            /* Read all constraint values */
            this.constraints = new ArrayList<Double>(nConstr);
            for (int i = 0; i < nConstr; i++) {
                this.constraints.add(in.readDouble());
            }
        }
    }

    /* Read the genotype information, if present */
    if (genotype) {
        int nChroms = in.readInt();

        if (nChroms == -1) {
            this.chromosomes = null;
        } else {
            /* Read all the chromosomes */
            this.chromosomes = new DoubleArray[nChroms];
            for (int i = 0; i < nChroms; i++) {
                int nGenes = in.readInt();
                this.chromosomes[i] = new ResizableDoubleArray(nGenes);
                for (int j = 0; j < nGenes; j++) {
                    this.chromosomes[i].addElement(in.readDouble());
                }
            }
        }
    }
}

From source file:gnu.trove.map.custom_hash.TObjectDoubleCustomHashMap.java

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {

    // VERSION//  w ww .  ja v a 2s .co  m
    in.readByte();

    // SUPER
    super.readExternal(in);

    // STRATEGY
    strategy = (HashingStrategy<K>) in.readObject();

    // NO_ENTRY_VALUE
    no_entry_value = in.readDouble();

    // NUMBER OF ENTRIES
    int size = in.readInt();
    setUp(size);

    // ENTRIES
    while (size-- > 0) {
        //noinspection unchecked
        K key = (K) in.readObject();
        double val = in.readDouble();
        put(key, val);
    }
}

From source file:com.joey.software.regionSelectionToolkit.controlers.ImageProfileTool.java

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    setBlockUpdate(true);//from www.  j  a  v a  2s  .  c  o  m
    int version = in.readInt();

    dataPoints = in.readInt();
    crossColor = new Color(in.readInt());
    pointSize = in.readDouble();

    value = new float[in.readInt()];
    for (int i = 0; i < value.length; i++) {
        value[i] = in.readFloat();
    }

    selectionData = new float[in.readInt()];
    for (int i = 0; i < selectionData.length; i++) {
        selectionData[i] = in.readFloat();
    }

    useData = new boolean[in.readInt()];
    for (int i = 0; i < useData.length; i++) {
        useData[i] = in.readBoolean();
    }

    offset.setValue(in.readDouble());
    showOffset.setSelected(in.readBoolean());

    setBlockUpdate(false);
    // dataPoints = p.dataPoints;
    // crossColor = new Color(p.crossColor.getRGB());
    // pointSize = p.pointSize;
    // value = new float[p.value.length];
    // for (int i = 0; i < value.length; i++)
    // {
    // value[i] = p.value[i];
    // }
    //
    // selectionData = new float[p.selectionData.length];
    // for (int i = 0; i < selectionData.length; i++)
    // {
    // selectionData[i] = p.selectionData[i];
    // }
    //
    // useData = new boolean[p.useData.length];
    // for (int i = 0; i < useData.length; i++)
    // {
    // useData[i] = p.useData[i];
    // }
    //
    // offset.setValue(p.offset.getValue());
    // showOffset.setSelected(p.showOffset.isSelected());
}

From source file:org.knime.al.util.noveltydetection.kernel.KernelCalculator.java

/************ Externalizable methods *****************/
@Override// w  w  w  . j  a  v  a2 s.com
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
    try {
        // read kernelFunction
        m_kernelFunction = (KernelFunction) Class.forName(in.readUTF()).newInstance();
        m_kernelFunction.readExternal(in);

        // read trainingData
        // rows
        m_rowCount = in.readInt();
        // columns
        m_colCount = in.readInt();
        // data
        m_trainingData = new double[m_rowCount][m_colCount];
        for (int r = 0; r < m_rowCount; r++) {
            for (int c = 0; c < m_colCount; c++) {
                m_trainingData[r][c] = in.readDouble();
            }
        }

    } catch (InstantiationException | IllegalAccessException e) {
        throw new IOException(e);
    }

}

From source file:org.knime.al.util.noveltydetection.knfst.KNFST.java

@Override
public void readExternal(final ObjectInput arg0) throws IOException, ClassNotFoundException {

    try {//from  ww w . j ava2s.co m
        // read kernel
        m_kernel = (KernelCalculator) Class.forName(arg0.readUTF()).newInstance();
        m_kernel.readExternal(arg0);

        // read projection
        // rows
        final int rowsProj = arg0.readInt();
        // columns
        final int colsProj = arg0.readInt();
        // data
        final double[][] projData = new double[rowsProj][colsProj];
        for (int r = 0; r < rowsProj; r++) {
            for (int c = 0; c < colsProj; c++) {
                projData[r][c] = arg0.readDouble();
            }
        }
        // Matrix construction
        m_projection = MatrixUtils.createRealMatrix(projData);

        // read targetPoints
        // rows
        final int rowsTar = arg0.readInt();
        // columns
        final int colsTar = arg0.readInt();
        // data
        final double[][] tarData = new double[rowsTar][colsTar];
        for (int r = 0; r < rowsTar; r++) {
            for (int c = 0; c < colsTar; c++) {
                tarData[r][c] = arg0.readDouble();
            }
        }
        // Matrix construction
        m_targetPoints = MatrixUtils.createRealMatrix(tarData);

        // read betweenClassDistances
        final double[] betweenClassDistances = new double[arg0.readInt()];
        for (int i = 0; i < betweenClassDistances.length; i++) {
            betweenClassDistances[i] = arg0.readDouble();
        }
        m_betweenClassDistances = betweenClassDistances;

    } catch (InstantiationException | IllegalAccessException e) {
        throw new IOException(e);
    }
}