Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the use of Marshal necessary? #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sgonyea
Copy link

@sgonyea sgonyea commented Mar 4, 2011

Hi, I was implementing some storage backends and saw the use of Marshal in Page#to_hash and Page#from_hash ...

  1. I don't actually see @DaTa used anywhere. Does it actually see any use?
  2. @headers are Hash data, so it seems like it should just stay in that format. Serialization would best, imo, be done by calling Hash#to_json ... And to do so inside the backend.
  3. OpenStruct can be created with a hash and when you call OpenStruct#marshal_dump, it spits out a hash. Which, again, can be serialized into JSON by the backend.

I'm looking to implement the backends for: Riak, RiakSearch, Solr, and Amazon's S3.

I'd also like to look into putting anemone onto resque / redis, for work distribution. I've recently become unhappy with Nutch+Hadoop for crawling, so I'd like to see how far I can scale anemone.

@sgonyea
Copy link
Author

sgonyea commented Mar 4, 2011

I need to make some other changes for something like this to work, so if you decide to drop the use of Marshal-ing, I can adjust the other libraries and add to this pull request. Lots of specs fail for me on the original library (ie, without my changes). I don't even know why I'm getting the below issue, which (to me) just reinforces "don't use Marshal".

    TypeError in 'Anemone::Storage::Redis should implement merge!, and return self'
    incompatible marshal file format (can't be read)
        format version 4.8 required; 99.111 given
    /Users/sgonyea/Sites/emone/lib/anemone/page.rb:185:in `load'
    /Users/sgonyea/Sites/emone/lib/anemone/page.rb:185:in `from_hash'
    /Users/sgonyea/Sites/emone/lib/anemone/storage/redis.rb:78:in `load_value'
    /Users/sgonyea/Sites/emone/lib/anemone/storage/redis.rb:84:in `rget'
    /Users/sgonyea/Sites/emone/lib/anemone/storage/redis.rb:41:in `block in each'
    /Users/sgonyea/Sites/emone/lib/anemone/storage/redis.rb:40:in `each'
    /Users/sgonyea/Sites/emone/lib/anemone/storage/redis.rb:40:in `each'
    /Users/sgonyea/Sites/emone/lib/anemone/storage/redis.rb:57:in `keys'
    /Users/sgonyea/Sites/emone/lib/anemone/storage/redis.rb:12:in `initialize'
    /Users/sgonyea/Sites/emone/lib/anemone/storage.rb:30:in `new'
    /Users/sgonyea/Sites/emone/lib/anemone/storage.rb:30:in `Redis'
    spec/storage_spec.rb:162:in `block (2 levels) in <module:Storage>'

@sgonyea
Copy link
Author

sgonyea commented Mar 4, 2011

and in both ruby-18 and ruby-19, I get:

129 examples, 32 failures

With the specs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant