原创 leetcode 456. 132 Pattern題解

Given a sequence of n integers a1, a2, …, an, a 132 pattern is a subsequence ai, aj, ak such that i < j < k and ai

原创 線程安全單例模式示例

單例模式:確保一個類只有一個實例,且提供一個全局訪問點 注意問題: 多線程安全 資源申請時機 性能問題 sig.h #include <iostream> #include <pthread.h> using namespac

原创 leetcode 476. Number Complement題解

Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary r

原创 【轉】警惕多線程環境string、vector、protobuf等自增長數據結構的隱性內存泄露

轉載自 警惕多線程環境string、vector、protobuf等自增長數據結構的隱性內存泄露 說明:遇到類似內存問題,猜測是同樣的原因。測試中。。。 最近工作上一個模塊內存泄露,內存緩慢增漲,存在oom的風險,很多人搞了一個月,最

原创 python字符串拼接編碼問題

utf-8   + unicode = type爲unicode utf-8   + gb18030 =  type爲str gb18030  +  unicode 報錯 以上三種情況拼接在內存中的存儲情況: 是否意味着 若憑藉字符

原创 【轉載】leveldb之MANIFEST

【轉載】leveldb之MANIFEST 首頁分類標籤留言關於訂閱 2017-01-11 | 分類 leveldb  | 標籤 leveldb  轉自 http://bean-li.github.io/leveldb-manifes

原创 簡單介紹google protobuf rpc框架使用方法

對google protobuf定義的基本rpc框架學習了一下 基本rpc定義 RpcController An RpcController mediates a single method call. The primary pu

原创 【轉載】leveldb中的LRUCache設計

【轉載】leveldb中的LRUCache設計 關鍵點: 1. hash (1)rehash+預防碰撞(總節點數超過hashtable大小) 2. LRU (1)冷鏈+熱鏈 (2)引用計數的使用 3.sharedLRUCache (1

原创 epoll實現echo server和client

作爲後端研發人員,竟然沒搞清楚C/S模式,慚愧。。不爽。。 部分代碼參考 http://blog.csdn.net/shanshanpt/article/details/7383400 感謝~~ server.cpp #inclu

原创 用戶搜索意圖識別讀書筆記

最近讀了“大數據雜談”公衆號上的一篇文章“搜你所想”之用戶搜索意圖識別,主要講了搜索意圖識別主要的步驟和一些方法,覺得講得挺詳細的所以根據文章內容繪製了腦圖,方便以後回顧。

原创 跳錶實現

參考redis以及http://www.cnblogs.com/liuhao/archive/2012/07/26/2610218.html bskl.h #include <vector> using namespace std;

原创 【轉載】leveldb源碼分析—Recover和Repair

【轉載】leveldb源碼分析—Recover和Repair  轉自 http://www.cnblogs.com/KevinT/p/3875572.html leveldb作爲一個KV存儲引擎將數據持久化到磁盤,而對於一個存儲引擎

原创 [leetcode]Repeated Substring Pattern順帶複習KMP

雖然是easy題型,但是想要高效的實現,還是得用KMP的思想啊。。 PS:一遇到next數組就歇菜。。原因是對next數組含義理解不透徹。。不能再這樣下去了。。 next[i]=j;表示到i前面字符串與原始字符匹配的子串長度。因此,

原创 C++ string自定義輔助方法彙總

split方法 #include <iostream> #include <vector> #include <sstream> using namespace std; void split(string s, char delim

原创 reactor模式C++實現

copy from github上的一份實現。。。找不到鏈接了。。。 * epoll主要負責fd到event類型的映射 * EventDemultiplexer管理fd <-> event類型 <-> eventhandler具體怎麼