for (QName fieldName : record.getFields().keySet()) {
FieldType fieldType = typeManager.getFieldTypeByName(fieldName);
Metadata metadata = record.getMetadata(fieldName);
boolean hasMetadata = metadata != null && !metadata.getMap().isEmpty();
DataOutput output = new DataOutputImpl();
output.writeByte(hasMetadata ? FieldFlags.METADATA_V1 : FieldFlags.DEFAULT);
output.writeBytes(fieldType.getValueType().toBytes(record.getField(fieldName), new IdentityRecordStack()));
if (hasMetadata) {
HBaseRepository.writeMetadataWithLengthSuffix(metadata, output);
}
event.addUpdatedField(fieldType.getId());
kvs.add(new KeyValue(rowKey, family,
Bytes.add(new byte[]{LilyHBaseSchema.RecordColumn.DATA_PREFIX}, fieldType.getId().getBytes()),
output.toByteArray()));
}
// fields to delete, should we add these too?
kvs.add(new KeyValue(rowKey, family, LilyHBaseSchema.RecordColumn.PAYLOAD.bytes, event.toJsonBytes()));