JavaBinCodec (Solr 3.6.2 API)
Keywords: org.apache.solr.common.util.JavaBinCodec class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.solr.common.util
Class JavaBinCodec

    java.lang.Object
      org.apache.solr.common.util.JavaBinCodec

Direct Known Subclasses:
  NamedListCodec

    public class JavaBinCodec

extends Object

The class is designed to optimaly serialize/deserialize any supported types in Solr response. As we know there are only a limited type of items this class can do it with very minimal amount of payload and code. There are 15 known types and if there is an object in the object tree which does not fall into these types, It must be converted to one of these. Implement an ObjectResolver and pass it over It is expected that this class is used on both end of the pipes. The class has one read method and one write method for each of the datatypes

Note -- Never re-use an instance of this class for more than one marshal or unmarshall operation. Always create a new instance.

Nested Class Summary
`static interface` | `JavaBinCodec.ObjectResolver`

Field Summary
`static byte` | `ARR`
`static byte` | `BOOL_FALSE`
`static byte` | `BOOL_TRUE`
`static byte` | `BYTE`
`static byte` | `BYTEARR`
`protected FastOutputStream` | `daos`
`static byte` | `DATE`
`static byte` | `DOUBLE`
`static byte` | `END`
`protected static Object` | `END_OBJ`
`static byte` | `EXTERN_STRING`
`static byte` | `FLOAT`
`static byte` | `INT`
`static byte` | `ITERATOR`
`static byte` | `LONG`
`static byte` | `MAP`
`static byte` | `NAMED_LST`
`static byte` | `NULL`
`static byte` | `ORDERED_MAP`
`static byte` | `SHORT`
`static byte` | `SINT`
`static byte` | `SLONG`
`static byte` | `SOLRDOC`
`static byte` | `SOLRDOCLST`
`static byte` | `STR`
`static byte` | `TAG_AND_LEN`

Constructor Summary
`JavaBinCodec()`
`JavaBinCodec(JavaBinCodec.ObjectResolver resolver)`

Method Summary
`void` | `marshal(Object nl, OutputStream os)`
`List` | `readArray(FastInputStream dis)`
`byte[]` | `readByteArray(FastInputStream dis)`
`String` | `readExternString(FastInputStream fis)`
`List` | `readIterator(FastInputStream fis)`
`Map` | `readMap(FastInputStream dis)`
`NamedList` | `readNamedList(FastInputStream dis)`
`SimpleOrderedMap` | `readOrderedMap(FastInputStream dis)`
`int` | `readSize(FastInputStream in)`
`int` | `readSmallInt(FastInputStream dis)`
`long` | `readSmallLong(FastInputStream dis)`
`SolrDocument` | `readSolrDocument(FastInputStream dis)`
`SolrDocumentList` | `readSolrDocumentList(FastInputStream dis)`
`String` | `readStr(FastInputStream dis)`
`Object` | `readVal(FastInputStream dis)`
`static int` | `readVInt(FastInputStream in)` The counterpart for the above
`static long` | `readVLong(FastInputStream in)`
`Object` | `unmarshal(InputStream is)`
`void` | `writeArray(Collection coll)`
`void` | `writeArray(List l)`
`void` | `writeArray(Object[] arr)`
`void` | `writeByteArray(byte[] arr, int offset, int len)`
`void` | `writeExternString(String s)`
`void` | `writeInt(int val)`
`void` | `writeIterator(Iterator iter)`
`boolean` | `writeKnownType(Object val)`
`void` | `writeLong(long val)`
`void` | `writeMap(Map val)`
`void` | `writeNamedList(NamedList nl)`
`boolean` | `writePrimitive(Object val)`
`void` | `writeSolrDocument(SolrDocument doc)`
`void` | `writeSolrDocument(SolrDocument doc, Set<String> fields)`
`void` | `writeSolrDocumentList(SolrDocumentList docs)`
`void` | `writeStr(String s)` write the string as tag+length, with length being the number of UTF-8 bytes
`void` | `writeTag(byte tag)`
`void` | `writeTag(byte tag, int size)`
`void` | `writeVal(Object val)`
`static void` | `writeVInt(int i, FastOutputStream out)` Special method for variable length int (copied from lucene).
`static void` | `writeVLong(long i, FastOutputStream out)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### NULL

    public static final byte NULL

See Also:
  Constant Field Values

### BOOL_TRUE

    public static final byte BOOL_TRUE

See Also:
  Constant Field Values

### BOOL_FALSE

    public static final byte BOOL_FALSE

See Also:
  Constant Field Values

### BYTE

    public static final byte BYTE

See Also:
  Constant Field Values

### SHORT

    public static final byte SHORT

See Also:
  Constant Field Values

### DOUBLE

    public static final byte DOUBLE

See Also:
  Constant Field Values

### INT

    public static final byte INT

See Also:
  Constant Field Values

### LONG

    public static final byte LONG

See Also:
  Constant Field Values

### FLOAT

    public static final byte FLOAT

See Also:
  Constant Field Values

### DATE

    public static final byte DATE

See Also:
  Constant Field Values

### MAP

    public static final byte MAP

See Also:
  Constant Field Values

### SOLRDOC

    public static final byte SOLRDOC

See Also:
  Constant Field Values

### SOLRDOCLST

    public static final byte SOLRDOCLST

See Also:
  Constant Field Values

### BYTEARR

    public static final byte BYTEARR

See Also:
  Constant Field Values

### ITERATOR

    public static final byte ITERATOR

See Also:
  Constant Field Values

### END

    public static final byte END

See Also:
  Constant Field Values

### TAG_AND_LEN

    public static final byte TAG_AND_LEN

See Also:
  Constant Field Values

### STR

    public static final byte STR

See Also:
  Constant Field Values

### SINT

    public static final byte SINT

See Also:
  Constant Field Values

### SLONG

    public static final byte SLONG

See Also:
  Constant Field Values

### ARR

    public static final byte ARR

See Also:
  Constant Field Values

### ORDERED_MAP

    public static final byte ORDERED_MAP

See Also:
  Constant Field Values

### NAMED_LST

    public static final byte NAMED_LST

See Also:
  Constant Field Values

### EXTERN_STRING

    public static final byte EXTERN_STRING

See Also:
  Constant Field Values

### daos

    protected FastOutputStream daos

### END_OBJ

    protected static final Object END_OBJ

Constructor Detail

### JavaBinCodec

    public JavaBinCodec()

### JavaBinCodec

    public JavaBinCodec(JavaBinCodec.ObjectResolver resolver)

Method Detail

### marshal

    public void marshal(Object nl,
                        OutputStream os)
                 throws IOException

  Throws:
    `IOException`

### unmarshal

    public Object unmarshal(InputStream is)
                     throws IOException

  Throws:
    `IOException`

### readOrderedMap

    public SimpleOrderedMap readOrderedMap(FastInputStream dis)
                                    throws IOException

  Throws:
    `IOException`

### readNamedList

    public NamedList readNamedList(FastInputStream dis)
                            throws IOException

  Throws:
    `IOException`

### writeNamedList

    public void writeNamedList(NamedList nl)
                        throws IOException

  Throws:
    `IOException`

### writeVal

    public void writeVal(Object val)
                  throws IOException

  Throws:
    `IOException`

### readVal

    public Object readVal(FastInputStream dis)
                   throws IOException

  Throws:
    `IOException`

### writeKnownType

    public boolean writeKnownType(Object val)
                           throws IOException

  Throws:
    `IOException`

### writeTag

    public void writeTag(byte tag)
                  throws IOException

  Throws:
    `IOException`

### writeTag

    public void writeTag(byte tag,
                         int size)
                  throws IOException

  Throws:
    `IOException`

### writeByteArray

    public void writeByteArray(byte[] arr,
                               int offset,
                               int len)
                        throws IOException

  Throws:
    `IOException`

### readByteArray

    public byte[] readByteArray(FastInputStream dis)
                         throws IOException

  Throws:
    `IOException`

### writeSolrDocument

    public void writeSolrDocument(SolrDocument doc)
                           throws IOException

  Throws:
    `IOException`

### writeSolrDocument

    public void writeSolrDocument(SolrDocument doc,
                                  Set<String> fields)
                           throws IOException

  Throws:
    `IOException`

### readSolrDocument

    public SolrDocument readSolrDocument(FastInputStream dis)
                                  throws IOException

  Throws:
    `IOException`

### readSolrDocumentList

    public SolrDocumentList readSolrDocumentList(FastInputStream dis)
                                          throws IOException

  Throws:
    `IOException`

### writeSolrDocumentList

    public void writeSolrDocumentList(SolrDocumentList docs)
                               throws IOException

  Throws:
    `IOException`

### readMap

    public Map readMap(FastInputStream dis)
                throws IOException

  Throws:
    `IOException`

### writeIterator

    public void writeIterator(Iterator iter)
                       throws IOException

  Throws:
    `IOException`

### readIterator

    public List readIterator(FastInputStream fis)
                      throws IOException

  Throws:
    `IOException`

### writeArray

    public void writeArray(List l)
                    throws IOException

  Throws:
    `IOException`

### writeArray

    public void writeArray(Collection coll)
                    throws IOException

  Throws:
    `IOException`

### writeArray

    public void writeArray(Object[] arr)
                    throws IOException

  Throws:
    `IOException`

### readArray

    public List readArray(FastInputStream dis)
                   throws IOException

  Throws:
    `IOException`

### writeStr

    public void writeStr(String s)
                  throws IOException

  write the string as tag+length, with length being the number of UTF-8 bytes

  Throws:
    `IOException`

### readStr

    public String readStr(FastInputStream dis)
                   throws IOException

  Throws:
    `IOException`

### writeInt

    public void writeInt(int val)
                  throws IOException

  Throws:
    `IOException`

### readSmallInt

    public int readSmallInt(FastInputStream dis)
                     throws IOException

  Throws:
    `IOException`

### writeLong

    public void writeLong(long val)
                   throws IOException

  Throws:
    `IOException`

### readSmallLong

    public long readSmallLong(FastInputStream dis)
                       throws IOException

  Throws:
    `IOException`

### writePrimitive

    public boolean writePrimitive(Object val)
                           throws IOException

  Throws:
    `IOException`

### writeMap

    public void writeMap(Map val)
                  throws IOException

  Throws:
    `IOException`

### readSize

    public int readSize(FastInputStream in)
                 throws IOException

  Throws:
    `IOException`

### writeVInt

    public static void writeVInt(int i,
                                 FastOutputStream out)
                          throws IOException

  Special method for variable length int (copied from lucene). Usually used for writing the length of a collection/array/map In most of the cases the length can be represented in one byte (length < 127) so it saves 3 bytes/object

  Parameters:
    `i` -
    `out` -
  Throws:
    `IOException`

### readVInt

    public static int readVInt(FastInputStream in)
                        throws IOException

  The counterpart for the above

  Parameters:
    `in` -
  Returns:
    the int value
  Throws:
    `IOException`

### writeVLong

    public static void writeVLong(long i,
                                  FastOutputStream out)
                           throws IOException

  Throws:
    `IOException`

### readVLong

    public static long readVLong(FastInputStream in)
                          throws IOException

  Throws:
    `IOException`

### writeExternString

    public void writeExternString(String s)
                           throws IOException

  Throws:
    `IOException`

### readExternString

    public String readExternString(FastInputStream fis)
                            throws IOException

  Throws:
    `IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD