Closed liqipeng closed 1 month ago
Currently, SCHEMA_CONSISTENT and COMPATIBLE modes are completely incompatible. I think that COMPATIBLE mode keep compatible with SCHEMA_CONSISTENT mode maybe necessary, so that SCHEMA_CONSISTENT mode can be easily switched to SCHEMA_CONSISTENT mode when the need for SCHEMA changes occurs.
We don't have plan to make SCHEMA_CONSISTENT and COMPATIBLE modes compatible with each other. If your scheme may change, you need to use COMPATIBLE from the start
Currently, SCHEMA_CONSISTENT and COMPATIBLE modes are completely incompatible. I think that COMPATIBLE mode keep compatible with SCHEMA_CONSISTENT mode maybe necessary, so that SCHEMA_CONSISTENT mode can be easily switched to SCHEMA_CONSISTENT mode when the need for SCHEMA changes occurs.
@chaokunyang 不好意思,可能蹩脚英文没说清楚,我想表达的是可以考虑一种单向的兼容,仅支持从SCHEMA_CONSISTENT迁移至COMPATIBLE即可。因为可能schema设计者一开始考虑不够充分使用了SCHEMA_CONSISTENT,后来有需求增加字段,他可以将模式切换为兼容模式来实现需求。
对fury底层原理暂不了解,先猜测假设一下,如果实现这种单向模式的兼容,不需要对fury底层做变更,更多是api层面的兼容,当选择COMPATIBLE模式执行反序列化时先探测一下二进制数据的模式(假定有相应的标识字段),如果实际数据是来自SCHEMA_CONSISTENT则正常按SCHEMA_CONSISTENT反序列化即可。
这样的兼容是可以提高fury的易用性的。目前默认为SCHEMA_CONSISTENT,如果初级使用者没深入理解这两种模式的差异是很容易做出错误决策的,当前两种模式完全不支持迁移会导致切换模式成本很高。
We can't do that. Schema compatible mode need to write class meta for deserialization, scheme consistent mode doesn't write that meta
@chaokunyang 目前是否有工具api可以探测序列化数据是哪种模式(SCHEMA_CONSISTENT或者COMPATIBLE)呢?
(类似于探测JDK 序列化的工具JavaSerializer.serializedByJDK(byte[] data)
)
We don't provide such tools, you can write such a header before write FURY serialized data
We don't provide such tools, you can write such a header before write FURY serialized data
Got it. Thank you for your reply.
Question
Language: Java
Version: 0.8.0
Step1: Serialize object without
private Integer age;
Step2: Derialize object with
private Integer age;
Throw exception: