List of usage examples for com.mongodb DefaultDBEncoder FACTORY
DBEncoderFactory FACTORY
To view the source code for com.mongodb DefaultDBEncoder FACTORY.
Click Source Link
From source file:com.github.nlloyd.hornofmongo.MongoScope.java
License:Open Source License
public static Long bsonsize(Context cx, Scriptable thisObj, Object[] args, Function funObj) throws IOException { DBObject bsonObj = (DBObject) BSONizer.convertJStoBSON(args[0], true); Long size = new Long(0); if (bsonObj != null) { BasicOutputBuffer byteBuffer = new BasicOutputBuffer(); DefaultDBEncoder.FACTORY.create().writeObject(byteBuffer, bsonObj); ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); byteBuffer.pipe(byteStream);//from w w w . j a va 2 s . c o m size = new Long(byteStream.size()); } return size; }
From source file:net.vz.mongodb.jackson.internal.stream.JacksonEncoderFactory.java
License:Apache License
public DBEncoder create() { if (collection.isEnabled(JacksonDBCollection.Feature.USE_STREAM_SERIALIZATION)) { return new JacksonDBEncoder(objectMapper, DefaultDBEncoder.FACTORY.create()); } else {/*from w w w . ja v a2 s. c o m*/ return DefaultDBEncoder.FACTORY.create(); } }
From source file:nl.knaw.huygens.timbuctoo.storage.mongo.TreeEncoderFactory.java
License:Open Source License
@Override public DBEncoder create() { return new JacksonDBEncoder(objectMapper, DefaultDBEncoder.FACTORY.create()); }
From source file:org.jongo.bench.EncoderBench.java
License:Apache License
public void timeEncodeWithDriver(int reps) { for (int i = 0; i < reps; i++) { DBObject dbo = asDBObject(createFriend(i)); dbApiLayer.encode(DefaultDBEncoder.FACTORY, dbo); }//from w w w. j av a2 s . com }
From source file:org.jongo.bson.BsonDBEncoder.java
License:Apache License
public int writeObject(final OutputBuffer buf, BSONObject o) { if (!(o instanceof LazyDBObject)) { return DefaultDBEncoder.FACTORY.create().writeObject(buf, o); }//from www .j a v a 2 s.co m try { return ((LazyDBObject) o).pipe(buf); } catch (IOException e) { throw new MongoException("Exception serializing a LazyDBObject", e); } }
From source file:org.jongo.bson.BufferedBsonDocument.java
License:Apache License
private void encode(BSONObject dbo) { DBEncoder dbEncoder = DefaultDBEncoder.FACTORY.create(); dbEncoder.writeObject(buffer, dbo); }
From source file:org.jongo.stream.JacksonEncoderFactory.java
License:Apache License
public DBEncoder create() { return new JacksonDBEncoder(objectMapper, DefaultDBEncoder.FACTORY.create()); }