V
V
Vitaly2017-07-17 20:16:26
Qt
Vitaly, 2017-07-17 20:16:26

Data formats for text and attachments?

Hello.
The program on Qt, there is a form with textual, numerical data and dates, as well as the ability to upload attachments. Text (and other) fields under a hundred. Attachment up to 500 mb and the total number is not limited. At the moment of development, only text data is stored in the form of Binary JSON (Qt's internal format). Thinking about how to save attachments while maintaining efficient access to text data (while saving changes).
At the moment, I'm thinking of creating two files - the first is actually JSON with text and "links" to attachments. "Link" is the usual offset from the second file. The second file is essentially just a "dump" of all attachments with a known offset (2 bytes for the identifier, 4 bytes for the length, the content itself and repetition for the next file).
If you write a structure with text and then a structure with attachments to a file, then when you increase the text, the next time you save it, you will have to create a new file and write all the attachments from the old one into it (if there are 10 attachments of 300 mb each, then reading from one to another, followed by deleting the first doesn't look very smart/efficient).
If you write a structure with attachments first, and then a structure with text, there will be no rewriting of large volumes when the text changes, and at the time of writing the data structure, all attachment offsets will be known, but when one attachment is deleted, it will still be overwritten.
What is the best practice for such cases? I'm still relatively new to C++ and I don't know much about file formats.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ananiev, 2017-07-18
@SaNNy32

IMHO, in such cases it is better to use a database, for example, the same sqlite .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question