自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(22)
  • 收藏
  • 关注

原创 python字符串拼接编码问题

utf-8   + unicode = type为unicodeutf-8   + gb18030 =  type为strgb18030  +  unicode 报错以上三种情况拼接在内存中的存储情况:是否意味着 若凭借字符串中存在unicode则统一按unicode处理其余拼接项?为啥呢?为啥会强转unicode?=========================

2018-01-10 20:48:07 2188

转载 【转载】leveldb中的LRUCache设计

【转载】leveldb中的LRUCache设计关键点:1. hash(1)rehash+预防碰撞(总节点数超过hashtable大小)2. LRU(1)冷链+热链(2)引用计数的使用【多线程安全】3.sharedLRUCache(1)分区首页分类标签留言关于订阅2016-11-26|分类leveldb|标签leveldbhtt...

2017-08-22 20:26:37 1008

转载 【转载】leveldb之MANIFEST

【转载】leveldb之MANIFEST首页分类标签留言关于订阅2017-01-11 | 分类 leveldb  | 标签 leveldb 转自 http://bean-li.github.io/leveldb-manifest/前言上一节讲了LogAndApply的一部分: Version* v = new Version(this); {

2017-08-22 15:00:06 2073

转载 【转载】leveldb源码分析—Recover和Repair

【转载】leveldb源码分析—Recover和Repair 转自 http://www.cnblogs.com/KevinT/p/3875572.htmlleveldb作为一个KV存储引擎将数据持久化到磁盘,而对于一个存储引擎来说在存储过程中因为一些其他原因导致程序down掉甚至数据文件被破坏等都会导致程序不能按正常流程再次启动。那么遇到这些状况以后如何使程序最大程度的恢复数据就

2017-08-21 16:40:30 631

原创 API之信息隐藏

最近在阅读leveldb的代码,以前没有太关注过信息隐藏,怎样才能不对外暴露实现细节。因此这里以leveldb中的Cache实现为例学习一下^_^// Copyright (c) 2011 The LevelDB Authors. All rights reserved.// Use of this source code is governed by a BSD-style license th

2017-08-17 11:32:32 354

原创 C++ string自定义辅助方法汇总

split方法#include <iostream>#include <vector>#include <sstream>using namespace std;void split(string s, char delim, vector<string>& nodes) { string temp; stringstream ss(s);

2017-08-08 13:59:22 256

原创 Template模式

template method 隔离不变与变化,把不变的部分上移到父类中,由子类去实现变化的部分#include <vector>#include <iostream>using namespace std;class A {public: virtual ~A() {} // template method void common() { read();

2017-07-28 19:40:14 434

原创 epoll实现echo server和client

作为后端研发人员,竟然没搞清楚C/S模式,惭愧。。不爽。。server.cpp#include <stdio.h>#include <unistd.h>#include <stdlib.h>#include <string.h>#include <sys/types.h>#include <errno.h>#include <sys/socket.h> // for

2017-07-07 17:14:16 574

转载 【转】Redis设计思路学习与总结

这才是学东西的正确态度,思路清晰,写得好好,学习~~(抱歉,投投copy过来,自己可见)http://www.cnblogs.com/onetwo/p/6214813.html======================================================================================================

2017-06-21 10:55:16 272

原创 简单介绍google protobuf rpc框架使用方法

对google protobuf定义的基本rpc框架学习了一下RpcController An RpcController mediates a single method call. The primary purpose of the controller is to provide a way to manipulate settings specific to the RPC impl

2017-06-15 23:16:36 9612

原创 个性化推荐读书笔记

读了“大数据杂谈”公众号文章“想你所想”之个性化推荐:实践与优化,还有挺多干货的。之前了解过推荐系统相关的算法,这篇文章将我之前看过的算法应用在了实际系统中,感觉有一定的参考价值。学习下~

2017-06-12 21:43:17 915

原创 用户搜索意图识别读书笔记

最近读了“大数据杂谈”公众号上的一篇文章“搜你所想”之用户搜索意图识别,主要讲了搜索意图识别主要的步骤和一些方法,觉得讲得挺详细的所以根据文章内容绘制了脑图,方便以后回顾。

2017-06-12 21:34:26 798

原创 [leetcode]Repeated Substring Pattern顺带复习KMP

虽然是easy题型,但是想要高效的实现,还是得用KMP的思想啊。。 PS:一遇到next数组就歇菜。。原因是对next数组含义理解不透彻。。不能再这样下去了。。next[i]=j;表示到i前面字符串与原始字符匹配的子串长度。因此,next[n+1]数组需要开n+1大小bool repeatedSubstringPattern(string s) { int i = 1; int

2017-06-08 22:49:19 297

转载 【转】警惕多线程环境string、vector、protobuf等自增长数据结构的隐性内存泄露

转载自 警惕多线程环境string、vector、protobuf等自增长数据结构的隐性内存泄露 说明:遇到类似内存问题,猜测是同样的原因。测试中。。。最近工作上一个模块内存泄露,内存缓慢增涨,存在oom的风险,很多人搞了一个月,最后定位是protobuf格式的数据的增涨。首选说一下,我定位内存泄露采取的经验吧。我一般利用gperftools,在进程起来之后,在一个时刻,先dump一个内存占用

2017-05-18 13:56:17 2703

原创 [leetcode] Fraction to Recurring Decimal

没想到溢出这码事儿。。。纠结了好久。。。abs只能针对int所以得自己做abs。。。需要记录循环开始的位置#include <iostream>#include <vector>#include <string>#include <map>#include <sstream>using namespace std;string fractionToDecimal(int numerat

2017-05-02 20:59:04 226

原创 跳表实现

参考redis以及http://www.cnblogs.com/liuhao/archive/2012/07/26/2610218.htmlbskl.h#include <vector>using namespace std;class SkipListLevel;static const uint32_t MAX_LEVEL = 8;struct SkipListNode { dou

2017-04-25 16:55:09 431

原创 数值型字符串转整型代码汇总

摘自 memcache 源码#include <iostream>#include <stdlib.h>#include <string.h>#include <assert.h>using namespace std;/* Avoid warnings on solaris, where isspace() is an index into an array, and gcc uses s

2017-02-06 18:20:03 522

原创 C++/JAVA版无脑模拟shipbattle

最近帮别人水了到题。。于是我写了一大坨。。 论除C++外掌握好第二语言的重要性。。。学python好了。。。T-TC++(我写的)#include <iostream>#include <string>#include <boost/algorithm/string.hpp>#include <boost/lexical_cast.hpp>#include <vector>#incl

2017-01-23 14:47:01 676

转载 flex&bison范例初步学习

欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:Markdown和扩展Markdown简洁的语法代码块高亮图片链接和图片上传LaTex数学公式UML序列图和流程图离线写博客导入导出Markdown文件丰富的快捷键快捷键加粗 Ctrl + B 斜体 Ctrl + I 引用 Ctrl

2017-01-23 14:34:00 326

转载 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 < ak < aj. Design an algorithm that takes a list of n numbers as input and checks whet

2017-01-21 23:17:53 1609

原创 leetcode 476. Number Complement题解

Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note: 1. The given integer is guaranteed to fit within the range of a 3

2017-01-21 22:32:31 442

原创 线程安全单例模式示例

单例模式:确保一个类只有一个实例,且提供一个全局访问点注意问题:多线程安全资源申请时机sig.h#include <iostream>#include <pthread.h>using namespace std;// 提前申请好资源,不会有竞态class MySgn {public: static MySgn* get_instance() { // 此处注意

2017-01-10 20:55:24 656

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除