public void write(DataOutput out) throws IOException { out.write(UNION_TYPE); out.writeUTF(name); out.writeInt(unionTypes.size()); for (InferredType it : unionTypes) { it.write(out); } }
public void write(DataOutput out) throws IOException { out.write(STRUCT_TYPE); out.writeUTF(name); out.writeInt(structTypes.size()); for (InferredType it : structTypes) { it.write(out); } }
@Override public void serialize(DataOutput dataOutput, GeobufFeature geobufFeature) throws IOException { GeobufEncoder enc = getEncoder(); // This could be more efficient, we're wrapping a single feature in a feature collection. But // that way the key/value // serialization all works. Geobuf.Data feat = enc.makeFeatureCollection(Arrays.asList(geobufFeature)); byte[] data = feat.toByteArray(); dataOutput.writeInt(data.length); dataOutput.write(data); }
/** * {@inheritDoc} * * @see Writable#write(DataOutput) */ public void write(DataOutput out) throws IOException { BSONEncoder enc = new BSONEncoder(); BasicOutputBuffer buf = new BasicOutputBuffer(); enc.set(buf); enc.putObject(_doc); enc.done(); out.writeInt(buf.size()); // For better performance we can copy BasicOutputBuffer.pipe(OutputStream) // to have a method signature that works with DataOutput out.write(buf.toByteArray()); }
public void write(DataOutput out) throws IOException { out.write(BASE_TYPE); out.writeUTF(name); out.writeInt(sampleStrs.size()); for (int i = 0; i < sampleStrs.size(); i++) { UTF8.writeString(out, sampleStrs.get(i)); } out.writeInt(tokenClassIdentifier); out.writeBoolean(tokenParameter != null); if (tokenParameter != null) { UTF8.writeString(out, tokenParameter); } }
public void writeTo(DataOutput out) throws Exception { out.writeByte(type.ordinal()); // We can't use Util.writeObject since it's size is limited to 2^15-1 try { if (object instanceof Streamable) { out.writeShort(-1); Util.writeGenericStreamable((Streamable) object, out); } else { byte[] bytes = Util.objectToByteBuffer(object); out.writeInt(bytes.length); out.write(bytes); } } catch (IOException e) { throw e; } catch (Exception e) { throw new IOException("Exception encountered while serializing execution request", e); } out.writeLong(request); }
private void writeRecord(DataOutput dataOutput, Object[] objectArray) throws IOException { dataOutput.write((byte) ' '); for (int j = 0; j < this.header.fieldArray.length; j++) { /* iterate throught fields */ switch (this.header.fieldArray[j].getDataType()) { case 'C': if (objectArray[j] != null) { String str_value = objectArray[j].toString(); dataOutput.write( Utils.textPadding( str_value, characterSetName, this.header.fieldArray[j].getFieldLength())); } else { dataOutput.write( Utils.textPadding( "", this.characterSetName, this.header.fieldArray[j].getFieldLength())); } break; case 'D': if (objectArray[j] != null) { GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime((Date) objectArray[j]); dataOutput.write(String.valueOf(calendar.get(Calendar.YEAR)).getBytes()); dataOutput.write( Utils.textPadding( String.valueOf(calendar.get(Calendar.MONTH) + 1), this.characterSetName, 2, Utils.ALIGN_RIGHT, (byte) '0')); dataOutput.write( Utils.textPadding( String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)), this.characterSetName, 2, Utils.ALIGN_RIGHT, (byte) '0')); } else { dataOutput.write(" ".getBytes()); } break; case 'F': if (objectArray[j] != null) { dataOutput.write( Utils.doubleFormating( (Double) objectArray[j], this.characterSetName, this.header.fieldArray[j].getFieldLength(), this.header.fieldArray[j].getDecimalCount())); } else { dataOutput.write( Utils.textPadding( " ", this.characterSetName, this.header.fieldArray[j].getFieldLength(), Utils.ALIGN_RIGHT)); } break; case 'N': if (objectArray[j] != null) { dataOutput.write( Utils.doubleFormating( (Double) objectArray[j], this.characterSetName, this.header.fieldArray[j].getFieldLength(), this.header.fieldArray[j].getDecimalCount())); } else { dataOutput.write( Utils.textPadding( " ", this.characterSetName, this.header.fieldArray[j].getFieldLength(), Utils.ALIGN_RIGHT)); } break; case 'L': if (objectArray[j] != null) { if ((Boolean) objectArray[j] == Boolean.TRUE) { dataOutput.write((byte) 'T'); } else { dataOutput.write((byte) 'F'); } } else { dataOutput.write((byte) '?'); } break; case 'M': break; default: throw new DBFException("Unknown field type " + this.header.fieldArray[j].getDataType()); } } /* iterating through the fields */ }
public void writeTo(DataOutput out) throws Exception { out.writeByte(type); out.writeShort(version.length); out.write(version); }
public void write(DataOutput out) throws IOException { out.write(ARRAY_TYPE); out.writeUTF(name); bodyType.write(out); }