mongodb 排序_技術分享 | MongoDB 一次排序超過內存限制的排查

本文目錄:

一、背景

1. 配置參數檢查

2. 排序字段是否存在索引

二、測試環境模擬索引對排序的影響

1. 測試環境信息

2. 報錯語句的執行計劃解釋 3. 建立新的組合索引進行測試

三、引申的組合索引問題

1. 查詢語句中,排序字段 _id 使用降序

2. 查詢語句中,排序字段 Num 和 _id 全部使用降序

四、引申的聚合查詢問題

1.Sort stage 使用內存排序

五、結論

1. 排序內存限制的問題

2. 使排序操作使用到索引?

1) 為查詢語句創建合適的索引

2) 注意前綴索引的使用

3.聚合查詢添加allowDiskUse選項

六、參考文獻

一、背景

某次在客戶現場處理一起APP業務中頁面訪問異常的問題,該頁面直接是返回一行行碩大的報錯代碼,錯誤大概如下所示:

MongoDB.Driver.MongoQueryException: QueryFailure flag was Executor error: OperationFailed: Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit

報錯頁面很明顯告知了問題排查的方向:

  • Sort operation 該頁面涉及的MongoDB查詢語句使用了排序。

  • more than the maximum 33554432 排序操作超過了MongoDB單個Session排序可使用的最大內存限制。

檢索MongoDB的日志確實存在大量的查詢報錯,跟APP頁面報錯能夠對應上;并且日志中排序使用的字段為 DT 和 _id ,升序排序。????

涉及業務敏感字,全文會略過、改寫或使用'xxx'代替

2019-XX-XXTXX:XX:XX.XXX+0800 E QUERY [conn3644666] Plan executor error during find: FAILURE, ·········· sortPattern: {DT: 1, _id: 1 }, memUsage: 33555513, memLimit: 33554432, ·············· }

2019-XX-XXTXX:XX:XX.XXX+0800 I QUERY [conn3644666] assertion 17144 Executor error: OperationFailed: Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit. ns:XXXXX query:{ $query:········ $orderby: { DT: 1, _id: 1 }, $hint: { CID: 1, CVX: 1 } }

1. 配置參數檢查

MongoDB Server中確認了對于Sort排序能夠支持的最大內存限制為32M。

> use admin

switched to db admin

> db.runCommand({ getParameter : 1, "internalQueryExecMaxBlockingSortBytes" : 1 } )

{ "internalQueryExecMaxBlockingSortBytes" : 33554432, "ok" : 1 }

2. 排序字段是否存在索引

根據報錯信息的建議,查看官方文檔的解釋:

In MongoDB, sort operations can obtain the sort order by retrieving documents based on the ordering in an index. If the query planner cannot obtain the sort order from an index, it will sort the results in memory. Sort operations that use an index often have better performance than those that do not use an index. In addition, sort operations that do not use an index will abort when they use 32 megabytes of memory.

文檔中意思大概是:在排序字段未利用到索引的情況下,若超過32M內存則會被Abort,語句直接返回報錯。

那么現在方向基本可以鎖定在排序操作是否使用到索引了;查看該集合狀態,排序字段 DT 和?_id確實存在索引 _id_、 DT_1 、 DT_1_CID_1_id_1 ,為啥還會報錯?帶著疑問我們下文在測試環境進行模擬。

> db.xxx.getIndexes()

[

·········

{

"v" : 1,

"key" : {

"_id" : 1

},

"name" : "_id_",

"ns" : "xxx.xxx"

},

{

"v" : 1,

"key" : {

"DT" : 1

},

"name" : "DT_1",

"ns" : "xxx.xxx"

},

{

"v" : 1,

"key" : {

"DT" : 1,

"CID" : 1,

"_id" : 1

},

"name" : "DT_1_CID_1_id_1",

"ns" : "xxx.xxx"

}

···········

二、測試環境模擬索引對排序的影響

1.測試環境信息

MongoDB版本4.0.10
MongoDB 存儲引擎wiredTiger
數據量1000000
測試集合名data_test

集合數據存儲格式

> db.data_test.findOne()

{

"_id" : ObjectId("5d0872dc5f13ad3173457186"),

"Name" : "Edison",

"Num" : 195930,

"loc" : {

"type" : "Point",

"coordinates" : [

118.0222094243601,

36.610739264097646

]

}

}

集合索引信息

> db.data_test.getIndexes()

[

{

"v" : 2,

"key" : {

"_id" : 1

},

"name" : "_id_",

"ns" : "mongobench.data_test"

},

{

"v" : 2,

"key" : {

"Name" : 1

},

"name" : "Name_1",

"ns" : "mongobench.data_test"

},

{

"v" : 2,

"key" : {

"Num" : 1

},

"name" : "Num_1",

"ns" : "mongobench.data_test"

},

{

"v" : 2,

"key" : {

"Num" : 1,

"Name" : 1,

"_id" : 1

},

"name" : "Num_1_Name_1__id_1",

"ns" : "mongobench.data_test"

}

]

查詢語句

為測試方便,將業務中報錯的聚合查詢按同樣查詢邏輯修改為 Mongo Shell 中的普通 find() 查詢

2. 報錯語句的執行計劃解釋

測試查詢報錯的語句,嘗試查看其查詢計劃如下:

> db.data_test.find({'Num':{"$gt":500000}}).sort({"Num":1,"_id":1}).explain()

2019-06-19T18:21:14.745+0800 E QUERY [js] Error: explain failed: {

"ok" : 0,

"errmsg" : "Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit.",

"code" : 96,

"codeName" : "OperationFailed"

}

直接報錯,這里有個疑問為啥連執行計劃都看不了?先不急,我們先刪除對于排序字段的組合索引 Num_1_Name_1_id_1 后,再查看執行計劃:

> db.data_test.dropIndex('Num_1_Name_1__id_1')

{ "nIndexesWas" : 4, "ok" : 1 }

db.data_test.find({'Num':{"$gt":500000}}).sort({"Num":1,"_id":1}).explain('executionStats')

{

"queryPlanner" : {

"plannerVersion" : 1,

"namespace" : "mongobench.data_test",

"indexFilterSet" : false,

"parsedQuery" : {

"Num" : {

"$gt" : 500000

}

},

"winningPlan" : {

"stage" : "SORT",

"sortPattern" : {

"Num" : 1,

"_id" : 1

},

"inputStage" : {

"stage" : "SORT_KEY_GENERATOR",

·······

"rejectedPlans" : [ ]

},

"executionStats" : {

"executionSuccess" : false,

"errorMessage" : "Exec error resulting in state FAILURE :: caused by :: Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit.",

"errorCode" : 96,

"nReturned" : 0,

"executionTimeMillis" : 1504,

"totalKeysExamined" : 275037,

"totalDocsExamined" : 275037,

"executionStages" : {

"stage" : "SORT",

"nReturned" : 0,

"executionTimeMillisEstimate" : 188,

····

"memUsage" : 33554514,

"memLimit" : 33554432,

"inputStage" : {

"stage" : "SORT_KEY_GENERATOR",

"nReturned" : 275037,

·····

查詢計劃中關鍵參數的解釋:

1. queryPlanner:explain中三種模式之一,默認模式。表示不會執行查詢語句而是選出最優的查詢計劃即winning plan,剩余兩種模式分別是 executionStats 和 allPlansExecution

  • winningPlan:MongoDB優化器選擇的最優執行計劃

[1]stage:包括COLLSCAN 全表掃描、IXSCAN 索引掃描、FETCH 根據索引去檢索指定文檔、SORT 在內存中進行排序(未使用索引)

[2]sortPattern:需排序的字段

[3]inputStage:winningPlan.stage的子階段

  • rejectedPlans:優化器棄用的執行計劃

2. executionStats:返回執行結果的狀態,如語句成功或失敗等

  • executionSuccess:語句執行是否成功

  • errorMessage:錯誤信息

  • nReturned:返回的記錄數

  • totalKeysExamined:索引掃描總行數

  • totalDocsExamined:文檔掃描總行數

  • memUsage:Sort 使用內存排序操作使用的內存大小

  • memLimit:MongoDB 內部限制Sort操作的最大內存

上述執行計劃表明查詢語句在未使用索引排序的情況下如果排序使用的內存超過32M必定會報錯,那么為什么沒有使用到索引排序,是不是跟組合索引的順序有關?

3. 建立新的組合索引進行測試

直接創建 Num 和 _id 列都為升序的組合索引,再次查看執行計劃:

> db.data_test.ensureIndex({Num:1,_id:1})

{

"createdCollectionAutomatically" : false,

"numIndexesBefore" : 3,

"numIndexesAfter" : 4,

"ok" : 1

}

> db.data_test.find({'Num':{"$gt":500000}}).sort({"Num":1,"_id":1}).explain('executionStats')

{

"queryPlanner" : {

"plannerVersion" : 1,

"namespace" : "mongobench.data_test",

"indexFilterSet" : false,

"parsedQuery" : {

"Num" : {

"$gt" : 500000

}

},

"winningPlan" : {

"stage" : "FETCH",

"inputStage" : {

"stage" : "IXSCAN",

"keyPattern" : {

"Num" : 1,

"_id" : 1

},

"indexName" : "Num_1__id_1",

·········

"rejectedPlans" : [

{

"stage" : "SORT",

"sortPattern" : {

"Num" : 1,

"_id" : 1

},

"inputStage" : {

"stage" : "SORT_KEY_GENERATOR",

·········

"executionStats" : {

"executionSuccess" : true,

"nReturned" : 499167,

"executionTimeMillis" : 1355,

"totalKeysExamined" : 499167,

"totalDocsExamined" : 499167,

"executionStages" : {

"stage" : "FETCH",

"nReturned" : 499167,

"executionTimeMillisEstimate" : 102,

"works" : 499168,

"advanced" : 499167,

"needTime" : 0,

"needYield" : 0,

"saveState" : 3901,

"restoreState" : 3901,

"isEOF" : 1,

"invalidates" : 0,

"docsExamined" : 499167,

"alreadyHasObj" : 0,

"inputStage" : {

"stage" : "IXSCAN",

"nReturned" : 499167,

"executionTimeMillisEstimate" : 14,

"works" : 499168,

·······

上述執行計劃說明:

  • winningPlan.stage:優化器選擇了FETCH+IXSCAN的Stage,而不是之前的Sort;這是最優的方式之一,也就是通過索引檢索指定的文檔數據,并在索引中完成排序 ("keyPattern" : {"Num" : 1,"_id" : 1}) ,效率最高

  • rejectedPlans:Sort 使用內存排序的方式被優化器棄用

  • executionSuccess:語句執行成功

  • nReturned:語句返回結果數為499167

三、引申的組合索引問題

上文中查詢語句explain()直接報錯,是因為組合索引為{Num_1_Name_1_id_1},而查詢語句為sort({"Num":1,"_id":1}),未遵循最左原則,索引無法被使用到而后優化器選擇Sort Stage觸發了內存限制并Abort。

至于為啥MongoDB連執行計劃都不返回給你,可以后續再討論,歡迎評論

創建合適的組合索引后,查詢語句成功執行;那么如果不按照索引的升降順序執行語句會怎樣?

1.查詢語句中,排序字段 _id 使用降序

當前的組合索引為{"key" : {"Num" : 1, "_id" : 1} },也就是都為升序,而我們將查詢語句中排序字段 _id 使用降序排序時,查詢語句直接報錯,說明該語句也未使用到索引排序,而是使用的Sort Stage。

> db.data_test.find({'Num':{"$gt":500000}}).sort({"Num":1,"_id":-1}).explain('executionStats')

2019-06-19T19:32:30.939+0800 E QUERY [js] Error: explain failed: {

"ok" : 0,

"errmsg" : "Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit.",

"code" : 96,

"codeName" : "OperationFailed"

}

2.查詢語句中,排序字段 Num _id 全部使用降序

我們現在將查詢語句的排序字段全部使用降序,與組合索引全部相反再測試,執行成功。

> db.data_test.find({'Num':{"$gt":500000}}).sort({"Num":-1,"_id":-1}).explain('executionStats')

{

"queryPlanner" : {

······

"winningPlan" : {

"stage" : "FETCH",

"inputStage" : {

"stage" : "IXSCAN",

"keyPattern" : {

"Num" : 1,

"_id" : 1

},

"indexName" : "Num_1__id_1",

·······

"rejectedPlans" : [

{

"stage" : "SORT",

·······

"executionStats" : {

"executionSuccess" : true,

·······

"inputStage" : {

"stage" : "IXSCAN",

·······

"indexName" : "Num_1__id_1",

······

"ok" : 1

}

再次做其他查詢組合測試 sort({"Num":-1,"_id":1}),執行依然失敗;說明只有在排序列的升降序只有和組合索引中的 方向 保持 全部相同 全部相反,語句執行才能成功。

四、引申的聚合查詢問題

上文中的查詢測試語句是在 MongoDB Shell 執行的 find() 查詢方法,但是業務程序中查詢一般都是使用聚合查詢方法 aggregate(),對于聚合查詢中的Sort Stage,官方文檔說明了使用內存排序能使用最大的內存為 100M,若需要避免報錯則需要添加 {allowDiskUse : true} 參數。

The $sort stage has a limit of 100 megabytes of RAM. By default, if the stage exceeds this limit, $sort will produce an error. To allow for the handling of large datasets, set the allowDiskUse option to true to enable $sort operations to write to temporary files. See the allowDiskUse option in db.collection.aggregate() method and the aggregate command for details.

1.Sort stage 使用內存排序

將普通的 find() 方法轉為 aggregate() 聚合方法,語義不變,特意將排序字段 _id 修改為 降序 -1 ,那么查詢計劃將無法使用到組合索引只能使用Sort stage。下文中查詢依然報錯,Sort stage操作使用的內存超過100M

> db.data_test.explain('executionStats').aggregate([{ $match : { Num : { $gt : 500000} } },{ $sort : { "Num" : 1, _id: -1 } }])

2019-06-19T20:28:43.859+0800 E QUERY [js] Error: explain failed: {

"ok" : 0,

"errmsg" : "Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in.",

"code" : 16819,

"codeName" : "Location16819"

} :

_getErrorWithCode@src/mongo/shell/utils.js:25:13

throwOrReturn@src/mongo/shell/explainable.js:31:1

constructor/this.aggregate@src/mongo/shell/explainable.js:121:1

@(shell):1:1

添加 {allowDiskUse: true} 參數,可以使Sort stage操作繞過內存限制而使用磁盤,查詢語句可以執行成功:

> db.data_test.explain('executionStats').aggregate([{ $match : { Num : { $gt : 500000} } },{ $sort : { "Num" : 1, _id: -1 } }],{allowDiskUse: true})

{

"stages" : [

······

"executionStats" : {

"executionSuccess" : true,

"nReturned" : 499167,

"executionTimeMillis" : 4128,

"totalKeysExamined" : 499167,

"totalDocsExamined" : 499167,

······

{

"$sort" : {

"sortKey" : {

"Num" : 1,

"_id" : -1

}

}

}

],

"ok" : 1

}

五、結論

1.排序內存限制的問題

MongoDB使用內存進行排序的場景只有是Sort stage,官方文檔有說明:

If MongoDB can use an index scan to obtain the requested sort order, the result will not include a SORT stage. Otherwise, if MongoDB cannot use the index to sort, the explain result will include a SORT stage.

意思大概是如果MongoDB可以使用索引掃描來進行排序,那么結果將不包括SORT stage。否則如果MongoDB無法使用索引進行排序,那么查詢計劃將包括SORT stage。

使用索引掃描的效率是遠大于直接將結果集放在內存排序的,所以MongoDB為了使查詢語句更有效率的執行,限制了 排序內存的使用,因而規定了只能使用 32M,該種考慮是非常合理的。

但也可通過手工調整參數進行修改(不建議):

# 比如調大到 128M

## 在線調整

> db.adminCommand({setParameter:1, internalQueryExecMaxBlockingSortBytes:134217728})

## 持久到配置文件

setParameter:

internalQueryExecMaxBlockingSortBytes: 134217728

2.使排序操作使用到索引

1)為查詢語句創建合適的索引如果查詢中排序是單列排序,如sort({"Num":1}),那么只需添加為 Num 列添加索引即可,排序的順序無影響

## 例如索引為 {'Num':1},查詢不管升/降序都可使用到索引排序

db.data_test.find().sort({Num:1})

db.data_test.find().sort({Num:-1})

如果查詢中排序是使用組合排序,如sort({"Num":1,"id":1}),那么需要建立對應的組合索引,如{"key" : {"Num" : 1, "_id" : 1} 或者 {"key" : {"Num" : -1, "_id" : -1}

## 例如索引為{"Num" : 1, "_id" : 1},可以用到索引排序的場景為

db.data_test.find().sort({Num:1,_id:1})

db.data_test.find().sort({Num:-1,_id:-1})

注意保持查詢中組合排序的升降序和組合索引中的 方向 保持 全部相同 或 全部相反

2)注意前綴索引的使用

上文查詢報錯的案例分析已說明了組合索引每一個鍵的順序非常重要,這將決定該組合索引在查詢過程中能否被使用到,也將是MongoDB的索引及排序同樣需遵循最左前綴原則。

3. 聚合查詢添加allowDiskUse選項

盡可能的保證查詢語句的排序能夠使用索引排序,但如果業務需要規避排序內存限制報錯的問題,那么需要在代碼中添加 {allowDiskUse : true} 參數。

六、參考文獻

https://docs.mongodb.com/manual/tutorial/sort-results-with-indexes/index.html

https://docs.mongodb.com/manual/reference/operator/aggregation/sort/#sort-memory-limit

https://docs.mongodb.com/manual/reference/explain-results/#executionstats

a319326673c94600c4e2c81c479b2ced.gif

近期社區動態

第三期?社區技術內容征稿?

所有稿件,一經采用,均會為作者署名。

征稿主題:MySQL、分布式中間件DBLE、數據傳輸組件DTLE相關的技術內容

活動時間:2019年6月11日?-?7月11日

本期投稿獎勵

投稿成功:京東卡200元*1

優秀稿件:京東卡200元*1+社區定制周邊(包含:定制文化衫、定制傘、鼠標墊)

優秀稿件評選,文章獲得“好看數量排名前三的稿件為本期優秀稿件。

3e180a30564093579d7864b52e52c84c.png7a4fd082d495b210d398a0f8e6ef6866.gif

喜歡點分享”,不行就看”

dbb76a592e59a72a7e403df0db2a9c82.gif

多喝熱水,重啟試試

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/541518.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541518.shtml
英文地址,請注明出處:http://en.pswp.cn/news/541518.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

sim800 模式切換_SIM的完整形式是什么?

sim800 模式切換SIM:訂戶標識模塊或訂戶標識模塊 (SIM: Subscriber Identity Module or Subscriber Identification Module) SIM is an abbreviation of a Subscriber Identity Module or Subscriber Identification Module. SIM is a portable chip and an integra…

css新單位 vw , vh

考慮到未來響應式設計的開發,如果你需要,瀏覽器的高度也可以基于百分比值調整。但使用基于百分比值并不總是相對于瀏覽器窗口的大小定義的最佳方式,比如字體大小不會隨著你窗口改變而改變,如今css3引入的新單位明確解決這一問題。…

linux下mysql目錄結構_linux下mysql安裝配置與目錄結構

本節內容:linux下mysql安裝與配置、mysql目錄結構。1、準備安裝程序(官方網站下載)服務端:MySQL-server-community-5.1.44-1.rhel4.i386.rpm客戶端:MySQL-client-community-5.1.44-1.rhel4.i386.rpm2、安裝(打印信息略) 代碼示例:[rootlocalh…

Python字典values()方法與示例

字典values()方法 (Dictionary values() Method) values() method is used to get all values of a dictionary, it returns a view object that contains the all values of the dictionary as a list. values()方法用于獲取字典的所有值,它返回一個包含字典所有值…

spark源碼分析之Executor啟動與任務提交篇

任務提交流程 概述 在闡明了Spark的Master的啟動流程與Worker啟動流程。接下繼續執行的就是Worker上的Executor進程了,本文繼續分析整個Executor的啟動與任務提交流程Spark-submit 提交一個任務到集群通過的是Spark-submit通過啟動腳本的方式啟動它的主類&#xff0…

mysql 5.5.22.tar.gz_MySQL 5.5.22源碼編譯安裝

MySQL 最新的版本都需要cmake編譯安裝,估計以后的版本也會采用這種方式,所以特地記錄一下安裝步驟及過程,以供參考。注意:此安裝是默認CentOS下已經安裝了最新工具包,比如GNU make, GCC, Perl, libncurses5-dev&#x…

Java Vector setElementAt()方法與示例

向量類setElementAt()方法 (Vector Class setElementAt() method) setElementAt() method is available in java.util package. setElementAt()方法在java.util包中可用。 setElementAt() method is used to set the given element (ele) at the given indices in this Vector.…

利用python進行數據分析D2——ch03IPython

為無為,事無事,味無味。大小多少,報怨以德。圖難于其易,為大于其細;天下難事必作于易,天下大事必作于細。——老子關于圖片的例子:import matplotlib.pyplot as plt imgplt.imread(ch03/stinkbug.png) import pylab plt.imshow(img) pylab.show()結果:調…

mysql 視圖 字典_MySQL深入01-SQL語言-數據字典-服務器變量-數據操作DML-視圖

SQL語言的組成部分常見分類:DDL:數據定義語言DCL:數據控制語言,如授權DML:數據操作語言其它分類:完整性定義語言:DDL的一部分功能約束約束:包括主鍵,外鍵,唯一…

為什么我會被淘汰?

這是一個值得討論的問題。華為前段時間也傳出了大規模裁員的一些負面新聞,一時間搞的人心惶惶。總結起來說,還是怕失去這份賴以生存的工作,尤其是對于上有老下有小的中年人來說,工作尤為重要。 淘汰,是軟件行業不變的真…

Java Throwable initCause()方法與示例

Throwable類initCause()方法 (Throwable Class initCause() method) initCause() Method is available in java.lang package. initCause()方法在java.lang包中可用。 initCause() Method is used to instantiate the cause of this throwable to the given value and this met…

mysql 存儲過程死循環_pl/sql存儲過程loop死循環

今早,一個存儲過程,寫過很多次的存儲過程,隨手一寫,各種報錯,各種糾結,網上一搜,有好多個都遇到,論壇上給出的結局答案,今早,一個存儲過程,寫過很…

GATK之VariantAnnotator

VariantAnnotator 簡要說明 用途: 利用上下文信息注釋識別的變異位點(variant calls)分類: 變異位點操作工具概要: 根據變異位點的背景信息(與功能注釋相對)進行注釋。目前有許多的注釋模塊(見注釋模塊一節…

pipedreader_Java PipedReader connect()方法與示例

pipedreaderPipedReader類的connect()方法 (PipedReader Class connect() method) connect() method is available in java.io package. connect()方法在java.io包中可用。 connect() method is used to cause this PipedReader to be connected to the given PipedWriter (sou…

《Java學習指南》—— 1.4 設計安全

本節書摘來異步社區《Java學習指南》一書中的第1章,第1.4節,作者:【美】Patrick Niemeyer , Daniel Leuck,更多章節內容可以訪問云棲社區“異步社區”公眾號查看。 1.4 設計安全 Java被設計為一種安全語言,對于這一事實…

ppython_Python pcom包_程序模塊 - PyPI - Python中文網

PCOM在python中一個非常基本的unitronics pcom協議實現。如何使用from pcom import commandsfrom pcom.plc import EthernetPlcwith EthernetPlc(address(192.168.5.43, 1616)) as plc:# Read realtime clockc commands.ReadRtc()res plc.send(c)print(res)# Set realtime cl…

bitcount方法詳解_Java Long類的bitCount()方法和示例

bitcount方法詳解長類bitCount()方法 (Long class bitCount() method) bitCount() method is available in java.lang package. bitCount()方法在java.lang包中可用。 bitCount() method is used to find the number of 1s bits in the 2s complement binary denotation of the…

《軟件定義數據中心:Windows Server SDDC技術與實踐》——導讀

前言 通過對自身的審視和對身邊IT 技術專家的觀察,我發現對于我們來說,掌握一項新的技術或熟悉一個新的產品,大都是聞而后知,知而后學,學以致用,用以知其然。然而Windows Server作為一個簡單的、易上手的操…

python二維向量運算模擬_python二維向量運算_[VB.NET][C#]二維向量的基本運算

前言在數學中,幾何向量是指具有大小和方向的幾何對象。在編程中,向量有著廣泛的應用,其作用在圖形編程和游戲物理引擎方面尤為突出。第一節 構造函數通過創建一個二維向量的類(或結構體),實現向量的表示及其運算。1. 首先&#xf…

Java LinkedHashMap clear()方法與示例

LinkedHashMap類的clear()方法 (LinkedHashMap Class clear() method) clear() method is available in java.util package. clear()方法在java.util包中可用。 clear() method is used to remove all the existing elements from this LinkedHashMap. clear()方法用于從此Link…