com.mongodb.Bytes Java Examples
The following examples show how to use
com.mongodb.Bytes.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Tailer.java From zerowing with MIT License | 6 votes |
private DBCursor createCursor() { DBCollection oplog = _mongo.getDB("local").getCollection("oplog.rs"); BSONTimestamp startingTimestamp = getStartingTimestamp(); DBCursor cursor; if (startingTimestamp == null) { log.info("Tailing the oplog from the beginning..."); cursor = oplog.find(); } else { log.info("Tailing the oplog from " + startingTimestamp); BasicDBObject query = new BasicDBObject("ts", new BasicDBObject("$gt", startingTimestamp)); cursor = oplog.find(query); cursor.addOption(Bytes.QUERYOPTION_OPLOGREPLAY); } cursor.addOption(Bytes.QUERYOPTION_NOTIMEOUT); cursor.addOption(Bytes.QUERYOPTION_TAILABLE); cursor.addOption(Bytes.QUERYOPTION_AWAITDATA); return cursor; }
Example #2
Source File: MongoCollectionReader.java From bluima with Apache License 2.0 | 5 votes |
protected void initQuery(MongoConnection conn) throws IOException { if (query != null) cur = conn.coll.find((DBObject) JSON.parse(query)); else cur = conn.coll.find(); cur.addOption(Bytes.QUERYOPTION_NOTIMEOUT).batchSize(1000); }
Example #3
Source File: MDbMetaData.java From birt with Eclipse Public License 1.0 | 4 votes |
private void addDataType( Object fieldValue ) { // add the data type of given fieldValue to existing set, if exists; // the same named field set in a different doc may have a different data type byte nativeBSonDataTypeCode = Bytes.getType( fieldValue ); if( m_nativeDataTypes == null ) m_nativeDataTypes = new HashSet<Integer>(2); if ( nativeBSonDataTypeCode == -1 ) { if ( fieldValue instanceof Document ) { nativeBSonDataTypeCode = Bytes.OBJECT; } } m_nativeDataTypes.add( Integer.valueOf( nativeBSonDataTypeCode ) ); // check if field value contains a document, // iteratively get field document's nested metadata if( nativeBSonDataTypeCode == BSON.ARRAY ) { if( fieldValue instanceof java.util.List ) { java.util.List<?> listOfObjects = (java.util.List<?>)fieldValue; if( listOfObjects.size() > 0 ) { // use first element in array to determine metadata addDataType( listOfObjects.get(0) ); // handles nested arrays return; } } } Object fieldObjValue = ResultDataHandler.fetchFieldDocument( fieldValue, nativeBSonDataTypeCode ); if( fieldObjValue != null ) // contains nested document { if( m_childDocMetaData == null ) m_childDocMetaData = sm_factory.new DocumentsMetaData(); m_childDocMetaData.addDocumentMetaData( fieldObjValue, this ); } }