Skip to content

Instantly share code, notes, and snippets.

@rwc9u
Created February 18, 2011 15:11
Show Gist options
  • Save rwc9u/833792 to your computer and use it in GitHub Desktop.
Save rwc9u/833792 to your computer and use it in GitHub Desktop.
ruby-1.9.2-p136 :001 > j = Job.last
ruby-1.9.2-p136 :002 > j.file_data.file.gridio.class
=> Mongo::GridIO
ruby-1.9.2-p136 :003 > CSV.new(j.file_data.file.gridio)
NoMethodError: undefined method `pos' for #<GridIO _id: 4d5cbe235ef0dbcaf2000001>
from /Users/rchristie/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/csv.rb:2011:in `init_separators'
from /Users/rchristie/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/csv.rb:1570:in `initialize'
from (irb):3:in `new'
from (irb):3
from /Users/rchristie/dev/cast/vendor/ruby/1.9.1/gems/railties-3.0.4/lib/rails/commands/console.rb:44:in `start'
from /Users/rchristie/dev/cast/vendor/ruby/1.9.1/gems/railties-3.0.4/lib/rails/commands/console.rb:8:in `start'
from /Users/rchristie/dev/cast/vendor/ruby/1.9.1/gems/railties-3.0.4/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
ruby-1.9.2-p136 :004 >
# It looks like the deprecated API, GridStore, used to support the methods like eof?, pos, and rewind so that I could
# essentially stream the file from Mongo into some consumer of that stream. I haven't tried going back to the older
# version of the driver or implementing the needed methods yet. I was just trying to find some background on why
# that API was deprecated.
@banker
Copy link

banker commented Feb 19, 2011

GridStore was deprecated because of certain strange semantics and incompatibility with the core GridFS API implemented by the current Grid class.

You should be able to used GridIO#read to stream an object. I'd be happy to add any other methods you need (like eof?). You can file a JIRA with what you need or submit a pull request.

@banker
Copy link

banker commented Feb 20, 2011

Just created an issue for tracking:
http://jira.mongodb.org/browse/RUBY-240

@rwc9u
Copy link
Author

rwc9u commented Feb 20, 2011

Thanks. I'll put submit a pull request for the others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment