[darcs-users] index format

Eric Kow kowey at darcs.net
Tue Jun 9 08:54:18 UTC 2009


I thought I would post a follow-up and yet another question

On Mon, Jun 08, 2009 at 23:56:08 +0100, Eric Kow wrote:
> I do hope this goes in some sort of hashed-storage documentation, either
> in the repo or the wiki.

I noticed this morning that this has gone into your haddock, thanks!

Links for the interested
------------------------
Here are some pages that folks may be interested in

* http://wiki.darcs.net/hashed-storage - We could use this as our
  hashed-storage homepage for now.  I've tried to summarise the
  questions so far and the answers. Feel free to add more.

* http://repos.mornfall.net/hashed-storage/dist/doc/html/hashed-storage/ 
  Unstable API.  Thanks to Petr, these are rebuilt upon darcs push.

peekItem update
---------------
I realise this is really more for Petr to say, but since I'm posting an update
email, I might as well mention that I noticed this patch just now:

Tue Jun  9 08:02:02 BST 2009  Petr Rockai <me at mornfall.net>
  * Make peekItem safe even when dirlen is Nothing.

And the updated version of peekItem

peekItem :: ForeignPtr () -> Int -> Maybe Int -> IO Item
peekItem fp off dirlen =
    withForeignPtr fp $ \p -> do
      nl' :: Int32 <- peekByteOff p off
      let nl = fromIntegral nl'
          path = fromForeignPtr (castForeignPtr fp) (off + 4) (nl - 1)
          path_noslash = (BS.last path == '/') ? (BS.init path, path)
          hash = fromForeignPtr (castForeignPtr fp) (off + 4 + nl) 64
          name = snd $ case dirlen of
                         Just split -> BS.splitAt split path_noslash
                         Nothing -> BS.spanEnd (/= '/') path_noslash
      return $! Item { iName = name
                     , iPath = path
                     , iHash = hash
                     , iSize = plusPtr p (off + 4 + nl + 64)
                     , iAux = plusPtr p (off + 4 + nl + 64 + 8)
                     }

No more undefined! Thanks!

Yet another question
--------------------
Yes, it's about the index again, and no it's not that important to me.  So
we've established that the index uses a binary format so that we can load it in
faster.  Since the index is organised into "lines" (watch out, haddock things
your quote marks are links), how about making the lines textual lines by using
a newline to separate them?

The trick here is that we're still using a binary format, reading and writing
to it in a rigid non-parsy way.  It's just that we systematically end each
entry with a byte that coincidentally renders in people's terminals a nice way.

I was thinking that something like this might reduce the opacity of the index
somehow.  Not that anybody should be mucking around in it, but I can imagine
that on the off chance that something goes wrong, maybe just the slight
improvement in ease of visual inspection (not to mention grepping) will pay off
in the future?

Any use for this sort of faux-text idea?

Thanks!

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.osuosl.org/pipermail/darcs-users/attachments/20090609/54c6c6f0/attachment.pgp>


More information about the darcs-users mailing list