Java Code Examples for java.io.ObjectInputStream#readFloat()

The following examples show how to use java.io.ObjectInputStream#readFloat() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void readObject(ObjectInputStream in) throws IOException,
		ClassNotFoundException {
	this.mapType = (MapType) in.readObject();
	this.num = 0;
	this.locked = false;

	int n = in.readInt();
	allocate(getCapacity(n, true));

	for (int i = 0; i < n; i++) {
		T key = keyFunc.intern((T) in.readObject()); // CHECKED
		float value = in.readFloat();
		if (mapType == MapType.SORTED_LIST) {
			// Assume keys and values serialized in sorted order
			keys[num] = key;
			values[num] = value;
			num++;
		} else if (mapType == MapType.HASH_TABLE) {
			put(key, value);
		}
	}
}
 
Example 2
/**
 * Run benchmark for given number of batches, with given number of cycles
 * for each batch.
 */
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
            StreamBuffer sbuf, int nbatches, int ncycles)
    throws Exception
{
    for (int i = 0; i < nbatches; i++) {
        sbuf.reset();
        for (int j = 0; j < ncycles; j++) {
            oout.writeFloat((float) 0.0);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readFloat();
        }
    }
}
 
Example 3
Source Project: jdk8u_jdk   File: Floats.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Run benchmark for given number of batches, with given number of cycles
 * for each batch.
 */
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
            StreamBuffer sbuf, int nbatches, int ncycles)
    throws Exception
{
    for (int i = 0; i < nbatches; i++) {
        sbuf.reset();
        for (int j = 0; j < ncycles; j++) {
            oout.writeFloat((float) 0.0);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readFloat();
        }
    }
}
 
Example 4
/**
 * Run benchmark for given number of batches, with given number of cycles
 * for each batch.
 */
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
            StreamBuffer sbuf, int nbatches, int ncycles)
    throws Exception
{
    for (int i = 0; i < nbatches; i++) {
        sbuf.reset();
        for (int j = 0; j < ncycles; j++) {
            oout.writeFloat((float) 0.0);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readFloat();
        }
    }
}
 
Example 5
private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
{
    z = in.readBoolean();
    b = in.readByte();
    c = in.readChar();
    s = in.readShort();
    i = in.readInt();
    f = in.readFloat();
    j = in.readLong();
    d = in.readDouble();
    str = (String) in.readObject();
    parent = in.readObject();
    left = in.readObject();
    right = in.readObject();
}
 
Example 6
/**
 * @see #writeMatrix(FastByIDMap, ObjectOutputStream)
 */
private static FastByIDMap<float[]> readMatrix(ObjectInputStream in) throws IOException {
  int count = in.readInt();
  FastByIDMap<float[]> matrix = new FastByIDMap<float[]>(count);
  for (int i = 0; i < count; i++) {
    long id = in.readLong();
    float[] features = new float[in.readInt()];
    for (int j = 0; j < features.length; j++) {
      float f = in.readFloat();
      Preconditions.checkState(LangUtils.isFinite(f));
      features[j] = f;
    }
    matrix.put(id, features);
  }
  return matrix;
}
 
Example 7
private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
{
    z = in.readBoolean();
    b = in.readByte();
    c = in.readChar();
    s = in.readShort();
    i = in.readInt();
    f = in.readFloat();
    j = in.readLong();
    d = in.readDouble();
    str = (String) in.readObject();
    parent = in.readObject();
    left = in.readObject();
    right = in.readObject();
}
 
Example 8
private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
{
    z = in.readBoolean();
    b = in.readByte();
    c = in.readChar();
    s = in.readShort();
    i = in.readInt();
    f = in.readFloat();
    j = in.readLong();
    d = in.readDouble();
    str = (String) in.readObject();
    parent = in.readObject();
    left = in.readObject();
    right = in.readObject();
}
 
Example 9
/**
 * Run benchmark for given number of batches, with given number of cycles
 * for each batch.
 */
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
            StreamBuffer sbuf, int nbatches, int ncycles)
    throws Exception
{
    for (int i = 0; i < nbatches; i++) {
        sbuf.reset();
        for (int j = 0; j < ncycles; j++) {
            oout.writeFloat((float) 0.0);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readFloat();
        }
    }
}
 
Example 10
Source Project: gemfirexd-oss   File: TFloatLongHashMap.java    License: Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream stream)
    throws IOException, ClassNotFoundException {
    stream.defaultReadObject();

    int size = stream.readInt();
    setUp(size);
    while (size-- > 0) {
        float key = stream.readFloat();
        long val = stream.readLong();
        put(key, val);
    }
}
 
Example 11
/**
 * Reads the object from the object input stream.
 *
 * @param stream the object input stream from where to read the serialized data.
 * @return the generated object.
 * @throws IOException            if reading the stream failed.
 * @throws ClassNotFoundException if serialized object class cannot be found.
 */
public Object readObject( final ObjectInputStream stream )
  throws IOException, ClassNotFoundException {
  final float width = stream.readFloat();
  final int cap = stream.readInt();
  final int join = stream.readInt();
  final float miterLimit = stream.readFloat();
  final float[] dash = (float[]) stream.readObject();
  final float dashPhase = stream.readFloat();
  //noinspection MagicConstant
  return new BasicStroke( width, cap, join, miterLimit, dash, dashPhase );
}
 
Example 12
Source Project: gemfirexd-oss   File: TFloatIntHashMap.java    License: Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream stream)
    throws IOException, ClassNotFoundException {
    stream.defaultReadObject();

    int size = stream.readInt();
    setUp(size);
    while (size-- > 0) {
        float key = stream.readFloat();
        int val = stream.readInt();
        put(key, val);
    }
}
 
Example 13
Source Project: gemfirexd-oss   File: TIntFloatHashMap.java    License: Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream stream)
    throws IOException, ClassNotFoundException {
    stream.defaultReadObject();

    int size = stream.readInt();
    setUp(size);
    while (size-- > 0) {
        int key = stream.readInt();
        float val = stream.readFloat();
        put(key, val);
    }
}
 
Example 14
private void readObject(ObjectInputStream stream)
    throws IOException, ClassNotFoundException {
    stream.defaultReadObject();

    int size = stream.readInt();
    setUp(size);
    while (size-- > 0) {
        float key = stream.readFloat();
        Object val = stream.readObject();
        put(key, val);
    }
}
 
Example 15
private void readObject(ObjectInputStream stream)
    throws IOException, ClassNotFoundException {
    stream.defaultReadObject();

    int size = stream.readInt();
    setUp(size);
    while (size-- > 0) {
        double key = stream.readDouble();
        float val = stream.readFloat();
        put(key, val);
    }
}
 
Example 16
Source Project: gemfirexd-oss   File: TFloatHashSet.java    License: Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream stream)
    throws IOException, ClassNotFoundException {
    stream.defaultReadObject();

    int size = stream.readInt();
    setUp(size);
    while (size-- > 0) {
        float val = stream.readFloat();
        add(val);
    }
}
 
Example 17
private void readObject(ObjectInputStream stream)
    throws IOException, ClassNotFoundException {
    stream.defaultReadObject();

    int size = stream.readInt();
    setUp(size);
    while (size-- > 0) {
        float key = stream.readFloat();
        double val = stream.readDouble();
        put(key, val);
    }
}
 
Example 18
/**
 * Reads the map data from the stream. This method must be overridden if a
 * subclass must be setup before {@code put()} is used.
 * <p>
 * Serialization is not one of the JDK's nicest topics. Normal serialization will
 * initialise the superclass before the subclass. Sometimes however, this isn't
 * what you want, as in this case the {@code put()} method on read can be
 * affected by subclass state.
 * <p>
 * The solution adopted here is to deserialize the state data of this class in
 * this protected method. This method must be called by the
 * {@code readObject()} of the first serializable subclass.
 * <p>
 * Subclasses may override if the subclass has a specific field that must be present
 * before {@code put()} or {@code calculateThreshold()} will work correctly.
 *
 * @param in the input stream
 * @throws IOException            if IO operation fails
 * @throws ClassNotFoundException if unable to resolve object class
 */
protected void doReadObject ( final ObjectInputStream in ) throws IOException, ClassNotFoundException
{
    loadFactor = in.readFloat ();
    final int capacity = in.readInt ();
    final int size = in.readInt ();
    init ();
    threshold = calculateThreshold ( capacity, loadFactor );
    data = new HashEntry[ capacity ];
    for ( int i = 0; i < size; i++ )
    {
        final Object key = in.readObject ();
        final Object value = in.readObject ();
        put ( key, value );
    }
}
 
Example 19
Source Project: jphp   File: AbstractHashedMap.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Reads the map data from the stream. This method must be overridden if a
 * subclass must be setup before <code>put()</code> is used.
 * <p/>
 * Serialization is not one of the JDK's nicest topics. Normal serialization will
 * initialise the superclass before the subclass. Sometimes however, this isn't
 * what you want, as in this case the <code>put()</code> method on read can be
 * affected by subclass state.
 * <p/>
 * The solution adopted here is to deserialize the state data of this class in
 * this protected method. This method must be called by the
 * <code>readObject()</code> of the first serializable subclass.
 * <p/>
 * Subclasses may override if the subclass has a specific field that must be present
 * before <code>put()</code> or <code>calculateThreshold()</code> will work correctly.
 *
 * @param in the input stream
 */
protected void doReadObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    loadFactor = in.readFloat();
    int capacity = in.readInt();
    int size = in.readInt();
    init();
    data = new HashEntry[capacity];
    for (int i = 0; i < size; i++) {
        K key = (K) in.readObject();
        V value = (V) in.readObject();
        put(key, value);
    }
    threshold = calculateThreshold(data.length, loadFactor);
}
 
Example 20
/**
 * Reads the map data from the stream. This method must be overridden if a
 * subclass must be setup before <code>put()</code> is used.
 * <p/>
 * Serialization is not one of the JDK's nicest topics. Normal serialization will
 * initialise the superclass before the subclass. Sometimes however, this isn't
 * what you want, as in this case the <code>put()</code> method on read can be
 * affected by subclass state.
 * <p/>
 * The solution adopted here is to deserialize the state data of this class in
 * this protected method. This method must be called by the
 * <code>readObject()</code> of the first serializable subclass.
 * <p/>
 * Subclasses may override if the subclass has a specific field that must be present
 * before <code>put()</code> or <code>calculateThreshold()</code> will work correctly.
 *
 * @param in the input stream
 */
protected void doReadObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    loadFactor = in.readFloat();
    int capacity = in.readInt();
    int size = in.readInt();
    init();
    data = new HashEntry[capacity];
    for (int i = 0; i < size; i++) {
        K key = (K) in.readObject();
        V value = (V) in.readObject();
        put(key, value);
    }
    threshold = calculateThreshold(data.length, loadFactor);
}