Skip to content

Commit

Permalink
Slightly less safe; a whole lot faster
Browse files Browse the repository at this point in the history
  • Loading branch information
billdueber committed Sep 16, 2010
1 parent 969e39a commit 99cf37c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
5 changes: 5 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ Note that you can use threach to multi-thread it all.

=== CHANGES

0.5.0 (2010.09.16)
* Removed a begin/rescue/end block that had been looking for simple argumenterrors for logging; speedup is
tremendous.
* No longer allow "array-like" in #add; only allow actual Arrays. Again, speedup.

0.4.1 (2010.09.07)
* Updated documentation
* Added access to document-level boost via #boost and #boost=
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.1
0.5.0
21 changes: 7 additions & 14 deletions lib/jruby_streaming_update_solr_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,23 +165,18 @@ def fieldBoost field

# Add a value to a field. Will add all elements of an array in turn
# @param [String] field The field to add a value or values to
# @param [String, Numeric, #each] val The value or array-like of values to add.
# @param [String, Numeric, Array] val The value or array of values to add.
# @param [Float] boost The boost for this field
# @return [Array<String,Numeric>] An array of the field's values after this addition
# @return [Undefined]

def add(field, val, boost=nil)
return if val == nil
if val.is_a? String or val.is_a? Numeric
self.addField(field, val)
if val.is_a? Array
val.each {|v| self.add(field, v)}
else
begin
val.each {|v| self.add(field, v)}
rescue NoMethodError => e
raise NoMethodError, "SolrInputDocument values must be a string, numeric, or an array-like (responds to #each) of same, not #{val.inspect}"
end
self.addField(field, val)
end
self.boost = boost if boost
return self[field]
end


Expand All @@ -197,9 +192,7 @@ def add(field, val, boost=nil)
# doc << ['author', ['Bill', 'Mike', 'Molly']] #=> ['Bill', 'Mike', 'Molly']

def << fv
field = fv[0]
value = fv[1]
self.add(field, value)
self.add(fv[0], fv[1])
end

# Get a list of the currently-set values for the passed field
Expand All @@ -221,7 +214,7 @@ def [] field
#
# @param [String] field The solr field you're setting the value of
# @param [String, Array<String>] value The value or array of values to set
# @return [Array<String>] The list of values (i.e., either +value+ or +[value]+)
# @return [Undefined]
#
# @example
# doc = SolrInputDocument.new
Expand Down

0 comments on commit 99cf37c

Please sign in to comment.