chaokunyang commented on issue #2609:
URL: https://github.com/apache/fory/issues/2609#issuecomment-3588321875
For xlang serialization, we do have a concept to distinguish the type kinds,
and allow every kind to use their own id:
```java
@Override
public void writeClassInfo(MemoryBuffer buffer, ClassInfo classInfo) {
int xtypeId = classInfo.getXtypeId();
int internalTypeId = xtypeId & 0xff;
buffer.writeVarUint32Small7(xtypeId);
switch (internalTypeId) {
case Types.NAMED_ENUM:
case Types.NAMED_STRUCT:
case Types.NAMED_EXT:
if (shareMeta) {
writeSharedClassMeta(buffer, classInfo);
return;
}
assert classInfo.namespaceBytes != null;
metaStringResolver.writeMetaStringBytes(buffer,
classInfo.namespaceBytes);
assert classInfo.typeNameBytes != null;
metaStringResolver.writeMetaStringBytes(buffer,
classInfo.typeNameBytes);
break;
case Types.NAMED_COMPATIBLE_STRUCT:
case Types.COMPATIBLE_STRUCT:
assert shareMeta : "Meta share must be enabled for compatible mode";
writeSharedClassMeta(buffer, classInfo);
break;
default:
break;
}
}
```
Users can reigster id from 0, and even fory register new interal types, it
won't break users.
We can unify this with java serialization, but I'm not sure whether it will
introduce extra cost, maybe need some benchmark. And it's a big change, it may
take more efforts.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]