日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

批量put和单条put

發(fā)布時間:2023/12/15 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 批量put和单条put 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業(yè)重金招聘Python工程師標準>>>

Hbase1.1.5源碼:

HTable類:

@Overridepublic void put(final Put put) throws IOException {getBufferedMutator().mutate(put);//放入bufferMutator中if (autoFlush) {flushCommits();}}/*** {@inheritDoc}* @throws IOException*/@Overridepublic void put(final List<Put> puts) throws IOException {getBufferedMutator().mutate(puts);放入bufferMutator中if (autoFlush) {flushCommits();}}

BufferedMutatorImpl類:

@Overridepublic synchronized void mutate(Mutation m) throws InterruptedIOException,RetriesExhaustedWithDetailsException {doMutate(m);}@Overridepublic synchronized void mutate(List<? extends Mutation> ms) throws InterruptedIOException,RetriesExhaustedWithDetailsException {for (Mutation m : ms) {doMutate(m); //調用單條的mutate方法}}private void doMutate(Mutation m) throws InterruptedIOException,RetriesExhaustedWithDetailsException {if (closed) {throw new IllegalStateException("Cannot put when the BufferedMutator is closed.");}if (!(m instanceof Put) && !(m instanceof Delete)) {throw new IllegalArgumentException("Pass a Delete or a Put");}// This behavior is highly non-intuitive... it does not protect us against// 94-incompatible behavior, which is a timing issue because hasError, the below code// and setter of hasError are not synchronized. Perhaps it should be removed.if (ap.hasError()) {writeAsyncBuffer.add(m);backgroundFlushCommits(true);}if (m instanceof Put) {validatePut((Put) m);}currentWriteBufferSize += m.heapSize(); // 計算字節(jié)大小,并累加writeAsyncBuffer.add(m);// 如果當前的數據字節(jié)大小大于閾值,則進行commitwhile (currentWriteBufferSize > writeBufferSize) {backgroundFlushCommits(false);}} ?

疑問:如果 設置了autoFlush 為false, 則批量put和單條put的效率應該是一樣的。為什么在測試時,批量要比單條快很多??

轉載于:https://my.oschina.net/u/1537182/blog/702840

總結

以上是生活随笔為你收集整理的批量put和单条put的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。