Re: [dev] Best way to serialize data

From: Dieter Plaetinck <dieter_AT_plaetinck.be>
Date: Mon, 6 Jun 2011 19:32:58 +0200

On Mon, 06 Jun 2011 19:19:56 +0200
Džen <yvldwt_AT_gmail.com> wrote:

> I was wondering about which way would be the easiest/simplest to
> serialize data, f.e. being read via a file or stdin (data being a
> table of x rows and y columns, each cell a string). I thought of
> using NULL bytes as cell delimiters and newline characters as row
> delimiters. This way it wouldn't be possible to use \0 nor \n
> inside the "cells", but I couldn't think of a simpler solution.
>
> Something like:
> a \0 b \0 c \n
> d \0 e \0 f \n
> ...
>
> What would you recommend? How'd you do it?
>
> Reason why I'm asking is because I was wondering how a dmenu-alike
> utility would read data, where each items has multiple values, not
> just one. Kinda like a search utility for table-structured data.
>

the alternative is using implicit boundaries (i.e. hardcoding field
lengths). you gain simplicity for the expense of space consumption.

you could look how databases like mysql, berkelydb or sqlite store
their tables on disk. these things are quite well thought-through.

Dieter
Received on Mon Jun 06 2011 - 19:32:58 CEST

This archive was generated by hypermail 2.2.0 : Mon Jun 06 2011 - 19:36:06 CEST