diodon-team team mailing list archive
Mailing list archive
XML vs SQL
> I believe that the XML is parsed and then loaded into memory, while
> sqlite database remains on disk (although there is an option to load
> the db into memory). What happens if our application quits
> unexpectedly? Do you simply go back to when the last time the XML
> file was written to disk? Do you end up losing all clipboard
> contents in the time between? Also, if the data is loaded to memory,
> do we need to be concerned about a large amount of data in the
> clipboard (esp. images) if the user has limited RAM?
Well, in our case the xml won't be larger than a couple of KBs, so the
performance and the usage of RAM won't be an issue.
The easiest thing not loose data is to store the xml straight away
on to the disk again, after a change has made. This can be done in a
separate thread so the user does not get interrupted.
> I know that the size limit of a blob in sqlite is 2mb. This may or
> may not be a problem. Does XML have a size limit?
The size limit is equal the limit of the size of one file of the file
system. So pretty huge ;), but such a file can only be read sequentially
> If using XML, would we have to code our own query method? Like
> another "for loop" that would have to iterate over all the items. Is
> it more efficient to have sqlite do the querying? Or does it not
> make a difference?
Well, when the application starts I would read all the needed
information into the memory and all user interactions will change that
memory data + changes will be persisted to the xml file.
> Maybe one thing that might help with this decision is to think
> through how are datastorage schema should be designed. The clipboard
> will handle three types of data: text, files, and Pixbufs. Since for
> files, we only need the path, our datastorage only needs types of
> data: text and pixbufs. So I suppose that some of the meta-data we
> will need to store with each item is which of the three types each
> data is: text proper, text file path, and pixbuf. I think this can
> all be done in one XML file or one SQL database table.
We only have to store information in the xml file which we need to show
Copying a file would just leave a reference to the file path in the xml
I would do the same with pixbufs. Such a pixbuf has to be stored to the
file system first and than be referenced in the xml file.
The size of the pixbuf will than only be copied to the memory, when the
user wants to copy it to the clipboard.