This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Making things better.

  • Loading branch information...
1 parent fe569b2 commit 7582b52c8c0152aa3b736d1520d87adc4bc176ef Joost Hietbrink committed with Burke Libbey Feb 3, 2010
Showing with 16 additions and 17 deletions.
  1. +12 −13 lib/indexer.rb
  2. +3 −3 mongosphinx.gemspec
  3. +1 −1 mongosphinx.rb
View
@@ -74,12 +74,6 @@ class XMLDocset
attr_reader :xml_footer
- # Makes sure the output if appearing on stdout and not buffered.
- def self.p(s)
- puts s
- $stdout.flush
- end
-
# Streams xml of all objects in a klass to the stdout. This makes sure you can process large collections.
#
# Options:
@@ -96,19 +90,24 @@ def self.p(s)
# xmlpipe_command = ./script/runner "MongoSphinx::Indexer::XMLDocset.stream(Document)"
#
def self.stream(klass, options = {})
+ STDOUT.sync = true # Make sure we really stream..
+
batch_size = options.delete(:batch_size) || 10000 # The number of documents in each batch process. Default is 10000.
max_offset = options.delete(:max_offset) || klass.count # The maximum offset. Default is klass.count.
- self.p '<?xml version="1.0" encoding="utf-8"?>'
+ puts '<?xml version="1.0" encoding="utf-8"?>'
- self.p '<sphinx:docset>'
+ puts '<sphinx:docset>'
# Schema
- self.p '<sphinx:schema>'
+ puts '<sphinx:schema>'
klass.fulltext_keys.each do |key, value|
- self.p "<sphinx:field name=\"#{key}\"/>"
+ puts "<sphinx:field name=\"#{key}\"/>"
end
- self.p '</sphinx:schema>'
+ # FIXME: What is this attribute?
+ puts '<sphinx:field name="classname"/>'
+ puts '<sphinx:attr name="csphinx-class" type="multi"/>'
+ puts '</sphinx:schema>'
# Content
offset = 0
@@ -117,11 +116,11 @@ def self.stream(klass, options = {})
offset = offset + batch_size
objects.each do |object|
- self.p XMLDoc.from_object(object)
+ puts XMLDoc.from_object(object)
end
end
- self.p '</sphinx:docset>'
+ puts '</sphinx:docset>'
end
# Creates a XMLDocset object from the provided data. It defines a
View
@@ -5,9 +5,9 @@ Gem::Specification.new do |spec|
spec.platform = "ruby"
spec.name = "mongosphinx"
spec.homepage = "http://github.com/burke/mongosphinx"
- spec.version = "0.1"
- spec.author = ["Burke Libbey", "Ryan Neufeld"]
- spec.email = ["burke@53cr.com", "ryan@53cr.com"]
+ spec.version = "0.1.2"
+ spec.authors = ["Burke Libbey", "Ryan Neufeld", "Joost Hietbrink"]
+ spec.email = ["burke@53cr.com", "ryan@53cr.com", "joost@joopp.com"]
spec.summary = "A full text indexing extension for MongoDB using Sphinx."
spec.files = ["README.rdoc", "mongosphinx.rb", "lib/multi_attribute.rb", "lib/mixins/properties.rb", "lib/mixins/indexer.rb", "lib/indexer.rb"]
spec.require_path = "."
View
@@ -7,7 +7,7 @@
begin
require 'rubygems'
rescue LoadError; end
-require 'mongomapper'
+require 'mongo_mapper'
require 'riddle'

0 comments on commit 7582b52

Please sign in to comment.