javabin is a custom binary format used to write out solr's response in a fast and efficient manner. SOLR-486 is the jira issue .

Currently only a java library is available to write/read this format . This is the default format used by SolrJ and this is the format used for inter-Solr communication in distributed search. Use wt=javabin in request parameter to get the output in this format.

Supported Types

It supports all the data types needed in Solr Response

How to marshal/unmarshal

//example 
Map m= new HashMap();
m.put("hello", "world");
OutputStream os = new ByteArrayOutputStream();
new JavaBinCodec().marshal(m,os);

bytes b = ((ByteArrayOutputStream)os).toByteArray()

//now read the Object back
InputStream is =new ByteArrayInputStream(b);
Map m1 = new JavaBinCodec().unmarshal(is);

How do I write any custom types ?

Any custom Object has to be first converted to one of the supported types then marshal it.

Versions

As of Solr 3.1, the JavaBin format has changed to version 2.

Version 2 serializes strings differently: instead of writing the number of UTF-16 characters followed by the bytes in Modified UTF-8 it writes the number of UTF-8 bytes followed by the bytes in UTF-8.

When upgrading from Solr 1.4, if you are using the JavaBin format, you will need to ensure that you also upgrade your SolrJ client.

See the SOLR-2034 jira issue for more information.


CategoryQueryResponseWriter

javabin (last edited 2010-08-27 15:57:57 by RobertMuir)