??xml version="1.0" encoding="utf-8" standalone="yes"?>久久成人国产精品,亚洲国产精品综合久久一线,国内精品伊人久久久久http://www.shnenglu.com/whspecial/zh-cnThu, 08 May 2025 20:49:40 GMTThu, 08 May 2025 20:49:40 GMT60自控力读书笔?/title><link>http://www.shnenglu.com/whspecial/archive/2015/04/27/210452.html</link><dc:creator>whspecial</dc:creator><author>whspecial</author><pubDate>Mon, 27 Apr 2015 07:34:00 GMT</pubDate><guid>http://www.shnenglu.com/whspecial/archive/2015/04/27/210452.html</guid><wfw:comment>http://www.shnenglu.com/whspecial/comments/210452.html</wfw:comment><comments>http://www.shnenglu.com/whspecial/archive/2015/04/27/210452.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.shnenglu.com/whspecial/comments/commentRss/210452.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/whspecial/services/trackbacks/210452.html</trackback:ping><description><![CDATA[附上URLQhttp://book.douban.com/subject/10786473/<br /><br /><div><span style="font-size: 18px;"><strong>1Q锻炼意志力的方?/strong></span></div><div><strong>AQ每天冥?分钟</strong></div><div><strong>BQ锻?/strong></div><div>对于ȝ有两个常见问题,W一个是“需要锻炼多?#8221;Q第二个?#8220;什么锻炼最有效”Q这两个问题的答案是“你想ȝ多久”Q?#8220;你真的会(x)d什么样的锻?#8221;</div><div><strong>CQ睡?/strong></div><div>睡觉能显著提高自控力,因ؓ(f)睡眠不?x)导致大脑缺乏够的能量q行自控?br />如何Ҏ(gu)晚睡的坏?fn)惯Q?/div><div>真正的问题ƈ不是自己ȝ觉,而是自己在一定时间之后就q离那些让自己无法睡觉的事情?br /></div><div></div><div><span style="font-size: 18px;"><strong>2Q意志力的规?/strong></span></div><div><strong>AQ每天的意志力变化规律:(x)</strong>早上的意志力最强,随着旉的推U而逐渐减弱?/div><div><strong>Ҏ(gu)Q?/strong>需要将最重要的事情放在早上处?/div><div><strong>BQ很多想不到的事情都是在消耗你的意志力Q?/strong>很多你认Z需要意志力的事情其实都在消耗你的意志,比如试图融入一家h(hun)D和你不符合的公司Q在p糕的\况中上班Q干坐着熬过无聊的会(x)议等{?/div><div><strong>Ҏ(gu)</strong>Q尽量避免这些事情的发生</div><div><strong>CQ压力和情A低落?x)导致意志力涣散Q?/strong>׃大脑的调节功能,如果一个h感觉到压力和情A低落Q大脑会(x)指引着你去做它认ؓ(f)能给你带来快乐的事情Q这样会(x)造成一个矛盾:(x)有很多工作要完成的hQ往往?x)选择ȝ游戏来排解压力;需要控制支出的Z(x)d肆购物来排解压力Q这样就造成了一个恶性@环?/div><div><strong>Ҏ(gu)Q?br /></strong>试有效的解压方法:(x)ȝQ阅读,听音乐,和家人相处,按摩Q散步,冥想Q培L创意的爱好;<br />攑ּ无效的解压方法:(x)赌博Q购物,抽烟Q喝酒,暴饮暴食Q玩游戏Q上|,׃个小时以上看?sh)媄或者电(sh)视?br />有效和无效的区别是?真正能缓解压力的不是释放多巴胺,而是增加大脑中改善情l的化学物质Q比如血清素QYQ}Z?催素等{,q样才是L的?/div><div><strong>DQ不能自我谅解导致的自控力恶性@环:(x)</strong>一ơ自控失败往往?x)导致整个自控计划的p|Q是W一ơ放弃后产生的羞LQ罪恶感Q失控感和绝望感Q会(x)让h破罐子破摔?/div><div><strong>Ҏ(gu)Q?/strong>L自我谅解Q只要是凡h都会(x)有失去自控力的时候,挫折本nq不可怕,可怕的是自暴自弃?br /></div><div></div><div><span style="font-size: 18px;"><strong>3Q意志力的误?/strong></span></div><div><strong>AQ不要把支持目标实现的行认ؓ(f)是目标本w:(x)</strong>比如在健w之后,有时?x)奖赏自׃瓶碳酔R料,或者去吃烧烤,其实最l摄入的能量q要大于健n消耗的能量?/div><div><strong>Ҏ(gu)Q?/strong>要弄清楚自己的目标,不要目标和q程弄؜了?/div><div><strong>BQ误(f)望当做幸:(x)</strong>׃多巴胺分泌的因素Q我们往往某些快感当做了真正的幸,比如吃垃N品,无节制的游戏{等?/div><div><strong>Ҏ(gu)Q?/strong>我们需要区分让我们的生zȝ正有意义的真实奖励(有长久意义的Q对生活有益的)Q和让我们分散精力,上瘾的虚假奖励(短暂无用的,仅仅是刺Ȁ多巴胺分泌的Q?/div><div><strong>CQ经常制定自控力计划而不施行Q?/strong>很多Z(x)重复的制定计划,而不L行计划,因ؓ(f)制定一个计划很Ҏ(gu)Q而且?x)让我们心情大好Q但是如果真的付诸实践,带给我们的快感远q小于制定计划的快感?/div><div><strong>Ҏ(gu)Q?/strong>需要避免一个意志力陷阱Q即?#8220;改变的承?#8221;而不?#8220;改变”来改善我们的心情</div><div><strong>DQhcd往攑ּ未来更大的回报,而选择卛_的满xQ?/strong>卛_奖励?x)激zL原始的奖ql,卛_Ȁ多巴胺的分泌Q而未来奖励是刺激人类最q才q化出来的前额皮质系l。hcd面(f)当前奖励和未来奖q时候,两个奖励pȝ?x)进行斗争?/div><div><strong>Ҏ(gu)Q?/strong>{待10分钟Q因10分钟?x)降低即L的快感Q让大脑更理智的思考。如?0分钟之后依然惌Q则可以选择卛_满?/div><div></div><img src ="http://www.shnenglu.com/whspecial/aggbug/210452.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/whspecial/" target="_blank">whspecial</a> 2015-04-27 15:34 <a href="http://www.shnenglu.com/whspecial/archive/2015/04/27/210452.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>log4j 行号与文件名打印问号http://www.shnenglu.com/whspecial/archive/2014/03/11/206132.htmlwhspecialwhspecialTue, 11 Mar 2014 07:57:00 GMThttp://www.shnenglu.com/whspecial/archive/2014/03/11/206132.htmlhttp://www.shnenglu.com/whspecial/comments/206132.htmlhttp://www.shnenglu.com/whspecial/archive/2014/03/11/206132.html#Feedback0http://www.shnenglu.com/whspecial/comments/commentRss/206132.htmlhttp://www.shnenglu.com/whspecial/services/trackbacks/206132.html转蝲自:(x)http://www.blogjava.net/itspy/archive/2008/04/22/194686.html#Post

log4j本来讄了要打印行号与文件名?l果有的能打印出?有的却是q,查了些文档之后才发现,原来打印问题是因为编l时没有~绎q去调试信息,所以没办法打印.
但是我用的是Ant,如果在Ant~绎?~绎q去调试信息?参考下面配|?
<javac srcdir="src" destdir="bin" debug="true"  classpathref="accrual.path" >

参考文?/div>
http://ant.apache.org/manual/CoreTasks/javac.html
Log4j配置
log4j.appender.C1.layout.ConversionPattern=%F(%L)-- %-4r %-5p [%t] %37c %3x - %m%n


whspecial 2014-03-11 15:57 发表评论
]]>排序二叉树(wi)转换成双向链?/title><link>http://www.shnenglu.com/whspecial/archive/2014/01/03/205123.html</link><dc:creator>whspecial</dc:creator><author>whspecial</author><pubDate>Thu, 02 Jan 2014 16:41:00 GMT</pubDate><guid>http://www.shnenglu.com/whspecial/archive/2014/01/03/205123.html</guid><wfw:comment>http://www.shnenglu.com/whspecial/comments/205123.html</wfw:comment><comments>http://www.shnenglu.com/whspecial/archive/2014/01/03/205123.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/whspecial/comments/commentRss/205123.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/whspecial/services/trackbacks/205123.html</trackback:ping><description><![CDATA[     摘要: 排序二叉树(wi)转化成双向链表,应该是一道很常见的面试题目,|上的实现比较多Q有用递归也有用中序遍历法的。看C位外国友人的实现Q还是比较清晰的Q思\如下Q?1Q如果左子树(wi)不ؓ(f)nullQ处理左子树(wi)    1.aQ递归转化左子?wi)?f)双向链表Q?   1.bQ找出根l点的前p点(是左子树(wi)的最右的节点Q?   1.cQ将上一步找出的节点和根...  <a href='http://www.shnenglu.com/whspecial/archive/2014/01/03/205123.html'>阅读全文</a><img src ="http://www.shnenglu.com/whspecial/aggbug/205123.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/whspecial/" target="_blank">whspecial</a> 2014-01-03 00:41 <a href="http://www.shnenglu.com/whspecial/archive/2014/01/03/205123.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UNIX|络~程MW记http://www.shnenglu.com/whspecial/archive/2013/10/31/204011.htmlwhspecialwhspecialWed, 30 Oct 2013 16:32:00 GMThttp://www.shnenglu.com/whspecial/archive/2013/10/31/204011.htmlhttp://www.shnenglu.com/whspecial/comments/204011.htmlhttp://www.shnenglu.com/whspecial/archive/2013/10/31/204011.html#Feedback1http://www.shnenglu.com/whspecial/comments/commentRss/204011.htmlhttp://www.shnenglu.com/whspecial/services/trackbacks/204011.html
   (1)TCP套接口编E?/strong>
   q里介绍各个接口函数Q?br />   1 文g描述W?/span>
   Qsocket(int domain, int type, int protocol); //生成文g描述W?/span>
   Qbind(int sockfd, struct sockaddr *my_addr, int addrlen); //本地的一个端口绑定到fd上,一般只需要在server?/span>
   2 服务?/span>
   Qlisten(int sockfd, int backlog); //有两个作用:(x)1,主动套接口变ؓ(f)被动套接?2,讄最大连接数backlog
   Qaccept(int sockfd, void *addr, int *addrlen); //为徏立好的连接生成一个新的fd
   3 客户?/span>
   Qconnect(int sockfd, struct sockaddr *serv_addr, int addrlen); //q行socketq接
   4 通信
   Qsend(int sockfd, const void *msg, int len, unsigned int flags); //发送请?/span>
   Qrecv(int sockfd, void *buf, int len, unsigned int flags); //接收h



   (2)I/O多\复用
   I/O多\复用是指内核一旦发现进E指定的一个或者多个IO条g准备dQ它?yu)通知该进E。按照《UNIX|络~程》的说法QI/O多\复用用于以下三种情况Q?br />   a)一个TCP服务器既要处理监听套接口Q又要处理已q接套接口;
   b)一个服务器既要处理TCPQ又要处理UDPQ?br />   c)当客L(fng)处理多个描述字(比如处理交互式输入和|络套接口)
   目前被广泛用的是select和epollQ?br />   2.1,select
   int select(int maxfdp1,fd_set *readset,fd_set *writeset,fd_set *exceptset,const struct timeval *timeout)
   W一个参数指定最大的fd数目Q中间三个分别是被监控的诅R写、异常的fd集,最后一个是时旉。select函数?x)阻塞等待,直到监控的fd集中有fdqAQ或者已l超时?br />   2.2,epoll
   epoll相比于selectQ主要的好处在于它不像select一样去轮询fd集,而是由内核去触发Q另外它支持更大的fd个数

   (3)|络服务器模?/strong>
   其实|络服务器模型还是比较复杂的Q有一比较经典的文章叫做c10K problemQ链接如下:(x)http://www.kegel.com/c10k.html
   q里记录的是很简单的几种多线ETCP服务器模型,Z可以比较下:(x)
   2.1 ȝEacceptQؓ(f)每个client创徏一个线E?br />   2.2 使用U程池,全部acceptQ当有连接来的时候其中某个线E进行处?br />   2.3 使用U程池,ȝEacceptQ当有连接来的时候主U程其攑օ队列Q由工作U程q行处理Q生产?消费者模型)
   1Ҏ(gu)q于频繁地进行线E创建销毁,2Ҏ(gu)在一个连接过来时?x)带来惊现象?Ҏ(gu)?x)比前两个方案要好一些?img src ="http://www.shnenglu.com/whspecial/aggbug/204011.html" width = "1" height = "1" />

whspecial 2013-10-31 00:32 发表评论
]]>
跨机房的hadoop集群http://www.shnenglu.com/whspecial/archive/2013/10/27/203940.htmlwhspecialwhspecialSun, 27 Oct 2013 15:28:00 GMThttp://www.shnenglu.com/whspecial/archive/2013/10/27/203940.htmlhttp://www.shnenglu.com/whspecial/comments/203940.htmlhttp://www.shnenglu.com/whspecial/archive/2013/10/27/203940.html#Feedback0http://www.shnenglu.com/whspecial/comments/commentRss/203940.htmlhttp://www.shnenglu.com/whspecial/services/trackbacks/203940.html

q是来自于阿里技术嘉q华的一个分享,因ؓ(f)在百度也考虑q类似的事情Q所以听得比较有感?zhn)Q这里把相关内容整理一下?/span>

首先重版权Q还是把原链接和作者脓(chung)上:(x)

http://adc.alibabatech.org/carnival/history/schedule/2013/detail/main/286?video=0

来自于阿里吴威工E师的分?/span>

 

首先需要说明一点,跨机?/span>hadoop可能应用场景q不是很多,国内?/span>BATq种巨头也许需要,但是大部分的中小公司也许q不需要这个,也许q是个屠龙之技Q呵c?/span>

把这个问题分三段来讲Q第一D|问题出现的背景,W二D|解决该问题的隄Q第三段是最l的解决Ҏ(gu)?/span>

Q一Q?nbsp;背景Q?/span>

先要看下Z么需要做一个跨机房的大集群Q?/span>

大集的优点在于数据理和授权容易(q个问题在一个多部门的大公司q是很重要的Q;跨部门的使用数据Ҏ(gu)Q无需重复拉取数据?/span>

在集达C定规模时Q单机房Q机房内的容量是有限的)已经无法满集群的需求了Q要想一x逸的解决问题Q需要徏设一个跨机房?/span>hadoop集群?/span>

Q二Q技术挑战:(x)

2.1 NameNode的性能问题Q?/span>

         在管理一个巨大的hadoop集群Ӟ׃原始?/span>Namenode是单节点Q因此会(x)成ؓ(f)一个性能瓉Q遇到的性能问题主要包括两方面:(x)存储定w问题Q存储元数据Q和计算压力Q处?/span>rpchQ修改内存树(wi)时候需要全局锁)问题?/span>

         其中存储定w问题可以依赖内存的垂直扩展来解决Q但是计压力却很难通过提升g来解冻I因ؓ(f)目前厂商的主要发展方向是多核Q而非提高主频Q?/span>

2.2机房之间的网l限Ӟ(x)

         机房之间的网l永q是个硬件条件的限制Q跨机房的网l传输带来了数据延时和带宽限Ӟ(x)

1Q?nbsp;延时一般是?/span>10ms之内Q?/span>hadoop上大部分q行的是ȝ作业Q基本可接受

2Q?nbsp;带宽限制的问题比较大Q因为单机房内的点对点带宽一般是?/span>1GbpsQ而机房之间的带宽在20Mbps左右Q非常有限?/span>

2.3资源l之间的理

         每个部门可以看做一个资源组Q它们可能会(x)互相使用Ҏ(gu)的数据,因此如何规划计算和存储的位置很重要Q否则会(x)在多个机房之间出现大量的数据拯?/span>

Q三Q解x案:(x)

先看下整个跨集群hadoop的架构图Q?/span>


 

重点介绍里面三点Q也是和上面三个问题相对应的:(x)

1Q?nbsp;可以看到q里d了两?/span>NNQ?/span>namenodeQ,它们实际上还是属于一?/span>hadoop集群Q这是业界里的一个解x案:(x)HDFS FedarationQ它Z解决元数据节Ҏ(gu)能问题Q?/span>

2Q?nbsp;可以看到q里有一?/span>cross node节点Q它是用来在两个机房之间同步数据的,它的设计考虑C机房间的|络限制Q?/span>

3Q?nbsp;最后是groupA?/span>groupBQ这是ؓ(f)了解x据出方和用方关系来用的?/span>

3.1 Federation

Federation相关资料见:(x)

http://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/Federation.html#HDFS_Federation


Z水^扩展NamenodeQ?/span>federation使用了多个互相独立的namenode。它们之间互怸需要通信Q每?/span>datenode需要向全部namenode注册q发送信息?/span>

BlockPool是属于一?/span>namenode?/span>block集合Q每?/span>blockpool之间也是互相独立的?/span>

         ?/span>federation里,有一个需要关注的问题Q就是多?/span>namenode的地址如何对用戯行透明Q它采用的解x案是目录?wi)挂载的?gu)Q社区有?/span>viewFSQ应该就是ؓ(f)了解册个问题)Q熟(zhn)?/span>linux或?/span>nfs的朋友应该都知道mountq个概念Q目录树(wi)挂蝲是q个意思?/span>

不过使用目录?wi)挂载也存在着一个问题,是各个子目录下的存储资源需要h为的介入理Q不能出C重的不均?/span>

3.2 crossNode

         机房间的|络限制要求不能出现大规模、长旉的数据拷贝,需要一个专门管理机戉K数据拯的进E,叫做crossNode。它是独立部|的一个节点,和元数据节点是分ȝ?/span>

         它能提供的功能概括来说主要包括以下三点:(x)

aQ?nbsp;Ҏ(gu)预置的跨机房文gQ进行数据拷?/span>

bQ?nbsp;处理实时的数据拷贝请?/span>

cQ?nbsp;q行跨机房的数据量控制

如何得知跨机房文件列表?

         ׃ȝd基本都是定时触发的,可以Ҏ(gu)对历史作业的分析来Ş成一个跨机房文g列表

3.3   资源l之间的理

各个资源l之间存在数据的依赖Q我们希望通过资源l管理,能实现大部分d在本机房内出数据,只有量跨机房出数据;大部分Q务读取本机房的数据副本,只有量跨机房读取数据?/span>

Z标识资源l之间的数据依赖性,定义一个资源组之间的距L念:(x)一个资源组讉K另一个资源组的数据量多Q则两者的距离近Q应该将距离接近的资源组攑֜同一个机房内?/span>

Z让计和产出可能地靠近Q用一?/span>MRProxyQ对于不同类型的d做不同处理:(x)

aQ?span style="font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">            ȝ计算Q跨机房列表中的数据正在传输中(DC1->DC2Q,DC2上的 Job 被暂停调度,{待传输完毕

bQ?span style="font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">            Ad-hoc查询Q?/span>DC2上的 Job 需要读DC1上的数据Q?/span>Job暂停调度Q通知 CrossNodeQ数据传输完毕后l箋调度

cQ?span style="font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">             Ҏ(gu)情况Q跨机房数据 JoinQ?/span>DC1大表Q?/span>DC2表Q?/span>Job 调度?/span>DC1上,跨机房直接读?/span>DC2数据Q无需{待

 

׃是根据视频和ppt整理Qƈ没有代码或者文,所以可能有些地方的理解有偏差,Ƣ迎来提意见~



whspecial 2013-10-27 23:28 发表评论
]]>
KFS代码分析2Qmeta元数据持久化Q?/title><link>http://www.shnenglu.com/whspecial/archive/2013/10/24/203894.html</link><dc:creator>whspecial</dc:creator><author>whspecial</author><pubDate>Wed, 23 Oct 2013 17:03:00 GMT</pubDate><guid>http://www.shnenglu.com/whspecial/archive/2013/10/24/203894.html</guid><wfw:comment>http://www.shnenglu.com/whspecial/comments/203894.html</wfw:comment><comments>http://www.shnenglu.com/whspecial/archive/2013/10/24/203894.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/whspecial/comments/commentRss/203894.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/whspecial/services/trackbacks/203894.html</trackback:ping><description><![CDATA[<p style="line-height:150%"><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">KFS</span><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">的元数据持久化是依赖checkpoint和operation logl合来工作的Q其中checkpoint֐思义保存的是某个点内存的状态,operation log记录的是对元数据修改的操作日志?/span></p> <h1><span style="font-size:12.0pt;font-family:宋体;Times New Roman";Times New Roman"">使用</span><span style="font-size:12.0pt;">checkpoint+log</span><span style="font-size:12.0pt;font-family:宋体;Times New Roman";Times New Roman"">的设?br /></span><span style="font-weight: normal;"><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">Q?Q?span style="font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">    </span></span><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">元数据信息必要持久化,否则掉电(sh)或者h工重启之后该信息丢失<br /></span><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">Q?Q?span style="font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">    </span></span><span style="font-size: 9pt; line-height: 150%; font-family: 宋体;">便于快速重启,可以从最q的一个cp中快速构建内存状态,加上该cp之后的log可以完整地构徏内存<br /><br /></span></span></h1> <h1><span style="font-size:12.0pt;font-family:宋体;Times New Roman";Times New Roman"">d</span><span style="font-size:12.0pt;">checkpoint</span><span style="font-size:12.0pt;font-family:宋体;Times New Roman";Times New Roman"">?/span><span style="font-size:12.0pt;">log</span><span style="font-size:12.0pt;font-family:宋体;Times New Roman";Times New Roman"">的过E?br /><br /></span><strong style="line-height: 150%; font-size: 14px;">Metaserver</strong><strong style="line-height: 150%; font-size: 14px;"><span style="font-family:宋体;">启动时的内存构徏Q?/span></strong></h1> <p style="line-height:150%"><span style="font-family:宋体;">?/span>Startup.cc<span style="font-family:宋体;">调用</span>rebuild<span style="font-family:宋体;">函数</span></p> <p style="margin-left:36.0pt;text-indent:-36.0pt;line-height:150%;">Q?Q?span style="font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">       </span><span style="font-family:宋体;">如果之前已经有了</span>checkpoint<span style="font-family:宋体;">Q从</span>checkpoint<span style="font-family:宋体;">里重建内存树(wi)Q否则新Z内存树(wi)</span></p> <p style="margin-left:36.0pt;text-indent:-36.0pt;line-height:150%;">Q?Q?span style="font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">       </span><span style="font-family:宋体;">在内存中</span>replay<span style="font-family:宋体;">?/span>checkpoint<span style="font-family:宋体;">之后的所?/span>operation log<br /><br /></p> <p style="line-height:150%"><strong>MetaServer</strong><strong><span style="font-family:宋体;">q行时写入新?/span>checkpoint</strong><strong><span style="font-family:宋体;">Q?br /></span></strong></p> <p style="line-height:150%">logcompactor_main.cc<span style="font-family:宋体;">?/span>main<span style="font-family:宋体;">函数调用Q应该是以调用另一个进E的方式来执行,猜想?/span>Metaserver<span style="font-family:宋体;">q程?x)定时调用该q程</span></p> <p style="margin-left:36.0pt;text-indent:-36.0pt;line-height:150%;">Q?Q?span style="font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">       </span><span style="font-family:宋体;">Ҏ(gu)旧的</span>checkpoint<span style="font-family:宋体;">在内存中生成状?/span></p> <p style="margin-left:36.0pt;text-indent:-36.0pt;line-height:150%;">Q?Q?span style="font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">       </span><span style="font-family:宋体;">在内存中</span>replay<span style="font-family:宋体;">之后?/span>op log</p> <p style="margin-left:36.0pt;text-indent:-36.0pt;line-height:150%;">Q?Q?span style="font-size: 7pt; line-height: normal; font-family: 'Times New Roman';">       </span><span style="font-family:宋体;">此时的内存状态写入新?/span>checkpoint<br /><br /></p> <p style="line-height:150%"><strong>MetaServer</strong><strong><span style="font-family:宋体;">q行时写入新?/span>log</strong><strong><span style="font-family:宋体;">Q?/span></strong></p> <p style="line-height:150%"><span style="font-family:宋体;">?/span>logger.cc<span style="font-family:宋体;">来写入新</span>log<span style="font-family:宋体;">Q看了代码应该是每次修改了元信息的操作,都会(x)这?/span>op log<span style="font-family:宋体;">写入盘Q虽然性能不高Q但是比较可靠(之前也自己写q日志库Q用的是两?/span>buffer<span style="font-family:宋体;">交换写入Q这h较高效一些)</span></p><img src ="http://www.shnenglu.com/whspecial/aggbug/203894.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/whspecial/" target="_blank">whspecial</a> 2013-10-24 01:03 <a href="http://www.shnenglu.com/whspecial/archive/2013/10/24/203894.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>KFS代码分析1Qmeta内存l构Q?/title><link>http://www.shnenglu.com/whspecial/archive/2013/10/23/203879.html</link><dc:creator>whspecial</dc:creator><author>whspecial</author><pubDate>Tue, 22 Oct 2013 17:36:00 GMT</pubDate><guid>http://www.shnenglu.com/whspecial/archive/2013/10/23/203879.html</guid><wfw:comment>http://www.shnenglu.com/whspecial/comments/203879.html</wfw:comment><comments>http://www.shnenglu.com/whspecial/archive/2013/10/23/203879.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/whspecial/comments/commentRss/203879.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/whspecial/services/trackbacks/203879.html</trackback:ping><description><![CDATA[<p><span style="font-family: Verdana; font-size: 10pt;">此处的KFS是指</span><span style="font-family: Verdana; font-size: 10pt; line-height: 18px; background-color: #ffffff;">Kosmos distributed file systemQ代码位?/span><span style="font-family: Verdana; font-size: 10pt;"><a >http://sourceforge.net/projects/kosmosfs/</a>Q之后会(x)写几相关的文章Q以供后来者参考?/span><span style="font-family: Verdana; font-size: 10pt;"><br /></span><span style="font-family: 宋体;"><br />KFS里Meta的内存结构主要是一B+?wi),保存在内存里Q具体分析如下:(x)</span></p> <h1><span style="font-size:12.0pt;">B-</span><span style="font-size:12.0pt;font-family:宋体;Times New Roman";Times New Roman"">?wi)?/span><span style="font-size:12.0pt;">B+</span><span style="font-size:12.0pt;font-family:宋体;Times New Roman";Times New Roman"">?wi)的定?/span></h1> <p style="line-height:150%"><span style="font-family:宋体;">关于q些?wi)的定义Q最好还是参考算法导论等l典书,|\上的信息有些不是很准,Z方便大家q是贴一个链接:(x)</span></p> <p style="line-height:150%"><a >http://www.cnblogs.com/oldhorse/archive/2009/11/16/1604009.html</a></p> <h1><span style="font-size:12.0pt;">KFS</span><span style="font-size:12.0pt;font-family:宋体;Times New Roman";Times New Roman"">Z选用</span><span style="font-size:12.0pt;">B+</span><span style="font-size:12.0pt;font-family:宋体;Times New Roman";Times New Roman"">?wi)而非</span><span style="font-size:12.0pt;">B</span><span style="font-size:12.0pt;font-family:宋体;Times New Roman";Times New Roman"">?wi)?/span></h1> <p style="line-height:150%"><span style="font-family:宋体;">q是我个人的理解Q?/span></p> <p style="line-height:150%"><span style="font-family:宋体;">虽然</span>B<span style="font-family:宋体;">?wi)可以在非叶子节点命中,会(x)羃短一些^均查N度,但是</span>B+<span style="font-family:宋体;">?wi)在q种应用一个优势就是每个节炚w有指?/span>next<span style="font-family:宋体;">节点的指针,对于范围查询或者遍历操作很适合。对于文件系l的一?/span>ls<span style="font-family:宋体;">某个子目录的需求,?/span>B+<span style="font-family:宋体;">?wi)可以较高效的解冟?/span></p> <h1><span style="font-size:12.0pt;">KFS</span><span style="font-size:12.0pt;font-family:宋体;Times New Roman";Times New Roman"">?/span><span style="font-size:12.0pt;">B+</span><span style="font-size:12.0pt; font-family:宋体;Times New Roman";Times New Roman"">?wi)的cd<br /></span></h1><p style="line-height: 150%;"><span style="font-size: 11.0pt;line-height:150%"><img src="http://www.shnenglu.com/images/cppblog_com/whspecial/image1.png" width="480" height="184" alt="" /><br />MetaNode</span><span style="font-size:11.0pt;line-height:150%;font-family: 宋体;">Q?/span>base class for both internal and leaf nodes</p> <p style="line-height:150%"><span style="font-size: 11.0pt;line-height:150%">Meta</span><span style="font-size:11.0pt;line-height:150%;font-family: 宋体;">Q?/span>base class for data objects (leaf nodes)</p> <p style="line-height:150%">Node<span style="font-family:宋体;">Q?/span>an internal node in the KFS search tree</p> <p style="line-height:150%">MetaChunkInfo<span style="font-family:宋体;">Q?/span>chunk information for a given file offset </p> <p style="line-height:150%">MetaDentry <span style="font-family:宋体;">Q?/span>Directory entry, mapping a file name to a file id</p> <p style="line-height:150%">MetaFattr<span style="font-family:宋体;">Q?/span>File or directory attributes</p> <h1><span style="font-size:12.0pt;font-family:宋体;Times New Roman";Times New Roman"">各节点的介绍<br /></span></h1> <p style="line-height:150%"><strong><span style="font-family:宋体;">Q?/span>1</strong><strong><span style="font-family:宋体;">Q?/span>Meta</strong><span style="font-family:宋体;">cL子节点的父类Q其最主要的成员变量是</span>fid<br /></p><p style="line-height:150%"><span style="font-family:宋体;">有三个叶子节点:(x)</span>MetaChunkInfo<span style="font-family:宋体;">Q?/span>MetaDentry<span style="font-family:宋体;">Q?/span>MetaFattr<br /><br /></p> <p style="line-height:150%"><strong><span style="font-family:宋体;">Q?/span>2</strong><strong><span style="font-family:宋体;">Q?/span>MetaDentry</strong><strong><span style="font-family:宋体;">Q?/span></strong><span style="font-family:宋体;">实现从文件名?/span>fid<span style="font-family:宋体;">的映,对于每个文gQ目录)都拥?/span>1<span style="font-family:宋体;">?/span>MetaDentry</p><p style="line-height:150%"><span style="font-family:宋体;">成员变量包括Q?/span></p> <p style="line-height:150%">dir<span style="font-family:宋体;">Q文件父目录?/span>fid</p> <p style="line-height:150%">name<span style="font-family:宋体;">Q?/span>dentry<span style="font-family:宋体;">的名Uͼ实际是文g?br /><br /></span></p> <p style="line-height:150%"><strong><span style="font-family:宋体;">Q?/span>3</strong><strong><span style="font-family:宋体;">Q?/span>MetaFattr</strong><strong><span style="font-family: 宋体;">Q?/span></strong><span style="font-family:宋体;">实现?/span>fid<span style="font-family:宋体;">到文件属性的映射Q对于每个文Ӟ目录Q都拥有一?/span>MetaFattr<span style="font-family:宋体;">?br /></span></p><p style="line-height:150%"><span style="font-family:宋体;">成员变量包括Q?/span></p> <p style="line-height:150%">Type<span style="font-family:宋体;">Q文件还是目?/span></p> <p style="line-height:150%">numReplicas<span style="font-family:宋体;">Q文件有几䆾副本</span></p> <p style="line-height:150%">mtime<span style="font-family:宋体;">Q修Ҏ(gu)?/span></p> <p style="line-height:150%">ctime<span style="font-family:宋体;">Q属性修Ҏ(gu)?/span></p> <p style="line-height:150%">crtime<span style="font-family:宋体;">Q文件创建时?/span></p> <p style="line-height:150%">chunkcount<span style="font-family:宋体;">Q连l的</span>chunk<span style="font-family:宋体;">数目</span></p> <p style="line-height:150%">filesize<span style="font-family:宋体;">Q文件大?/span></p> <p style="line-height:150%">nextChunkOffset<span style="font-family:宋体;">Q最后一?/span>chunk<span style="font-family:宋体;">在文件的所处的</span>offset</p> <p style="line-height:150%">mode_t mode<span style="font-family:宋体;">Q文件属性(</span>rwx<span style="font-family:宋体;">位)</span></p> <p style="line-height:150%">key<span style="font-family:宋体;">Q由</span>KFS_FATTR<span style="font-family:宋体;">Q?/span>fid<span style="font-family:宋体;">来构成,可以通过</span>fid<span style="font-family:宋体;">直接扑ֈ保存文g属性的节点?br /></span><br /> <strong><span style="font-family:宋体;">Q?/span>4</strong><strong><span style="font-family:宋体;">Q?/span>MetaChunkInfo</strong><strong><span style="font-family: 宋体;">Q?/span></strong><span style="font-family:宋体;">标志某个文g对应?/span>chunk<span style="font-family:宋体;">信息Q如果一个文件包含多?/span>chunk<span style="font-family:宋体;">Q那么需要有多个</span>MetaChunkInfo<span style="font-family:宋体;">?br /></span></p><p style="line-height:150%"><span style="font-family:宋体;">成员变量包括Q?/span></p> <p style="line-height:150%">offset<span style="font-family:宋体;">Q?/span>chunk<span style="font-family:宋体;">在文件中的偏U量Q因Z个文件可能由多个</span>chunk<span style="font-family:宋体;">l成</span></p> <p style="line-height:150%">chunkId<span style="font-family:宋体;">Q?/span>chunk<span style="font-family:宋体;">?/span>id<span style="font-family:宋体;">?/span></p> <p style="line-height:150%">chunkVersion<span style="font-family:宋体;">Q?/span>chunk<span style="font-family:宋体;">?/span>version<span style="font-family:宋体;">?br /><br /></span></p> <p style="line-height:150%"><strong><span style="font-family:宋体;">Q?/span>5</strong><strong><span style="font-family:宋体;">Q?/span>Node</strong><strong><span style="font-family: 宋体;">Q?/span></strong><span style="font-family:宋体;">实现的是</span>B+<span style="font-family:宋体;">?wi)的内部节点Q这U节点仅仅作为烦引用途,存储实际元数据信息的节点位于最底部的叶子节炏V?br /></span></p><p style="line-height:150%"><span style="font-family:宋体;">成员变量包括Q?/span></p> <p style="line-height:150%">NKEY = 32<span style="font-family:宋体;">Q每个节Ҏ(gu)多拥有的关键字数目,实际上也是最多拥有的子节Ҏ(gu)目,如果多余q个D点进行分?/span></p> <p style="line-height:150%">NSPLIT = NKEY / 2<span style="font-family:宋体;">Q分裂之后每个节点的关键字数?/span></p> <p style="line-height:150%">NFEWEST = NKEY - NSPLIT<span style="font-family:宋体;">Q每个节Ҏ(gu)拥有的关键字数目,如果于q个g个节点进行合q?/span></p> <p style="line-height:150%">count<span style="font-family:宋体;">Q节点实际拥有的关键字数?/span></p> <p style="line-height:150%">Key childKey[NKEY]<span style="font-family:宋体;">Q节点存储的关键字列?/span></p> <p style="line-height:150%">MetaNode *childNode[NKEY]<span style="font-family:宋体;">Q节Ҏ(gu)向子节点的指针列?/span></p> <p style="line-height:150%">Node *next<span style="font-family:宋体;">Q指向下一个同U节点的指针</span></p> <p style="line-height:150%"><span style="font-family:宋体;">实际上每个内部节点的阶数?/span>32<span style="font-family:宋体;">Q可以有</span>32<span style="font-family:宋体;">个子节点Q而每个叶子节点只保存一?/span>key<span style="font-family:宋体;">倹{?/span></p> <h1><span style="font-size:12.0pt;font-family:宋体;Times New Roman";Times New Roman"">三类子节点在</span><span style="font-size:12.0pt;">B+</span><span style="font-size:12.0pt;font-family:宋体;Times New Roman";Times New Roman"">?wi)中如何分布Q?/span></h1> <p style="line-height:150%"><span style="font-family:宋体;">可以惌Q必定是同一cȝ节点聚集在一赗因此对于排序函数就是先比较节点cdQ然后再对节点内部的成员变量q行比较?/span>MetaDentry<span style="font-family:宋体;">是根?/span>dir<span style="font-family:宋体;">Q父目录?/span>id<span style="font-family:宋体;">Q,</span>MetaFattr<span style="font-family:宋体;">是根?/span>fid<span style="font-family:宋体;">Q?/span>MetaChunkInfo<span style="font-family:宋体;">是根?/span>id<span style="font-family:宋体;">?/span>chunkId<span style="font-family:宋体;">来排序?/span></p> <h1><span style="font-size:12.0pt;font-family:宋体;Times New Roman";Times New Roman"">一个不太相关的思?/span></h1> <p style="line-height:150%"><span style="font-size: 10pt; line-height: 150%; font-family: 宋体;">看上面的三类子节点,我们可以发现chunk的位|信息ƈ没有保存在B+?wi)里Q它是单独保存在一个Map数据l构里的Q也不会(x)在meta server里进行持久化Q而是每次chunk启动时向meta server来报告。之所以不做持久化Q可以这h理解Q?/span></p> <p style="line-height:150%"><span style="font-size: 10pt; line-height: 150%; font-family: 宋体;">只有Chunk服务器才能最l确定一个Chunk是否在它的硬盘上。Chunk服务器的错误可能?x)导致Chunk自动消失(比如Q硬盘损坏了或者无法访问了)Q亦或者操作h员可能会(x)重命名一个Chunk服务器,q是由chunk server来报告比较靠谱?/span></p><img src ="http://www.shnenglu.com/whspecial/aggbug/203879.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/whspecial/" target="_blank">whspecial</a> 2013-10-23 01:36 <a href="http://www.shnenglu.com/whspecial/archive/2013/10/23/203879.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Dremel存储格式解析http://www.shnenglu.com/whspecial/archive/2013/08/14/202546.htmlwhspecialwhspecialWed, 14 Aug 2013 15:17:00 GMThttp://www.shnenglu.com/whspecial/archive/2013/08/14/202546.htmlhttp://www.shnenglu.com/whspecial/comments/202546.htmlhttp://www.shnenglu.com/whspecial/archive/2013/08/14/202546.html#Feedback1http://www.shnenglu.com/whspecial/comments/commentRss/202546.htmlhttp://www.shnenglu.com/whspecial/services/trackbacks/202546.html    Dremel是google推出的又一器Qpaper中U能够在3s内分?PB的数据,主要是面向交互式查询。这paper对嵌套类型的存储方式斚wQ思维实有些跌Q这文章主要讲讲这个,一斚w是方便后来者理解,另一斚w是让自己也整理下思\?br />

    首先Dremel使用的是列存模型Q对于基本类型列存较Ҏ(gu)做到Q但是对于嵌套类型,Dremel也能做到其拆解成基本类型ƈq行列存Q这是值得我们研究的?br />

    直观看下嵌套cd按行存储和拆解后按列存储的对比效果:(x)

    然后对于嵌套数据cdQDremel里面定义了里面三U类型的字段

    1Q必d?ơ而且仅出?ơ的字段Qrequired

    2Q可能出?ơ或?ơ的字段Qoptional

    3Q可能出?ơ或者Nơ字D:(x)repeated

    下面以paper的例子来讲述吧:(x)

    其中DocId是required字段Q因此在r1,r2中必d?ơ;url字段是optional字段Q因此在r1的第三个Name里未出现Q在r1的前两个Name里出C1ơ;Backward字段是repeated字段Q因此在r1的Links里未出现Q在r2的Links里出C2ơ?br />

    理解了上面这些,直接来看下Dremel是怎么来存它的吧:(x)

    上表中的每条记录都有两个属性,"r"代表repetition levelQ?d"代表definition levelQ定义如下:(x)

    repetition level:what repeated field in the field’s path the value has repeatedQ记录该字段是在哪个repeatedU别上重复的

    definition level:how many fields inpthat could be undefined (because they are optional or repeated) are actually presentQ记录该字段之上有多个optional或者repeated字段实际是有值的Q本来可以ؓ(f)null的)

    看到q里Q各位可能已l在心里默念了:(x)WTFQ别急,可以l合一个例子来看:(x)

先看repetition levelQ下面以r替代Q,以Name.Language.CodeZQ?/p>

    1)对第1个出现的|其r始终?Q因?en-us'的r?

    2)对于W?个?en'Q其上一个值是'en-us'Q它们是在LanguageU别发生的重复,Name.Language是两U的repeated字段Q因此r?

    3)对于W?个值nullQ是Z记录'en-gb'是出现在W三个Name而非W二个Name里,Ҏ(gu)占位用的。null的上一个值是'en'Q它们是在NameU别发生的重复,因此r?

    4)对于W?个?en-gb'Q其上一个值是nullQ它们也是在NameU别发生的重复,因此r?

    5)对于W?个值nullQ其上一个值是'en-gb'Q它们出现在两个不同Document里,因此r?

    ȝ下,看repetition level注意两点Q?,只比较该值和上一个|2,只需要看q两个值的重复位置上有几个repeated字段

再看definition levelQ下面以d替代Q,也以Name.Language.CodeZQ?/p>

    1)对于'en-us'Q其上的NameQLanguage都出CQ因此d?Q其实对于非null值的字段Q其上的optional或者repeated字段肯定是出CQ所以都是相同的Q只是null字段的d值有差别Q?br />

    2)对于'en'Q同理d也ؓ(f)2

    3)对于nullQ其上只出现了NameQ没有出现LanguageQ因此d?

    4)对于'en-gb',d也ؓ(f)2

    5)对于最后一个nullQ其上也只出CNameQ没有出现LanguageQ因此d?


    以上只是讲了dremel怎么d嵌套cdQ至于这U存法是怎么惛_来的Q真非我辈能理解的了。。。更多内容,请参考原著paper?qing)网上解析?br />



whspecial 2013-08-14 23:17 发表评论
]]>
Orcfile文g格式解析Q?Q?/title><link>http://www.shnenglu.com/whspecial/archive/2013/08/14/202545.html</link><dc:creator>whspecial</dc:creator><author>whspecial</author><pubDate>Wed, 14 Aug 2013 15:13:00 GMT</pubDate><guid>http://www.shnenglu.com/whspecial/archive/2013/08/14/202545.html</guid><wfw:comment>http://www.shnenglu.com/whspecial/comments/202545.html</wfw:comment><comments>http://www.shnenglu.com/whspecial/archive/2013/08/14/202545.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/whspecial/comments/commentRss/202545.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/whspecial/services/trackbacks/202545.html</trackback:ping><description><![CDATA[<p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    上篇文章从整体介l了Orcfile的存储格式,接下来重点介l下Orc里用到的几种~码格式Q?/p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    字典~码Q用于Stringcd的字D?br /></p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    Run-Length~码Q用于intQlongQshort{类型的~码</p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    Bit~码Q可以用于各U数据类?br /></p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;"><strong>1Q字典编码:(x)</strong></p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    对于Stringcd的每个字D分别保存一个字典,记录每个值在字典中的位置Q保存字典的数据l构采用一늺黑树(wi)。对于每个String字段Q最l会(x)有三个输出StreamQ分别是StringOuptut(记录字典中的?QLengthOutput(记录每个字典值的长度)QRowOutput(记录字段在字怸的位|??/p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    思?Qؓ(f)什么要用红黑树(wi)Q?br /></p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    因ؓ(f)U黑?wi)无论是插入Q删除,查找的性能都比较^均,都是O(logN)Q而且是^衡查找树(wi)Q最坏情况也不会(x)退化成O(N)<br /></p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    思?Q其实一般存储时q会(x)使用LZO之类的压~,它们本n是一U字典压~,Z么Orc里面要自己做字典压羃Q?br /></p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    因ؓ(f)LZO之类的压~窗口一般比较小QLZO默认?4KBQ,而Orc的字典压~是以整个字Dؓ(f)范围来压~的Q压~率?x)更好?br /></p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;"><strong>2QRun-Length~码Q?/strong><br /></p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    对于int,long,shortcd的字D,使用Run-Length~码。该Run-Length能够对等差数列(完全相等也属于等差数列)q行压羃Q该{差数列需要满以下两个条Ӟ(x)</p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    1Q至包?个元?/p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    2Q差值在-128~127之间Q因为差值用1Byte来表C)</p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    对于不满等差数列的数字QRun-Length~码也能存储Q但是没有压~效果,Run-Length的具体存储如下:(x)</p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    W一个Byte是Control ByteQ取值在-128~127之间Q其?1~-128代表后面存储着1~128个不满{差数列的数字,0~127代表后面存储着3~130个等差数列的数字Q?/p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    如果Control Byte>=0Q则后面跟着一个Byte存储差|否则不存储该ByteQ?/p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    如果Control Byte>=0Q则后面跟着{差数列的第一个数Q否则跟着-Control Byte个数字?/p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    例子Q?/p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    原始数字Q?2,12,12,12,12,10,7,13</p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    l过Run-Length的数字:(x)<span style="color: #ff0000;">2</span>,<span style="color: #ffc000;">0</span>,12,<span style="color: #ff0000;">-3</span>,10,7,13</p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    U色代表Control ByteQ黄色代表差|黑色代表具体的数字?br /></p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;"><strong>3QBit~码Q?/strong></p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">Ҏ(gu)有类型的字段都可以采用Bit~码来表C值是否ؓ(f)null。在写Q何类型字D之前,先判断该字段值是够ؓ(f)nullQ如果ؓ(f)null则bit值存?Q否则存?Q对于ؓ(f)null的字D在实际~码时不需要存储了。经qBit~码之后Q可以对?个bitl成一个ByteQ再对其q行Run-Length~码?/p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    其实除了q三U编码格式之外,Orc对于hive的复杂类型array,map,list{,其降维成基本类型来存储Q这个也是值得借鉴的,如果有空之后?x)进行分析?/p><img src ="http://www.shnenglu.com/whspecial/aggbug/202545.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/whspecial/" target="_blank">whspecial</a> 2013-08-14 23:13 <a href="http://www.shnenglu.com/whspecial/archive/2013/08/14/202545.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Orcfile文g格式解析Q?Q?/title><link>http://www.shnenglu.com/whspecial/archive/2013/08/14/202544.html</link><dc:creator>whspecial</dc:creator><author>whspecial</author><pubDate>Wed, 14 Aug 2013 15:12:00 GMT</pubDate><guid>http://www.shnenglu.com/whspecial/archive/2013/08/14/202544.html</guid><wfw:comment>http://www.shnenglu.com/whspecial/comments/202544.html</wfw:comment><comments>http://www.shnenglu.com/whspecial/archive/2013/08/14/202544.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/whspecial/comments/commentRss/202544.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/whspecial/services/trackbacks/202544.html</trackback:ping><description><![CDATA[<p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    Orcfile(<em>Optimized Row Columnar</em>)是hive 0.11版里引入的新的存储格式,是对之前的RCFile存储格式的优化。写q个的哥们来自于HortonWorksQ代码写的很不错Q比之前的rcfile强多了(据说rcfile是个中科院的童鞋跑去facebook写的Q看来中国的计算机教育水q是有限啊。。。囧Q跑题了Q?/p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    先介l下Orc的文件格式,截一张官方的图:(x)<br /></p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;"><a target="_blank" data_ue_src="http://blog.51cto.com/attachment/201306/234709762.png"><img src="http://blog.51cto.com/attachment/201306/234709762.png" title="OrcFileLayout.png" data_ue_src="http://blog.51cto.com/attachment/201306/234709762.png" alt="" /></a></p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    可以看到每个Orc文g?个或多个stripel成Q每个stripe250MB大小Q这个Stripe实际相当于之前的rcfile里的RowGroup概念Q不q大由4MB->250MBQ这样应该能提升序ȝ吞吐率。每个Stripe里有三部分组成,分别是Index Data,Row Data,Stripe FooterQ?/p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    1QIndex DataQ一个轻量的indexQ默认是每隔1W行做一个烦引。这里做的烦引应该只是记录某行的各字D在Row Data中的offsetQ据说还包括每个Column的max和min|具体没细看代码?/p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    2QRow DataQ存的是具体的数据,和RCfile一P先取部分行,然后对这些行按列q行存储。与RCfile不同的地方在于每个列q行了编码,分成多个Stream来存储,具体如何~码在下一解析里?x)讲?/p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    3QStripe FooterQ存的是各个Stream的类型,长度{信息?/p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    每个文g有一个File FooterQ这里面存的是每个Stripe的行敎ͼ每个Column的数据类型信息等Q每个文件的N是一个PostScriptQ这里面记录了整个文件的压羃cd以及(qing)FileFooter的长度信息等。在d文gӞ?x)seek到文件尾部读PostScriptQ从里面解析到File Footer长度Q再读FileFooterQ从里面解析到各个Stripe信息Q再d个StripeQ即从后往前读?/p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    接下来看下ORcfile相对于RCfile做了哪些改进Q从Orc作者的ppt里截了张图,分别解释下各行:(x)<br /></p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;"><a target="_blank" data_ue_src="http://blog.51cto.com/attachment/201306/003840639.png"><img src="http://blog.51cto.com/attachment/201306/003840639.png" title="囄1.png" width="500" height="345" border="0" hspace="0" vspace="0" data_ue_src="http://blog.51cto.com/attachment/201306/003840639.png" style="width: 500px; height: 345px;" alt="" /></a></p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    Hive type model:RCfile在底层存储时不保存类型,都当做Byte来存储</p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    Separtor complex columns:Orc复杂类型拆开存储</p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    Splits Found QuicklyQ不很理?br /></p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    Default Column group sizeQ不用解释了</p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    Files per a bucketQ不很理?/p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    Store minQmaxQcountQsumQ存了这些便于快速地skip掉一个stripe</p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    Versioned metadata:不很理解<br /></p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    Run-Length Data-codingQ整数类型做Run-Length变长~码</p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    Store Strings in dictionaryQStringcd做字典编?/p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    Store Row CountQ每个Stripe?x)存储行?/p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    Skip Compressed blocks:可以直接skip掉压~过的block</p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    Store internal indexes:存储了一个轻量的index</p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;"><br /></p><p style="margin-right: 0px; margin-left: 0px; font-family: sans-serif; font-size: 16px; line-height: normal;">    整个Orc看下来,代码写的q是比较清晰明了的,而且我们也进行了试Q压~效果比RCfile提升了不,有兴的朋友可以来看下,之后?x)写W二解析,主要是讲Orc用到的几U编码格式?br /></p><div></div><img src ="http://www.shnenglu.com/whspecial/aggbug/202544.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/whspecial/" target="_blank">whspecial</a> 2013-08-14 23:12 <a href="http://www.shnenglu.com/whspecial/archive/2013/08/14/202544.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>лǵվܻԴȤ</p> <a href="http://www.shnenglu.com/" title="精品视频久久久久">精品视频久久久久</a> <div class="friend-links"> </div> </div> </footer> <a href="http://www.rsfrw.cn" target="_blank">www.þ.com</a>| <a href="http://www.dm739.cn" target="_blank">ŷƷþþ</a>| <a href="http://www.hzks666.cn" target="_blank">Ʒ99Ʒþ</a>| <a href="http://www.ekqz.cn" target="_blank">99þþùƷС˵</a>| <a href="http://www.ksxhsd.cn" target="_blank">þƬѹۿ</a>| <a href="http://www.haolepay.cn" target="_blank">AëƬþþƷ</a>| <a href="http://www.coldcha.cn" target="_blank">þþƷƵ</a>| <a href="http://www.vstmall.com.cn" target="_blank">97þþƷˬ</a>| <a href="http://www.114tmall.cn" target="_blank">þþƷ9988</a>| <a href="http://www.ccubaei.cn" target="_blank">þûƵ</a>| <a href="http://www.2tou.cn" target="_blank">8090Ʒþһ </a>| <a href="http://www.dgvs.cn" target="_blank">þ99Ʒþþþþþò</a>| <a href="http://www.link133.cn" target="_blank">޾ƷþëƬ</a>| <a href="http://www.rainbows.net.cn" target="_blank">һþöۺ</a>| <a href="http://www.nxxq5.cn" target="_blank">ҹƷþþþþӰriav</a>| <a href="http://www.003kd.cn" target="_blank">ȾþӾþþƷ18</a>| <a href="http://www.xingtaiidc.cn" target="_blank">7777þþùƷ</a>| <a href="http://www.vlbx.cn" target="_blank">ҹavþþþ</a>| <a href="http://www.dliif.cn" target="_blank">þùɫAVѹۿ</a>| <a href="http://www.sun-yan.cn" target="_blank">ɫۺϾþþƷĻҳ</a>| <a href="http://www.tyo8.cn" target="_blank">26uuuþ</a>| <a href="http://www.xfidc.com.cn" target="_blank">˾þóۺӰԺ </a>| <a href="http://www.qgnz.net.cn" target="_blank">þԭƷӰԺ</a>| <a href="http://www.jobs0593.cn" target="_blank">޳˾þ</a>| <a href="http://www.f-lover.cn" target="_blank">ƷŮٸAVѾþ</a>| <a href="http://www.wy369.com.cn" target="_blank">պƷþþþþ</a>| <a href="http://www.nlzm.net.cn" target="_blank">þþݾþþ</a>| <a href="http://www.csrjgzs.cn" target="_blank">þþƷAV</a>| <a href="http://www.xcfsfl.cn" target="_blank">Ļþҹ</a>| <a href="http://www.ebianlian.cn" target="_blank">þòӰ</a>| <a href="http://www.67yule.cn" target="_blank">ҹƷþþþ</a>| <a href="http://www.76288.com.cn" target="_blank">ձѾþþþþþվ</a>| <a href="http://www.114tmall.cn" target="_blank">޾Ʒþþþþò</a>| <a href="http://www.bosot.cn" target="_blank">ۺϾþùһ鶹</a>| <a href="http://www.a79wvh.cn" target="_blank">ɫۺϾþĻ</a>| <a href="http://www.94byq.cn" target="_blank">þƵᆱƷ99㽶</a>| <a href="http://www.dengbilong6.com.cn" target="_blank">Ʒþþþþ</a>| <a href="http://www.5490.com.cn" target="_blank">þҹɫƷav</a>| <a href="http://www.zhangyiping.cn" target="_blank">þó鱬Ļ</a>| <a href="http://www.gkxee.cn" target="_blank">ٸþþþþñŪ߳</a>| <a href="http://www.33k4.cn" target="_blank">Ʒþ99</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>