MongoDB öw.objectid maid? £%%%%%%%%%%%%%%%%%%%%%%%%» %%%%%%%%%%%%%%%%%%%%%%%â

Source: Internet
Author: User

MongoDB öw.objectid maid? £%%%%%%%%%%%%%%%%%%%%%%%%» %%%%%%%%%%%%%%%%%%%%%%%â

Ü ürúmámámöó mámímámímámámímámímámāmāmāmāmāmāmāmāmāmāmāmāmāmāmāmāmāmāmla when» µ µáð Ê â  £%%äöö %%%%» 2 when?

Mahathíá ~~â ObjectId £°

TimeStamp <symbol · blank "http://www.bkjia.com/kf/ware/vc/" target = "_ blank" class = "keylink"> cipher/cipher + 8PHsLLXsMquwfm9 + cipher + vqvIt7W9w + cipher = "1970-01-01 UTC 1307761900 sec '-u
Machine
Ó Ï Â À 'microäè ¸ ö×ö~ú£;*í Ê ç2cdcd2, ~â â ~~ö×ö~úçor?~~~~úö~» úzä~~~~» ± ~~~~~~~~~~~~~~~~~~~~~~~~~~~» ° ~~~ço» úzomantögou» úzomámámámámámémémémémémémémémémémémémémémémémémémémémémémémémé éúanté²» í~µä» ú~~~hash öµ£;è? ± £;úö² ~~~~ö~²» {****************************** guí» £***â **************************************************************** · comment '{***************************************
PidÉ Ï Ã µ µämachine Ç ç» £;*ø pid *í ***************************************************************** áë objectid ²» ³ å Í» ££ Ó Ï Â 'µä2018ὠλ Í Ê ç² úéúobjectid µä½ ø ³ ± why?
IncrementÇ° ~~~µä~~ö×ö~ú~ç± £ö~á~~» ~~äú²» í~» ú~~~i²» í ~~ ½ ø ³ éúé objectid ²» ³ å Í» £» ö ö× ö ¯ ö ö¼ ózä¼ Æ Ê £? éúµäobjectid ²» á~~ö~~~í» £;***í 256 µä3 '{· {µáúo 16777216} Ç çâ ********************************************************************
Â Ò Ð òMaid
Â Ò Ð òMaid
Query query = new Query (); if (id! = Null) {query. addCriteria (Criteria. where ("_ id "). gt (id);} query. with (new Sort (Sort. direction. ASC, "_ id "));
Comparator <DBObject> comparator = new Comparator <DBObject> () {@ Overridepublic int compare (DBObject o1, DBObject o2) {return (ObjectId) o1.get ("_ id ")). compareTo (ObjectId) o2.get ("_ id") ;}}; PriorityQueue <DBObject> queue = new PriorityQueue <DBObject> (200, comparator );Ó óço ?þ ¢ ¶ à cií» § ¶ Ë ¸ ²? please refer to the following statements for £\%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ¨ ä ä¸ ô Ò» à ë É é£ £. £ â  n Ç çó À Ô ²» áö öö öâ Ò µ µä çé omö£.

Protected WriteResult insert (List <DBObject> list, boolean shouldApply, com. mongodb. writeConcern concern, DBEncoder encoder) {if (encoder = null) encoder = DefaultDBEncoder. FACTORY. create (); if (willTrace () {for (DBObject o: list) {trace ("save:" + _ fullNameSpace + "" + JSON. serialize (o) ;}}if (shouldApply) {for (DBObject o: list) {apply (o); _ checkObject (o, false, false ); object id = o. get ("_ id"); if (id instanceof ObjectId) {(ObjectId) id ). notNew () ;}} WriteResult last = null; int cur = 0; int maxsize = _ mongo. getMaxBsonObjectSize (); while (cur <list. size () {OutMessage om = OutMessage. insert (this, encoder, concern); for (; cur <list. size (); cur ++) {DBObject o = list. get (cur); om. putObject (o); // limit for batch insert is 4 x maxbson on server, use 2 x to be safe if (om. size ()> 2 * maxsize) {cur ++; break ;}} last = _ connector. say (_ db, om, concern);} return last ;}×{*****Óobjectid µä² **********************************************************
/*** Cballs {@ link DBCollection # apply (com. mongodb. DBObject, boolean )} with ensureID = true * @ param o <code> DBObject </code> to which to add fields * @ return the modified parameter object */public Object apply (DBObject o) {return apply (o, true);}/*** CILS {@ link DBCollection # doapply (com. mongodb. DBObject )}, optionally adding an automatic _ id field * @ param jo object to add fields to * @ param ensureID whether to add an <code> _ id </code> field * @ return the modified object <code> o </code> */public Object apply (DBObject jo, boolean ensureID) {Object id = jo. get ("_ id"); if (ensureID & id = null) {id = ObjectId. get (); jo. put ("_ id", id) ;}doapply (jo); return id ;}*********************************************************************** Ľ · 」
Public WriteResult save (DBObject jo, WriteConcern concern) {if (checkReadOnly (true) return null; _ checkObject (jo, false, false); Object id = jo. get ("_ id"); if (id = null | (id instanceof ObjectId & (ObjectId) id ). isNew () {if (id! = Null & id instanceof ObjectId) (ObjectId) id ). notNew (); if (concern = null) return insert (jo); else return insert (jo, concern);} DBObject q = new BasicDBObject (); q. put ("_ id", id); if (concern = null) return update (q, jo, true, false); else return update (q, jo, true, false, concern );}
2.» Ç ç²» éö ~*************************************************************Maid
DBObject update = new BasicDBObject ("$ inc", new BasicDBObject ("counter", 1); DBObject query = new BasicDBObject ("_ id", key ); DBObject result = getmediatemplate (). getCollection (collectionName ). findAndModify (query, update); if (result = null) {DBObject doc = new BasicDBObject (); doc. put ("counter", 1L); doc. put ("_ id", key); // insert (collectionName, doc); getctiontemplate (). save (doc, collectionName); return 1L;} return (Long) result. get ("counter ");

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.