Java Code Examples for java.io.DataOutput#writeFloat()

The following examples show how to use java.io.DataOutput#writeFloat() . 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
Source File: DataSerializer.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Writes an array of <code>float</code>s to a
 * <code>DataOutput</code>.
 * This method will serialize a
 * <code>null</code> array and not throw a
 * <code>NullPointerException</code>.
 *
 * @throws IOException
 *         A problem occurs while writing to <code>out</code>
 *
 * @see #readFloatArray
 */
public static void writeFloatArray(float[] array, DataOutput out)
  throws IOException {

  InternalDataSerializer.checkOut(out);

  int length;
  if (array == null) {
    length = -1;
  } else {
    length = array.length;
  }
  InternalDataSerializer.writeArrayLength(length, out);
  if (DEBUG) {
    InternalDataSerializer.logger.info( LocalizedStrings.DEBUG, "Writing float array of length " + length);
  }
  if (length > 0) {
    for (int i = 0; i < length; i++) {
      out.writeFloat(array[i]);
    }
  }
}
 
Example 2
Source File: DataSerializer.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Writes an array of <code>float</code>s to a
 * <code>DataOutput</code>.
 * This method will serialize a
 * <code>null</code> array and not throw a
 * <code>NullPointerException</code>.
 *
 * @throws IOException
 *         A problem occurs while writing to <code>out</code>
 *
 * @see #readFloatArray
 */
public static void writeFloatArray(float[] array, DataOutput out)
  throws IOException {

  InternalDataSerializer.checkOut(out);

  int length;
  if (array == null) {
    length = -1;
  } else {
    length = array.length;
  }
  InternalDataSerializer.writeArrayLength(length, out);
  if (DEBUG) {
    InternalDataSerializer.logger.info( LocalizedStrings.DEBUG, "Writing float array of length " + length);
  }
  if (length > 0) {
    for (int i = 0; i < length; i++) {
      out.writeFloat(array[i]);
    }
  }
}
 
Example 3
Source File: SQLReal.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@Override
public void toData(DataOutput out) throws IOException {
  if (!isNull()) {
    out.writeByte(getTypeId());
    out.writeFloat(this.value);
    return;
  }
  this.writeNullDVD(out);
}
 
Example 4
Source File: FloatArrayWritable.java    From multimedia-indexing with Apache License 2.0 5 votes vote down vote up
public void write(DataOutput out) throws IOException {
    int length = 0;
    if (data != null) {
        length = data.length;
    }

    out.writeInt(length);

    for (int i = 0; i < length; i++) {
        out.writeFloat(data[i]);
    }
}
 
Example 5
Source File: MapLiteSerializer.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void writeFloat(Float value, DataOutput output) throws IOException
{
	if (value == null) {
		output.writeFloat(0);
	} else {
		output.writeFloat(value);
	}
}
 
Example 6
Source File: FloatSerializer.java    From eagle with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(Object value, DataOutput dataOutput) throws IOException {
    if (value instanceof Number) {
        value = ((Number)value).floatValue();
    }
    dataOutput.writeFloat((float)value);
}
 
Example 7
Source File: TaskStatus.java    From big-c with Apache License 2.0 5 votes vote down vote up
public void write(DataOutput out) throws IOException {
  taskid.write(out);
  out.writeFloat(progress);
  out.writeInt(numSlots);
  WritableUtils.writeEnum(out, runState);
  Text.writeString(out, diagnosticInfo);
  Text.writeString(out, stateString);
  WritableUtils.writeEnum(out, phase);
  out.writeLong(startTime);
  out.writeLong(finishTime);
  out.writeBoolean(includeAllCounters);
  out.writeLong(outputSize);
  counters.write(out);
  nextRecordRange.write(out);
}
 
Example 8
Source File: ModOperation.java    From vxquery with Apache License 2.0 5 votes vote down vote up
@Override
public void operateFloatDecimal(FloatPointable floatp, XSDecimalPointable decp, DataOutput dOut)
        throws SystemException, IOException {
    float value = floatp.floatValue();
    value %= decp.floatValue();
    dOut.write(ValueTag.XS_FLOAT_TAG);
    dOut.writeFloat(value);
}
 
Example 9
Source File: DataSerializer.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Writes a primitive <code>float</code> to a
 * <code>DataOutput</code>.
 *
 * @throws IOException
 *         A problem occurs while writing to <code>out</code>
 *
 * @see DataOutput#writeFloat
 * @since 5.1
 */
public static void writePrimitiveFloat(float value, DataOutput out)
  throws IOException {

  InternalDataSerializer.checkOut(out);

  if (DEBUG) {
    InternalDataSerializer.logger.info( LocalizedStrings.DEBUG, "Writing Float " + value);
  }

  out.writeFloat(value);
}
 
Example 10
Source File: SubtractOperation.java    From vxquery with Apache License 2.0 5 votes vote down vote up
@Override
public void operateIntegerFloat(LongPointable longp, FloatPointable floatp, DataOutput dOut)
        throws SystemException, IOException {
    float value = longp.floatValue();
    value -= floatp.floatValue();
    dOut.write(ValueTag.XS_FLOAT_TAG);
    dOut.writeFloat(value);
}
 
Example 11
Source File: FrameworkUtils.java    From data-polygamy with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void write(DataOutput out) throws IOException {
    // spatial
    out.writeInt(this.spatial);
    
    // temporal
    out.writeInt(this.temporal);
    
    // attribute
    out.writeFloat(this.value);
}
 
Example 12
Source File: PMDSkinVertData.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void writeToStream(DataOutput os) throws IOException {
    os.writeInt(skinVertIndex);
    os.writeFloat(skinVertPos.x);
    os.writeFloat(skinVertPos.y);
    os.writeFloat(-skinVertPos.z);
}
 
Example 13
Source File: CastToFloatOperation.java    From vxquery with Apache License 2.0 4 votes vote down vote up
@Override
public void convertDecimal(XSDecimalPointable decp, DataOutput dOut) throws SystemException, IOException {
    float value = decp.floatValue();
    dOut.write(ValueTag.XS_FLOAT_TAG);
    dOut.writeFloat(value);
}
 
Example 14
Source File: CountAverageTuple.java    From hadoop-map-reduce-patterns with Apache License 2.0 4 votes vote down vote up
public void write(DataOutput out) throws IOException {
	out.writeFloat(count);
	out.writeFloat(average);
}
 
Example 15
Source File: Average.java    From data-polygamy with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void write(DataOutput out) throws IOException {
    out.writeFloat(sum);
    out.writeInt(count);
}
 
Example 16
Source File: DeltaObject.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
protected void _toDelta(DataOutput out) throws IOException {
   Log.getLogWriter().info("In DeltaObject.toDelta, for " + this + "\n" + "with DataOutput " + out);
   DeltaObserver.addToDeltaKey(extra);

   // for validation later, encode with a toDelta id number
   long toDeltaIdNumber = DeltaPropagationBB.getBB().getSharedCounters().incrementAndRead(DeltaPropagationBB.toDeltaIdNumber);
   out.writeLong(toDeltaIdNumber);
   Log.getLogWriter().info("Wrote toDeltaIdNumber " + toDeltaIdNumber);

   out.writeBoolean(aPrimitiveLongChanged);
   if (aPrimitiveLongChanged) {
      out.writeLong(aPrimitiveLong);
      Log.getLogWriter().info("Wrote changed field aPrimitiveLong " + aPrimitiveLong);
   }
   out.writeBoolean(aPrimitiveIntChanged);
   if (aPrimitiveIntChanged) {
      out.writeInt(aPrimitiveInt);
      Log.getLogWriter().info("Wrote changed field aPrimitiveInt " + aPrimitiveInt);
   }
   out.writeBoolean(aPrimitiveShortChanged);
   if (aPrimitiveShortChanged) {
      out.writeShort(aPrimitiveShort);
      Log.getLogWriter().info("Wrote changed field aPrimitiveShort " + aPrimitiveShort);
   }
   out.writeBoolean(aPrimitiveFloatChanged);
   if (aPrimitiveFloatChanged) {
      out.writeFloat(aPrimitiveFloat);
      Log.getLogWriter().info("Wrote changed field aPrimitiveFloat " + aPrimitiveFloat);
   }
   out.writeBoolean(aPrimitiveDoubleChanged);
   if (aPrimitiveDoubleChanged) {
      out.writeDouble(aPrimitiveDouble);
      Log.getLogWriter().info("Wrote changed field aPrimitiveDouble " + aPrimitiveDouble);
   }
   out.writeBoolean(aPrimitiveByteChanged);
   if (aPrimitiveByteChanged) {
      out.writeByte(aPrimitiveByte);
      Log.getLogWriter().info("Wrote changed field aPrimitiveByte " + aPrimitiveByte);
   }
   out.writeBoolean(aPrimitiveCharChanged);
   if (aPrimitiveCharChanged) {
      out.writeChar(aPrimitiveChar);
      Log.getLogWriter().info("Wrote changed field aPrimitiveChar " + aPrimitiveChar);
   }
   out.writeBoolean(aPrimitiveBooleanChanged);
   if (aPrimitiveBooleanChanged) {
      out.writeBoolean(aPrimitiveBoolean);
      Log.getLogWriter().info("Wrote changed field aPrimitiveBoolean " + aPrimitiveBoolean);
   }
   out.writeBoolean(aByteArrayChanged);
   if (aByteArrayChanged) {
      out.writeInt(aByteArray.length);
      out.write(aByteArray);
      Log.getLogWriter().info("Wrote changed field aByteArray of length " + aByteArray.length);
   }
   out.writeBoolean(aStringChanged);
   if (aStringChanged) {
      out.writeInt(aString.length());
      out.writeBytes(aString);
      Log.getLogWriter().info("Wrote changed field aString " + aString);
   }
   out.writeInt(END_SIGNAL.length());
   out.writeBytes(END_SIGNAL);
   Log.getLogWriter().info("Wrote end signal: " + END_SIGNAL);
   Log.getLogWriter().info("Done writing in DeltaObject.toDelta for " + this);
}
 
Example 17
Source File: DeltaObject.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
protected void _toDelta(DataOutput out) throws IOException {
   Log.getLogWriter().info("In DeltaObject.toDelta, for " + this + "\n" + "with DataOutput " + out);
   DeltaObserver.addToDeltaKey(extra);

   // for validation later, encode with a toDelta id number
   long toDeltaIdNumber = DeltaPropagationBB.getBB().getSharedCounters().incrementAndRead(DeltaPropagationBB.toDeltaIdNumber);
   out.writeLong(toDeltaIdNumber);
   Log.getLogWriter().info("Wrote toDeltaIdNumber " + toDeltaIdNumber);

   out.writeBoolean(aPrimitiveLongChanged);
   if (aPrimitiveLongChanged) {
      out.writeLong(aPrimitiveLong);
      Log.getLogWriter().info("Wrote changed field aPrimitiveLong " + aPrimitiveLong);
   }
   out.writeBoolean(aPrimitiveIntChanged);
   if (aPrimitiveIntChanged) {
      out.writeInt(aPrimitiveInt);
      Log.getLogWriter().info("Wrote changed field aPrimitiveInt " + aPrimitiveInt);
   }
   out.writeBoolean(aPrimitiveShortChanged);
   if (aPrimitiveShortChanged) {
      out.writeShort(aPrimitiveShort);
      Log.getLogWriter().info("Wrote changed field aPrimitiveShort " + aPrimitiveShort);
   }
   out.writeBoolean(aPrimitiveFloatChanged);
   if (aPrimitiveFloatChanged) {
      out.writeFloat(aPrimitiveFloat);
      Log.getLogWriter().info("Wrote changed field aPrimitiveFloat " + aPrimitiveFloat);
   }
   out.writeBoolean(aPrimitiveDoubleChanged);
   if (aPrimitiveDoubleChanged) {
      out.writeDouble(aPrimitiveDouble);
      Log.getLogWriter().info("Wrote changed field aPrimitiveDouble " + aPrimitiveDouble);
   }
   out.writeBoolean(aPrimitiveByteChanged);
   if (aPrimitiveByteChanged) {
      out.writeByte(aPrimitiveByte);
      Log.getLogWriter().info("Wrote changed field aPrimitiveByte " + aPrimitiveByte);
   }
   out.writeBoolean(aPrimitiveCharChanged);
   if (aPrimitiveCharChanged) {
      out.writeChar(aPrimitiveChar);
      Log.getLogWriter().info("Wrote changed field aPrimitiveChar " + aPrimitiveChar);
   }
   out.writeBoolean(aPrimitiveBooleanChanged);
   if (aPrimitiveBooleanChanged) {
      out.writeBoolean(aPrimitiveBoolean);
      Log.getLogWriter().info("Wrote changed field aPrimitiveBoolean " + aPrimitiveBoolean);
   }
   out.writeBoolean(aByteArrayChanged);
   if (aByteArrayChanged) {
      out.writeInt(aByteArray.length);
      out.write(aByteArray);
      Log.getLogWriter().info("Wrote changed field aByteArray of length " + aByteArray.length);
   }
   out.writeBoolean(aStringChanged);
   if (aStringChanged) {
      out.writeInt(aString.length());
      out.writeBytes(aString);
      Log.getLogWriter().info("Wrote changed field aString " + aString);
   }
   out.writeInt(END_SIGNAL.length());
   out.writeBytes(END_SIGNAL);
   Log.getLogWriter().info("Wrote end signal: " + END_SIGNAL);
   Log.getLogWriter().info("Done writing in DeltaObject.toDelta for " + this);
}
 
Example 18
Source File: RemoteRegionAttributes.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public void toData(DataOutput out) throws IOException {
  DataSerializer.writeString(this.cacheLoaderDesc, out);
  DataSerializer.writeString(this.cacheWriterDesc, out);
  DataSerializer.writeStringArray(this.cacheListenerDescs, out);
  DataSerializer.writeString(this.capacityControllerDesc, out);
  DataSerializer.writeObject(this.keyConstraint, out);
  DataSerializer.writeObject(this.valueConstraint, out);
  DataSerializer.writeObject(this.rTtl, out);
  DataSerializer.writeObject(this.rIdleTimeout, out);
  DataSerializer.writeObject(this.eTtl, out);
  DataSerializer.writeString(this.customEttlDesc, out);
  DataSerializer.writeObject(this.eIdleTimeout, out);
  DataSerializer.writeString(this.customEIdleDesc, out);
  DataSerializer.writeObject(this.dataPolicy, out);
  DataSerializer.writeObject(this.scope, out);
  out.writeBoolean(this.statsEnabled);
  out.writeBoolean(this.ignoreJTA);
  out.writeInt(this.concurrencyLevel);
  out.writeFloat(this.loadFactor);
  out.writeInt(this.initialCapacity);
  out.writeBoolean(this.earlyAck);
  out.writeBoolean(this.multicastEnabled);
  out.writeBoolean(this.enableGateway);
  DataSerializer.writeString(this.gatewayHubId, out);
  out.writeBoolean(this.enableSubscriptionConflation);
  out.writeBoolean(this.publisher);
  out.writeBoolean(this.enableAsyncConflation);

  DataSerializer.writeObject(this.diskWriteAttributes, out);
  DataSerializer.writeObject(this.diskDirs, out);
  DataSerializer.writeObject(this.diskSizes, out);
  out.writeBoolean(this.indexMaintenanceSynchronous);
  DataSerializer.writeObject(this.partitionAttributes, out);
  DataSerializer.writeObject(this.membershipAttributes, out);
  DataSerializer.writeObject(this.subscriptionAttributes, out);
  DataSerializer.writeObject(this.evictionAttributes, out);
  out.writeBoolean(this.cloningEnable);
  DataSerializer.writeString(this.diskStoreName, out);
  out.writeBoolean(this.isDiskSynchronous);
  DataSerializer.writeStringArray(this.gatewaySendersDescs, out);
  out.writeBoolean(this.isGatewaySenderEnabled);

  out.writeBoolean(this.concurrencyChecksEnabled);
  DataSerializer.writeString(this.hdfsStoreName, out);
  DataSerializer.writeString(this.compressorDesc, out);
  out.writeBoolean(this.enableOffHeapMemory);
}
 
Example 19
Source File: PMDUtil.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static void writeVector3f(DataOutput os, Vector3f v) throws IOException{
    os.writeFloat(v.x);
    os.writeFloat(v.y);
    os.writeFloat(-v.z);
}
 
Example 20
Source File: MemoryThresholds.java    From gemfirexd-oss with Apache License 2.0 2 votes vote down vote up
/**
 * Write the state of this to the DataOutput
 * 
 * @param out
 *          DataOutput on which to write internal state
 * @throws IOException
 */
public void toData(DataOutput out) throws IOException {
  out.writeLong(this.maxMemoryBytes);
  out.writeFloat(this.criticalThreshold);
  out.writeFloat(this.evictionThreshold);
}