PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > Marshaled data ordering inconsistent
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Marshaled data ordering inconsistent

Réponse
 
LinkBack Outils de la discussion
Vieux 20/11/2007, 10h07   #1
mla mla
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Marshaled data ordering inconsistent

It seems that when you marshal hashes the binary representations aren't
stable.

This is an issue with PStore because it uses the md5 of the marshaled
data to decide whether it's changed and whether a disk write is needed.

Perl's serialization module, Storable, has a $Storable::canonical option
which, if true, sorts the keys of hashes. Would it be reasonable to add
such an option to Marshal?

I read that Ruby 1.9 will have ordered hashes. So maybe that will make
the issue moot?

Script that illustrates the issue:
http://mla.homeunix.com/tmp/marshal-test.rb

Output that I see:
http://mla.homeunix.com/tmp/marshal-test.txt

ruby 1.8.6 (2007-11-18 patchlevel 5000) [i686-linux]
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 20/11/2007, 12h38   #2
Robert Klemme
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Marshaled data ordering inconsistent

2007/11/20, mla mla <maurice.aubrey@gmail.com>:
> It seems that when you marshal hashes the binary representations aren't
> stable.
>
> This is an issue with PStore because it uses the md5 of the marshaled
> data to decide whether it's changed and whether a disk write is needed.
>
> Perl's serialization module, Storable, has a $Storable::canonical option
> which, if true, sorts the keys of hashes. Would it be reasonable to add
> such an option to Marshal?


Sounds good to me. What happens if keys are not sortable? Fallback
to default, i.e. store unsorted?

> I read that Ruby 1.9 will have ordered hashes. So maybe that will make
> the issue moot?


Probably not because not all applications need ordered Hashes.
Usually ordering imposes an overhead that you might not want to pay.
So I'd say even in 1.9 this issue is not (fully) gone.

Kind regards

robert

--
use.inject do |as, often| as.you_can - without end

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 00h22.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09506 seconds with 10 queries