You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2009/06/22 07:17:18 UTC
[Solr Wiki] Update of "javabin" by NoblePaul
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.
The following page has been changed by NoblePaul:
http://wiki.apache.org/solr/javabin
------------------------------------------------------------------------------
javabin is a custom binary format used to write out solr's response in a [https://issues.apache.org/jira/browse/SOLR-486?focusedCommentId=12588875#action_12588875 fast and efficient] manner. [http://issues.apache.org/jira/browse/SOLR-486 SOLR-486] is the jira issue .
Currently only a [http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/common/util/NamedListCodec.java?revision=685640&view=markup 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.
-
+ [[TableOfContents]]
== Supported Types ==
It supports all the data types needed in Solr Response
* null
@@ -24, +24 @@
* org.apache.solr.common.util.!NamedList
* org.apache.solr.common.util.!SimpleOrderedMap
* Object[] (items must be of any known type)
+
+ == 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.
+
----