序列化番石榴的不可变表 [英] Serializing Guava's ImmutableTable

查看:67
本文介绍了序列化番石榴的不可变表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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:

  • Issue 1264
  • Issue 1562

你们中有人对包含ImmutableTable属性的类进行序列化吗?我该怎么做,而又不使用MapMap?

Do any of you serialize classes containing ImmutableTable attributes? How could I do this, without resorting to using a Map of Maps?

推荐答案

即使ImmuttableTable无法序列化,您也可以始终使用

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.

这篇关于序列化番石榴的不可变表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆