找回密码
 注册
查看: 1767|回复: 0

R语言 rJava包 jserialize()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-22 21:05:29 | 显示全部楼层 |阅读模式
jserialize(rJava)
jserialize()所属R语言包:rJava

                                         Java object serialization
                                         Java对象序列化

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

.jserialize serializes a Java object into raw vector using Java serialization.
.jserialize到原料向量使用Java序列化的Java对象序列化。

.junserialize re-constructs a Java object from its serialized (raw-vector) form.
.junserialize重新构建一个Java对象的序列(原始向量)的形式。

.jcache updates, retrieves or removes R-side object cache which can be used for persistent storage of Java objects across sessions.
.jcache更新,检索或删除可用于Java对象持久存储在会话中使用的R-端对象缓存。


用法----------Usage----------


.jserialize(o)
.junserialize(data)
.jcache(o, update=TRUE)



参数----------Arguments----------

参数:o
Java object
Java对象


参数:data
serialized Java object as a raw vector
序列化的Java对象作为原始向量


参数:update
must be TRUE (cache is updated), FALSE (cache is retrieved) or NULL (cache is deleted).
必须是TRUE(缓存更新),FALSE(高速缓存中检索)或NULL被删除(缓存)。


Details

详情----------Details----------

Not all Java objects support serialization, see Java documentation for details. Note that Java serialization and serialization of R objects are two entirely different mechanisms that cannot be interchanged. .jserialize and .junserialize can be used to access Java serialization facilities.
并不是所有的Java对象支持序列化,详情请参阅Java文档。请注意,Java序列化和系列化研发对象是两个完全不同的机制,不能互换。 .jserialize和.junserialize可以用来访问Java序列化设施。

.jcache manipulates the R-side Java object cache associated with a given Java reference:
.jcache操纵的R-端Java对象缓存与一个给定的Java参考:

Java objects do not persist across sessions, because the Java Virtual Machine (JVM) is destroyed when R is closed. All saved Java object references will be restored as null references, since the corresponding objects no longer exist (see R documentation on serialization). However, it is possible to serialize a Java object (if supported by the object) and store its serialized form in R. This allows for the object to be deserialized when loaded into another active session (but see notes below!)
Java对象不坚持在不同的会话,因为Java虚拟机(JVM)R被关闭时被销毁。 null引用将恢复所有保存的Java对象引用,因为相应的对象不再存在(见R系列化文件)。但是,它是可以序列化一个Java对象(如果支持对象),并将其序列在R的形式,这使得反序列化的对象被加载到另一个活动会话(见下面的说明!)

R-side cache consists of a serialized form of the object as raw vector. This cache is attached to the Java object and thus will be saved when the Java object is saved. rJava provides an automated way of deserializing Java references if they are null references and have a cache attached. This is done on-demand basis whenever a reference to a Java object is required.
包括为原料的矢量对象的序列化形式的R端缓存。此缓存连接到Java对象,从而保存Java对象时,将被保存。 rJava提供了一个自动化的方式反序列化的Java参考,如果他们是null引用和附加缓存。这是按需的基础上,每当需要一个Java对象的引用。

Therefore packages can use .jcache to provide a way of creating Java references that persist across sessions. However, they must be very cautious in doing so. First, make sure the serialized form is not too big. Storing whole datasets in Java serialized form will hog immense amounts of memory on the R side and should be avoided. In addition, be aware that the cache is just a snapshot, it doesn't change when the referenced Java object is modified. Hence it is most useful only for references that are not modified outside R. Finally, internal references to other Java objects accessible from R are not retained (see below). Most common use of .jcache is with Java references that point to definitions of methods (e.g., models) and other descriptive objects which are then used by other, active Java classes to act upon. Caching of such active objects is not a good idea, they should be instantiated by functions that operate on the descriptive references instead.
因此,包可以使用.jcache提供了创建跨会话坚持Java的引用方式。然而,他们必须这样做非常谨慎。首先,确保没有太大的序列化形式。 Java序列化的形式存储在整个数据集,将猪的R端上巨量的内存,并应避免。此外,要知道,缓存仅仅是一个快照,它不会改变引用的Java对象被修改时。因此,它是最有用的,只为参考,不被修改外河,最后从R访问其它Java对象的内部引用是不保留(见下文)。最常见的使用.jcache是与Java的引用这一点的方法(例如,模型)和其他描述对象,然后由其他的,积极的Java类用于付诸行动的定义。缓存等活动对象是不是一个好主意,他们应该被实例化的功能操作,而不是描述引用。

Important note: the serialization of Java references does NOT take into account any dependencies on the R side. Therefore if you hold a reference to a Java object in R that is also referenced by the serialized Java object on the Java side, then this relationship cannot be retained upon restore. Instead, two copies of disjoint objects will be created which can cause confusion and errorneous behavior.
重要说明:序列化的Java参考,不考虑任何依赖R侧。因此,如果你持有在R的Java对象,也由在Java端的序列化的Java对象引用的参考,那么这种关系不能被保留后恢复。相反,将创建两个不相交的对象副本,这可能会导致混乱和errorneous行为。

The cache is attached to the reference external pointer and thus it is shared with all copies of the same reference (even when changed via .jcast etc.), but it is independent of other references to the object obtained separately (e.g., via .jcall or .jfield).
缓存连接到外部参考指针,因此它是共享相同的参考(即使通过.jcast等改变)的所有副本,但它是独立于其他引用对象分别获得(例如,通过.jcall或.jfield)。

Also note that deserialization (even automated one) requires a running virtual machine. Therefore you must make sure that either .jinit or .jpackage is used before any Java references are accessed.
还要注意的是反序列化(甚至自动化一)需要运行的虚拟机。因此,你必须确保,要么.jinit或.jpackage之前访问任何Java引用。


值----------Value----------

.jserialize returns a raw vector
.jserialize返回原始向量

.junserialize returns a Java object or NULL if an error occurred (currently you may use .jcheck() to further investigate the error)
.junserialize返回一个Java对象或NULL如果发生错误(目前你可以使用.jcheck()进一步调查的误差)

.jcache returns the current cache (usually a raw vector) or NULL if there is no cache.
.jcache返回当前缓存(通常是原始向量)或NULL如果没有缓存。

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-1-22 16:15 , Processed in 0.029350 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表