public final void writeDatum(final double value,final int attributeIndex,final Attribute attribute,final ColumnType columnType,final DataOutput out,final boolean sparse) throws IOException {
  if (sparse) {
    if (Tools.isDefault(attribute.getDefault(),value)) {
      return;
    }
 else {
      out.writeInt(attributeIndex);
    }
  }
switch (columnType) {
case DOUBLE:
    out.writeDouble(value);
  break;
case INTEGER:
if (Double.isNaN(value)) {
  out.writeInt(Integer.MIN_VALUE + 1);
  out.writeBoolean(true);
}
 else {
  out.writeInt((int)value);
  if ((int)value == Integer.MIN_VALUE + 1) {
    out.writeBoolean(false);
  }
}
break;
case NOMINAL_BYTE:
if (Double.isNaN(value)) {
out.writeByte(-1);
}
 else {
out.writeByte((byte)value);
}
break;
case NOMINAL_INTEGER:
if (Double.isNaN(value)) {
out.writeInt(-1);
}
 else {
out.writeInt((int)value);
}
break;
case NOMINAL_SHORT:
if (Double.isNaN(value)) {
out.writeShort(-1);
}
 else {
out.writeShort((short)value);
}
break;
default :
throw new RuntimeException("Illegal type: " + columnType);
}
}

public final void writeDatum ( final double value , final int attributeIndex , final Attribute attribute , final ColumnType columnType , final DataOutput out , final boolean sparse ) throws IOException { if ( sparse ) { if ( Tools . isDefault ( attribute . getDefault ( ) , value ) ) { return ; } else { out . writeInt ( attributeIndex ) ; } } switch ( columnType ) { case DOUBLE : out . writeDouble ( value ) ; break ; case INTEGER : if ( Double . isNaN ( value ) ) { out . writeInt ( Integer . MIN_VALUE + 1 ) ; out . writeBoolean ( true ) ; } else { out . writeInt ( ( int ) value ) ; if ( ( int ) value == Integer . MIN_VALUE + 1 ) { out . writeBoolean ( false ) ; } } break ; case NOMINAL_BYTE : if ( Double . isNaN ( value ) ) { out . writeByte ( - 1 ) ; } else { out . writeByte ( ( byte ) value ) ; } break ; case NOMINAL_INTEGER : if ( Double . isNaN ( value ) ) { out . writeInt ( - 1 ) ; } else { out . writeInt ( ( int ) value ) ; } break ; case NOMINAL_SHORT : if ( Double . isNaN ( value ) ) { out . writeShort ( - 1 ) ; } else { out . writeShort ( ( short ) value ) ; } break ; default : throw new RuntimeException ( "Illegal type: " + columnType ) ; } }
writes a single datum with the given index . the data type is specified by the parameter columntype . if sparse is true , the value is prefixed by the given attributeindex .
