Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialisation #65

Closed
hadley opened this issue Dec 14, 2015 · 7 comments
Closed

Serialisation #65

hadley opened this issue Dec 14, 2015 · 7 comments

Comments

@hadley
Copy link
Member

hadley commented Dec 14, 2015

i.e. how to make saveRDS() and readRDS() work?

@hadley
Copy link
Member Author

hadley commented Dec 14, 2015

From Kurt:

? XML::xmlSerializeHook

for a mechanism with user-level hooks, and then

http://r.789695.n4.nabble.com/serialization-of-external-pointers-td3552746.html

for a pointer to what Simon seems to do for rJava, and then

https://www.rforge.net/doc/packages/rJava/jserialize.html

for more on this.

@hadley
Copy link
Member Author

hadley commented May 4, 2016

I think we just need to serialise as a string and the deserialise on load.

@jimhester
Copy link
Member

There are three types of objects we would want to serialize.

  1. xml_documents - These are easy, just serialize them with as.character() and deserialize with read_xml()
  2. xml_node - Not sure how to deal with the doc ptr, I assume we don't want to serialize the entire document for each node, but maybe there is no other choice... Even if we do how do we ensure the node is pointing to the proper place in the tree?
  3. xml_nodesets - Same issues as 2., but each node in the nodeset will have the same document.

Maybe we should just punt on 2. and 3. and only serialize xml_documents?

@jimhester
Copy link
Member

Another issue, the function given in the refhook= parameter of readRDS() and saveRDS() is called for each external pointer without any context, so while I can serialize and deserialize the document pointer I cannot have the deserialized node pointer point to the deserialized document.

We could fix this by wrapping readRDS() and setting the node after deserializing the object, but if we are using our own function how much more useful is this than just using xml_write(), xml_read() directly...

@hadley
Copy link
Member Author

hadley commented May 12, 2016

Can you have a look at what XML does?

@jimhester
Copy link
Member

The main difference is in XML when you xmlParseDoc() you get a single external pointer to the document, where we have two pointers to the document and root node. So they can just create the document pointer with the serialized text nodes.

@hadley
Copy link
Member Author

hadley commented May 25, 2016

Seems pretty hacky, so lets not worry about for now.

@hadley hadley closed this as completed May 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants