序列化番石榴的不可变表

编程入门 行业动态 更新时间:2024-10-23 18:27:49
本文介绍了序列化番石榴的不可变表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

更多推荐

序列化番石榴的不可变表

本文发布于:2023-10-19 14:49:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1507844.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:番石榴   序列化

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!