@Override public void writeBytes(DataOutput dataOutput) { if (recordIdBytes == null) { dataOutput.writeByte(IdGeneratorImpl.IdType.USER.getIdentifierByte()); dataOutput.writeUTF(basicRecordIdString, false); } else { dataOutput.writeBytes(recordIdBytes); } }
@Override public void writeBytes(DataOutput dataOutput) { if (uuidBytes == null) { dataOutput.writeByte(IdGeneratorImpl.IdType.UUID.getIdentifierByte()); dataOutput.writeLong(uuid.getMostSignificantBits()); dataOutput.writeLong(uuid.getLeastSignificantBits()); } else { dataOutput.writeBytes(uuidBytes); } }
@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); } }
/** * Format of the bytes written : * - Length of the blob value : int of 4 bytes * - Blob Value * - Blob Media Type : UTF (which starts with an int of 4 bytes indicating its length) * - Blob size : long of 8 bytes * - Blob name : UTF (which starts with an int of 4 bytes indicating its length) * * <p> IMPORTANT: Any changes on this format has an impact on the {@link ContainsValueComparator} */ @Override public void write(Object value, DataOutput dataOutput, IdentityRecordStack parentRecords) { dataOutput.writeByte((byte)1); // Encoding version 1 Blob blob = (Blob)value; byte[] key = blob.getValue(); if (key == null) { dataOutput.writeVInt(0); } else { dataOutput.writeVInt(key.length); dataOutput.writeBytes(key); } dataOutput.writeUTF(blob.getMediaType()); Long size = blob.getSize(); if (size == null) { size = Long.valueOf(-1); } dataOutput.writeLong(size); dataOutput.writeUTF(blob.getName()); }
dataOutput.writeByte(ENCODING_VERSION); byte[] recordIdBytes = recordType.getId().getBytes(); dataOutput.writeVInt(recordIdBytes.length); Object fieldValue = recordFields.get(name); if (fieldValue == null) { dataOutput.writeByte(UNDEFINED); } else { dataOutput.writeByte(DEFINED); parentRecords.push(record); fieldType.getValueType().write(fieldValue, dataOutput, parentRecords);
@Override public void write(Object value, DataOutput dataOutput, IdentityRecordStack parentRecords) { dataOutput.writeByte((byte)1); // Encoding version 1 // Currently we only store the millis, not the chronology. dataOutput.writeLong(((DateTime)value).getMillis()); }
@Override public void write(Object value, DataOutput dataOutput, IdentityRecordStack parentRecords) { dataOutput.writeByte((byte)1); // Encoding version 1 dataOutput.writeUTF((String)value); }
@Override public void write(Object value, DataOutput dataOutput, IdentityRecordStack parentRecords) { // We're not storing any recordType information together with the data // The recordType information is only available in the schema dataOutput.writeByte(VERSION_THREE); ((Link)value).write(dataOutput); }
@Override public void write(Object value, DataOutput dataOutput, IdentityRecordStack parentRecords) { dataOutput.writeByte((byte)1); // Encoding version 1 // Currently we only store the millis, not the chronology. dataOutput.writeLong(((LocalDate)value).toDateTimeAtStartOfDay(DateTimeZone.UTC).getMillis()); }
public static byte[] encodeValueType(String valueTypeName) { DataOutput dataOutput = new DataOutputImpl(); dataOutput.writeByte(valueTypeEncodingVersion); dataOutput.writeUTF(valueTypeName); return dataOutput.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); } }
boolean hasMetadata = metadata != null && !metadata.getMap().isEmpty(); dataOutput.writeByte(hasMetadata ? FieldFlags.METADATA_V1 : FieldFlags.DEFAULT); try { valueType.write(fieldValue, dataOutput, new IdentityRecordStack(parentRecord));