public class

Bytes

extends BSON
java.lang.Object
   ↳ org.bson.BSON
     ↳ com.mongodb.Bytes

Class Overview

Class that hold definitions of the wire protocol

Summary

Constants
int QUERYOPTION_AWAITDATA Use with TailableCursor.
int QUERYOPTION_EXHAUST Stream the data down full blast in multiple "more" packages, on the assumption that the client will fully read all data queried.
int QUERYOPTION_NOTIMEOUT The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use.
int QUERYOPTION_OPLOGREPLAY Internal replication use only - driver should not set
int QUERYOPTION_PARTIAL Use with sharding (mongos).
int QUERYOPTION_SLAVEOK When turned on, read queries will be directed to slave servers instead of the primary server.
int QUERYOPTION_TAILABLE Tailable means cursor is not closed when the last data is retrieved.
int RESULTFLAG_AWAITCAPABLE Set when the server supports the AwaitData Query option.
int RESULTFLAG_CURSORNOTFOUND Set when getMore is called but the cursor id is not valid at the server.
int RESULTFLAG_ERRSET Set when query failed.
int RESULTFLAG_SHARDCONFIGSTALE Drivers should ignore this.
[Expand]
Inherited Constants
From class org.bson.BSON
Fields
public static final ByteOrder ORDER Little-endian
[Expand]
Inherited Fields
From class org.bson.BSON
Public Constructors
Bytes()
Public Methods
static byte getType(Object o)
Gets the type byte for a given object.
[Expand]
Inherited Methods
From class org.bson.BSON
From class java.lang.Object

Constants

public static final int QUERYOPTION_AWAITDATA

Use with TailableCursor. If we are at the end of the data, block for a while rather than returning no data. After a timeout period, we do return as normal.

Constant Value: 32 (0x00000020)

public static final int QUERYOPTION_EXHAUST

Stream the data down full blast in multiple "more" packages, on the assumption that the client will fully read all data queried. Faster when you are pulling a lot of data and know you want to pull it all down. Note: the client is not allowed to not read all the data unless it closes the connection.

Constant Value: 64 (0x00000040)

public static final int QUERYOPTION_NOTIMEOUT

The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use. Set this option to prevent that.

Constant Value: 16 (0x00000010)

public static final int QUERYOPTION_OPLOGREPLAY

Internal replication use only - driver should not set

Constant Value: 8 (0x00000008)

public static final int QUERYOPTION_PARTIAL

Use with sharding (mongos). Allows partial results from a sharded system if any shards are down/missing from the cluster. If not used an error will be returned from the mongos server.

Constant Value: 128 (0x00000080)

public static final int QUERYOPTION_SLAVEOK

When turned on, read queries will be directed to slave servers instead of the primary server.

Constant Value: 4 (0x00000004)

public static final int QUERYOPTION_TAILABLE

Tailable means cursor is not closed when the last data is retrieved. Rather, the cursor marks the final object's position. You can resume using the cursor later, from where it was located, if more data were received. Like any "latent cursor", the cursor may become invalid at some point (CursorNotFound) – for example if the final object it references were deleted.

Constant Value: 2 (0x00000002)

public static final int RESULTFLAG_AWAITCAPABLE

Set when the server supports the AwaitData Query option. If it doesn't, a client should sleep a little between getMore's of a Tailable cursor. Mongod version 1.6 supports AwaitData and thus always sets AwaitCapable.

Constant Value: 8 (0x00000008)

public static final int RESULTFLAG_CURSORNOTFOUND

Set when getMore is called but the cursor id is not valid at the server. Returned with zero results.

Constant Value: 1 (0x00000001)

public static final int RESULTFLAG_ERRSET

Set when query failed. Results consist of one document containing an "$err" field describing the failure.

Constant Value: 2 (0x00000002)

public static final int RESULTFLAG_SHARDCONFIGSTALE

Drivers should ignore this. Only mongos will ever see this set, in which case, it needs to update config from the server.

Constant Value: 4 (0x00000004)

Fields

public static final ByteOrder ORDER

Little-endian

Public Constructors

public Bytes ()

Public Methods

public static byte getType (Object o)

Gets the type byte for a given object.

Parameters
o the object
Returns
  • the byte value associated with the type, or -1 if no type is matched