Example #1
0
 protected void write(DataOutputStream out) throws IOException {
   out.writeUTF(allocationMode.name());
   out.writeInt(length());
   out.writeUTF(dataType().name());
   if (dataType() == Type.DOUBLE) {
     for (int i = 0; i < length(); i++) out.writeDouble(getDouble(i));
   } else {
     for (int i = 0; i < length(); i++) out.writeFloat(getFloat(i));
   }
 }
Example #2
0
 @Override
 public void write(DataOutputStream out) throws IOException {
   if (length() >= Integer.MAX_VALUE)
     throw new IllegalArgumentException(
         "Length of data buffer can not be >= Integer.MAX_VALUE on output");
   out.writeUTF(allocationMode.name());
   out.writeInt((int) length());
   out.writeUTF(dataType().name());
   if (dataType() == Type.DOUBLE) {
     for (int i = 0; i < length(); i++) out.writeDouble(getDouble(i));
   } else if (dataType() == Type.INT) {
     for (int i = 0; i < length(); i++) out.writeInt(getInt(i));
   } else {
     for (int i = 0; i < length(); i++) out.writeFloat(getFloat(i));
   }
 }