Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Apache Solr JavaBin format (binary format) implementation for Ruby
Ruby C
Branch: master
Failed to load latest commit information.
ext/java_bin/ext solr 3.1 support
lib release 0.4.3
test ruby 2.0.0 build on travis
.document Initial commit to java_bin.
LICENSE second commit
README.rdoc Update README.rdoc
java_bin.gemspec added rdoc to fix build on 1.8.7 and 1.9.2



This is an Apache Solr JavaBin format (binary format) implementation for Ruby.


  • fast parse(2.5 - 5 times faster than ruby eval), and less network traffic.

MRI 1.8.7
 ruby eval parse. 5000 times. elapsed time 6.664981
 javabin parse.   5000 times. elapsed time 1.472825
 4.52530409247534 times

REE 1.8.7
 ruby eval parse. 5000 times. elapsed time 4.844482
 javabin parse.   5000 times. elapsed time 1.059044
 4.57439162112245 times

YARV 1.9.2 pre1
 ruby eval parse. 5000 times. elapsed time 6.659331328
 javabin parse.   5000 times. elapsed time 1.261828473
 5.277525012704322 times
  • rsolr/solr-ruby support.

  • pure and c extension code.

  • ruby 1.8/1.9/2.0 support.

  • solr 1.4/3.1 support.


  • Ruby1.8.7 or later (include 1.9.x, 2.0.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, YARV 1.9.3 and 2.0.0 on CentOS6.3 (x86_64bit) with Apache Solr 1.4, 3.1


gem sources -a
gem install java_bin

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
gem install java_bin
cd (path to)\ext\java_bin\ext
ruby extconf.rb

Simple Usage

require 'rubygems'
require 'java_bin'

@parser =
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 :q => '*:*'

Valgrind/Memory Leaks

  • In this project we use Valgrind ( to ensure that the native extension is leak-free.

  • On any Debian-based Linux you simply need to install the valgrind package:

apt-get install valgrind
  • On homebrew-powered OSX, simply type:

brew install valgrind
  • Then invoke the Rake task. If any errors are present, it will fail.

rake valgrind


  • more parse speed

  • license

  • shared string over parsing

  • builder(writer)


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.


Toshinori Kajihara <>


Copyright © 2010 - 2013 kennyj. See LICENSE for details.

Something went wrong with that request. Please try again.