can you give me an example of not serializable data? - serialization

I'm studying some basic informatic concepts, so this could be a very noob question. I've understood what Serialization is, and what is used for. What I'm trying to understand is if all objects are serializable. You can download from the Internet any file you like: to do that all the files have to be serializable, right?
Is there a file or an object that you cannot serialize?
Thank you!

Some objects contain references to system resources such as file descriptors. You may still serialize such objects because file descriptor is a 32/64 bit number. But if you deserialize it in another process/computer, it won't have any meaning because system resources are valid only in process where they were acquired. So, logically not all objects are serializable.

Related

vb.net serialization of system objects?

I am working with sending objects over network. I have it working with custom objects just fine but my question is can I serialize system objects? For example I want to serialize the System.Net.NetworkInformation.NetworkInterface object on one computer and send it to another so I can load all of its properties easily. Is this possible? This doesn't seem to work:
<Serializable()> NIC As System.Net.NetworkInformation.NetworkInterface
Thanks in advance
An object type has to be designed to be serializable, and marked so in it's original code. You will need to build your own object to keep the properties that you care about, mark it serializable, and use that.

Write/read class objects to/from file, D-Lang

I'm trying to write/read a class object from/to a file.
I'm new to D and I just want to play a little bit around with it.
Is there a Class/Function to write/read an object to/from a file?
I'm looking for something similar to the ObjectOutputStream сlass in Java.
Or do I have to serialize (concatenate) the object's variables as strings in the file?
I have a Movie class and a MovieManager class, which contains a dynamic movie-array.
A Movie object contains just a few strings and integer values.
Extending answer, provided in comment, it is worth explicitly stating, that D does not provide "one true way" of reading/writing objects to/from files, as there can't be a single optimal one. Different considerations about speed, resulting file format, handling references and similar corner cases may results in different serialization strategies.
That being said, most likely proper serialization library is needed, and, by lucky chance, one of most mature D solutions ("Orange" by Jacob Carlborg https://github.com/jacob-carlborg/orange) is being reviewed right now as a candidate for inclusion into standard library as a std.serialization: newsgroup thread. It may be your best bet.
The library Unmanaged provides a serialization system. You also have Orange
which is less restrictive, as Unmanaged serialization only works if the object to serialize is an ancestor of one of the framework base class.But...Unmanaged works on the "accessor" principle. The data serialized are get via a method and the data deserialized are set via a method, which allows to update some stuffs when the deserializer recall for example...

How to store complex objects into hadoop Hbase?

I have complex objects with collection fields which needed to be stored to Hadoop. I don't want to go through whole object tree and explicitly store each field. So I just think about serialization of complex fields and store it as one big piece. And than desirialize it when reading object. So what is the best way to do it? I though about using some kind serilization for that but I hope that Hadoop has means to handle this situation.
Sample object's class to store:
class ComplexClass {
<simple fields>
List<AnotherComplexClassWithCollectionFields> collection;
}
HBase only deals with byte arrays, so you can serialize your object in any way you see fit.
The standard Hadoop way of serializing objects is to implement the org.apache.hadoop.io.Writable interface. Then you can serialize your object into a byte array using org.apache.hadoop.io.WritableUtils.toByteArray(Writable ... writable).
Also, there are other serialization frameworks that people in the Hadoop community use, like Avro, Protocol Buffers, and Thrift. All have their specific use cases, so do your research. If you're doing something simple, implementing Hadoop's Writable should be good enough.

Cannot serialize Object to ViewState only Session

I have a class that is marked as serializable and have no problem storing it in the Session but when I attempt to save it in the ViewState I get:
Sys.WebForms.PageRequestManagerServerErrorException: Error serializing value
The reason is that view state serialization is done by the LosFormatter class while session serialization is done by the BinaryFormatter class. The two are subtly different and one of these subtle differences is probably causing your problem.
Take a look at this article and the documentation for LosFormatter to see if you can find some clues about what is causing your problem.
Well it also depends what kind of session do you use. If it's in-proc, then serialization doesn't take place at all. Your objects get stored into memory.

PHP Complete Object Graph not stored in Session

I have read other posts on stack overflow on the issue but my question is a little different..
When storing an object in the Session does PHP save the Complete Object Graph in the session?
I am having problems accessing some of the properties of the Object AFTER it is read from the Session.
The object i am storing has complex type properties with some of them being objects of classes that inherit from other classes, so serializing the object before storing it in the session might be a little "expensive".
What am i missing with Objects and their storage in the Session. Are there limits?
Thank you.
Complex object graphs are serialized fine. Even cyclic references can be serialized. You can't serialize resources though, and certain built-in object types. Generally speaking, serialization is a very expensive operation. You should not rely on it as a shared memory strategy.