Marking a message as `NESTED`

When using Record Layer, I was wondering when should a message be marked as NESTED?

For example in the following definition for a Record Store,

message MyInnerRecord1 {
    option (com.apple.foundationdb.record.record).usage = NESTED;
    optional int64 val = 1;
}

message MyInnerRecord2 {
    optional int64 val = 1;
}

message MyOuterRecord {
    optional int64 pk = 1 [(com.apple.foundationdb.record.field).primary_key = true];
    optional MyInnerRecord1 my_inner_record1 = 2;
    optional MyInnerRecord2 my_inner_record2 = 3;
}

message UnionDescriptor {
    option (com.apple.foundationdb.record.record).usage = UNION;
    optional MyOuterRecord _MyOuterRecord = 1;
}

What would be the difference between using MyInnerRecord1 and MyInnerRecord2?

The NESTED usage is essentially optional. What really matters is that any top-level type that you want to be a record type have a corresponding field in the UNION message.

I believe we have some validation steps that make sure that messages explicitly marked as NESTED don’t wind up in the union message, and messages marked as MESSAGE don’t get forgotten. See: fdb-record-layer/RecordMetaDataBuilder.java at 1aec8f5212a99d1eaeeae9c38a42cc571f42a5a9 · FoundationDB/fdb-record-layer · GitHub

But other than running those validations, setting the message usage as NESTED and RECORD is optional

Thanks @alloc for the reply!