Re: serialize only a litte part?

From: NOBODY (anti_at_spam.org)
Date: 01/15/04

  • Next message: Tony Morris: "Re: Unsatisfied Link Error - works on one machine but not the other - HELP!!!"
    Date: Thu, 15 Jan 2004 02:18:00 GMT
    
    

    Note:
    BAIS: byte array input stream
    BAOS: byte array output stream

    Yes you can serialize only a part. Here is the twist:

    1-You have to write to a BAOS subclass (to avoid arraycopy and get access
    to the buffer, for reuse, and the count)

    2-you write 1 instance of all common classes you intend to use to the
    object stream (this is the learn phase)
    3-you flush, and count how many bytes were written.
    4-you write your instance and flush
    5-you grab only the byte between the mark and the end and save them.

    when reading:

    1-prepare a static readonly version of the byte[] prefix created earlier,
    this is a working cached version of the data you didn't want to save.
    remember that it must be exactly the same classes you wrote in phase 2
    above.

    2-you load your data in another byte[].
    3-either you concat the 2 arrays and wrap the OIS over BAIS over byte[],
    or better, you use a OIS over sequenceinputstream over 2 BAIS over the 2
    byte[].

    4-read all the "dummy" prefix objects
    5-read your instance.

    NOTE:
    -the size is definitely smaller, but be warned that the r/w of dummies
    are taking much more CPU now.
    -String is natively supported like a primitive, but not arrays of it.
    -arrays (of any dimensions) of a class are not learned when the class is
    learned.
    -write your own Externalizable classes and persist yourself, the
    readExternal is about 60%-80% of typical readobjects. And it makes
    smaller data.
    -this trick make data versionning almost impossible.
    -you can detect classes by overriding OOS.annotateClass() and loggin to
    console for dev purpose.

    cmk128@hotmail.com (Peter) wrote in news:a52de42d.0401091946.55ad0f57
    @posting.google.com:

    > Hi
    > For example, I have serialize a hugh object into file system. A
    > little part of the object change. How can i only serialize that little
    > part? or i have to serialize the whole object again?
    >
    > thanks
    > from Peter (cmk128@hotmail.com)


  • Next message: Tony Morris: "Re: Unsatisfied Link Error - works on one machine but not the other - HELP!!!"

    Relevant Pages

    • Re: saving std::string to a file
      ... Deserialize methods. ... how to recreate the object from a stream. ... as long as the Serialize function writes the length first. ... I was looping through the array and each CPoint was saving itself., ...
      (microsoft.public.vc.language)
    • Re: Array to Xml to DataSet
      ... In order to read the contents of the stream into the DataSet you need to ... MS MVP XML ... Array to Xml to DataSet ... So I serialize the array to XML, ...
      (microsoft.public.dotnet.xml)
    • Re: Error Saving Bitmaps when stored in an array?
      ... I have an array of Bitmap images which I am trying to Serialize. ... You will get this error if the *source* of the bitmap has been closed. ... if the bitmap was created from a stream and the stream was closed then you ...
      (microsoft.public.dotnet.framework.drawing)
    • Re: Serializing data set with de-normalized data
      ... You have very limited ability to affect the XML output and the only things ... array, you'll need to create each of those values and separate them with ... some delimmiter and ultimately treat them as one value. ... ComplexType and define your own effective Array, that should serialize ...
      (microsoft.public.dotnet.framework.adonet)
    • Re: silent semantic changes with reiser4
      ... how do you unpack on a traditional filesystem? ... tool to use to serialize it. ... > wacky file, you'd get a wacky file, where the main stream is the serialized ... the backup doesn't really care. ...
      (Linux-Kernel)