java_bin
This is an Apache Solr JavaBin format (binary format) implementation for Ruby.
Features
-
fast parse(2.5 - 5 times faster than ruby eval), and less network traffic.
MRI 1.8.7
[data1]
ruby eval parse. 5000 times. elapsed time 1.282744
javabin parse. 5000 times. elapsed time 0.4634
2.76811394044022 times
[data2]
ruby2 eval parse. 5000 times. elapsed time 6.568942
javabin2 parse. 5000 times. elapsed time 2.267351
2.89718795193157 times
REE 1.8.7
[data1]
ruby eval parse. 5000 times. elapsed time 0.940934
javabin parse. 5000 times. elapsed time 0.310581
3.02959292422911 times
[data2]
ruby2 eval parse. 5000 times. elapsed time 4.708985
javabin2 parse. 5000 times. elapsed time 1.482276
3.176861124379 times
YARV 1.9.2
[data1]
ruby eval parse. 5000 times. elapsed time 1.348342119
javabin parse. 5000 times. elapsed time 0.367371147
3.6702450097421506 times
[data2]
ruby2 eval parse. 5000 times. elapsed time 6.486995777
javabin2 parse. 5000 times. elapsed time 1.73077786
3.748023317677521 times
-
rsolr/solr-ruby support.
-
pure and c extension code.
-
ruby 1.8/1.9 support.
Requirements
-
Ruby1.8.7 or later (include 1.9.x)
-
(recommended) C compiler (gcc or vc++): you can also use java_bin without c extension, but ‘pure’ is 30 times slower than ‘ext’.
-
JavaBin has been tested with MRI 1.8.7, REE 1.8.7, YARV 1.9.2 pre1 on Ubuntu Linux 9.10 (32bit) and MRI 1.8.6 on Windows Vista (32bit), and Apache Solr 1.4
Install
(Linux)
gem sources -a http://gemcutter.org
gem install java_bin
(Windows)
fix (path to)\ruby\lib\ruby\1.8\i386-mswin32\config.h
#if _MSC_VER != 1200
↓
#if _MSC_VER < 1200
start => visual studio c++ 200x xxxx edition => visual studio tools => visual studio 200x command prompt
gem sources -a http://gemcutter.org
gem install java_bin
or
cd (path to)\ext\java_bin\ext
ruby extconf.rb
nmake
Simple Usage
require 'rubygems'
require 'java_bin'
@parser = JavaBin.parser.new
result = @parser.parse( javabin format string )
With RSolr/Solr-Ruby
-
By RSolr/Solr-Ruby support, a parser automatically uses javabin format instead of ruby format.
require 'rubygems'
require 'rsolr'
require 'java_bin'
solr = RSolr.connect
solr.select :q => '*:*'
TODO
-
more parse speed
-
license
-
pure parse encoding bug (1.9.x)
-
shared string over parsing
-
windows build(1.9.x)
-
64bit build
-
builder(writer)作成
-
JRuby support
References
-
javabin wiki.apache.org/solr/javabin
-
javabin codec (for java) svn.apache.org/viewvc/lucene/solr/trunk/src/common/org/apache/solr/common/util/JavaBinCodec.java?view=markup
-
rsolr github.com/mwmitchell/rsolr/
-
solr-ruby wiki.apache.org/solr/solr-ruby
Note on Patches/Pull Requests
-
Fork the project.
-
Make your feature addition or bug fix.
-
Add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-
Send me a pull request. Bonus points for topic branches.
Author
Toshinori Kajihara <[email protected]>
Copyright
Copyright © 2010 kennyj. See LICENSE for details.