我正在使用 Guava 的17.0版本,尤其是新的收藏类型.尝试通过Socket编写ImmutableTable时,我意识到该类及其具体实现似乎不可序列化.
I am using the version 17.0 of Guava, especially the new collection types. While trying to write an ImmutableTable through a Socket, I realized that the class and its concrete implementations do not seem to be serializable.
但是,以下两张票证似乎表明开发人员已意识到该问题:
However, the two following tickets seem to indicate that the developers are aware of the issue:
- 问题1264
- 问题1562
- Issue 1264
- Issue 1562
你们中有人对包含ImmutableTable属性的类进行序列化吗?我该怎么做,而又不使用Map的Map?
Do any of you serialize classes containing ImmutableTable attributes? How could I do this, without resorting to using a Map of Maps?
推荐答案即使ImmuttableTable无法序列化,您也可以始终使用 HashBasedTable 或其他表实现.然后反序列化之后,使用ImmutableTable.copyOf(deserialized)再次获取ImmutableTable.不完全优雅,但实施起来很简单.
Even though ImmuttableTable isn't serializable, you could always use a HashBasedTable or one of the other Table implementations. And then after deserialization, use ImmutableTable.copyOf(deserialized) to get the ImmutableTable again. Not exactly elegant, but simple enough to implement.
更多推荐
序列化番石榴的不可变表
发布评论