serialization - GWT 能有效地序列化 java.lang.Longs 吗?

标签 serialization gwt performance network-efficiency

我通过 GWT RPC 机制在客户端和服务器之间来回发送对象 ID。 id 以 Longs(8 字节)的形式从数据存储中出来。我认为我所有的 id 只需要 4 个字节,但可能会发生一些随机事件,给我一个 5 字节(或其他)的值。

GWT 是否会聪明地将这些值打包成某种可变长度编码,这样平均可以节省空间?我可以在某处指定它这样做吗?或者我应该编写自己的代码将多头复制到整数并注意那些特殊情况?

谢谢~

最佳答案

GWT documentation 中所述.

long: JavaScript has no 64-bit integral type, so long needs special consideration. Prior to GWT 1.5, the long type was was simply mapped to the integral range of a 64-bit JavaScript floating-point value, giving long variables an actual range less than the full 64 bits. As of GWT 1.5, long primitives are emulated as a pair of 32-bit integers, and work reliably over the entire 64-bit range. Overflow is emulated to match the expected behavior. There are a couple of caveats. Heavy use of long operations will have a performance impact due to the underlying emulation. Additionally, long primitives cannot be used in JSNI code because they are not a native JavaScript numeric type.



如果您的 id 可以放入整数,那么您可能会更好。否则,如果您使用的是 DTO,请将 id 设为 double ,这实际上存在于 Javascript 中。

关于serialization - GWT 能有效地序列化 java.lang.Longs 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3808209/

相关文章:

java - 哪些更改会使序列化类版本不兼容?

.net - 如何在 ASP.NET 中找到无法序列化的对象?

java - 带有 smartGWT : No palettes for smart widgets (XML UIBinder mode) 的 GWT 设计器

android - 粗略定位是否比 Android 上的地理围栏使用更少的电池?

c - 在c : do internal states improve speed?中

java - 读取流套接字服务器

java - 将 Java 对象(反)序列化为文件的最佳方法是什么

Eclipse Tomcat 资源可用列表不包含 Gwt 2.7.0 maven 应用程序

java - 如何在 GWT 应用程序中显示一种格式?

sql - 性能差异 : select top 1 order by vs. select min(val)