@Override public void serialize(Object value, DataOutput dataOutput) { dataOutput.writeVUTF((String)value); }
@Override public final void writeBytes(DataOutput dataOutput) { if (recordIdBytes == null) { masterRecordId.writeBytes(dataOutput); // TODO this needs to be designed some other way if (masterRecordId instanceof UserRecordId) { dataOutput.writeByte((byte) 0); } Set<Entry<String, String>> entrySet = variantProperties.entrySet(); for (Entry<String, String> entry : entrySet) { // entry consists of the dimension and the dimension value dataOutput.writeVUTF(entry.getKey()); dataOutput.writeVUTF(entry.getValue()); } } else { dataOutput.writeBytes(recordIdBytes); } }
public static byte[] serialize(Set<String> strings) { DataOutput builder = new DataOutputImpl(); builder.writeVInt(strings.size()); for (String permission : strings) { builder.writeVUTF(permission); } return builder.toByteArray(); }
/** * Writes the metadata to the given output. It can be read back from a variable-length input using * {@link #read(DataInput)}. */ public static void write(Metadata metadata, DataOutput output) { // Write the fields Map<String, Object> map = metadata.getMap(); output.writeVInt(map.size()); for (Map.Entry<String, Object> entry : map.entrySet()) { // write the key output.writeVUTF(entry.getKey()); // write the value Object value = entry.getValue(); ValueSerDeser serdeser = CLASS_TO_SERDESER.get(value.getClass()); if (serdeser == null) { throw new IllegalArgumentException("Unsupported kind of metadata value: type of '" + value + "' is " + value.getClass().getName()); } output.writeByte(serdeser.getTypeByte()); serdeser.serialize(value, output); } // Write the deleted fields Set<String> fieldsToDelete = metadata.getFieldsToDelete(); output.writeVInt(fieldsToDelete.size()); for (String field : fieldsToDelete) { output.writeVUTF(field); } }