渴死的火烈鸟
standalone · 共 356 篇文章
zookeeper介绍
ZooKeeper是Hadoop的正式子项目,它是一个针对大型分布式系统的可靠协调系统,提供的功能包括:配置维护、名字服务、分布式同步、组服务等。ZooKeeper的目标就是封装好复杂易出错的关键服务,将简单易用的接口和性能高效、功能稳定的系统提供给用户。 Zookeeper是Google的Chubby一个开源的实现.是高有效和可靠的协同工作系统.Zookeeper能够用来leader选举,配置信息维护等.在一个分布式的环境中,我们需要一个Master实例或存储一些配置信息,确保文件写入的一致性等.Zookeeper能够保证如下3点: Watches are ordered with res…
how to reverse the word sequence in a sentence?
For example, "Welcome you to Beijing" is reversed into "Beijing to you Welcome" void ReverseString(char *s, int start, int end) 2{ 3 while (start < end) 4 { 5 if (s[start] != s[end]) 6 { 7 s[start] ^= s[end]; 8 s[end] ^= s[start]; 9 s[start] ^= s[end]; 10 } 11 12 start++; 13 end--; 14 } 15} 16 17 v…
2010-07-06 22:01 · c++ · 评论(0)
How to delete a node in a LinkList ?
If only given the pointer to the node to be deleted? Note the node is not the first one nor the last. 如果在单链表中删除一个指定的结点? 需要注意的是不是头尾结点。 这到题其实就是个小技巧,没有告诉前面的一个结点怎么做删除呢?答案就是把后面结点的内容拷贝过来!这个问题的前提是结点不能使首尾结点,否则就没法做了。 假设数据内容是整型,简化问题。 void delete(Node p){ Node q = p.next; p.data = q.data; p.next = q.next; }
2010-07-06 21:22 · algorithm · 评论(0)
deep copy & shallow copy
A shallow copy of an object copies all of the member field values. This works well if the fields are values, but may not be what you want for fields that point to dynamically allocated memory. The pointer will be copied. but the memory it points to will not be copied -- the field in both the origin…
2010-07-06 20:57 · c++ · 评论(0)
copy constructor and copy assignment
When copies of objects are made A copy constructor is called whenever a new variable is created from an object. This happens in the following cases (but not in assignment). A variable is declared which is initialized from another object , eg, Person q("Mickey"); // constructor is used to build q. P…
2010-07-06 20:47 · c++ · 评论(0)
HDFS中不起作用的buffer size
/** * Create a new output stream to the given DataNode. * @see ClientProtocol#create(String, FsPermission, String, boolean, short, long) */ DFSOutputStream(String src, FsPermission masked, boolean overwrite, short replication, long blockSize, Progressable progress, int buffersize, int bytesPerCheck…
2010-05-12 11:38 · hadoop · 评论(1)
Plot CDF Graph
Sub calculateCDF() ' ' caculateCDF Macro ' ' Range("M2").Select Selection.EntireRow.Delete Do While Range("M2").Value < 1 And Not IsEmpty(Range("M2")) Range("M2").Select Selection.EntireRow.Delete Loop If IsEmpty(Range("M2")) Then Exit Sub End If Dim row As Integer row = Range("M2").End(xlDown).row…
2010-04-29 09:37 · VBA · 评论(0)
Efficient data transfer through zero copy
http://www.ibm.com/developerworks/linux/library/j-zerocopy/ http://www.linuxjournal.com/article/6345?page=0,1
2010-03-19 10:47 · java · 评论(0)
awk使用实例
awk使用实例(转载) 2009-08-25 16:41 简介 awk是一种编程语言,非常适合处理文本,使用简单,功能却很强大。awk扫描文件中的每一行,查找与命令行中所给定内容相匹配的模式。如果发现匹配内容,则进行下一个编程步骤。如果找不到匹配内容,则继续处理下一行 示例 基本使用 输出文件的第一列 awk '{print $1}' access_log 使用自定义的分隔符(默认是空格) awk -F ', ' '{print $1}' access_log awk -F '&q=' '{print $2}' access_log 条件判断 awk '$9==304 {print}' ac…
2010-02-09 15:47 · linux · 评论(0)
java程序员面试必备的32个要点
很经典的东西,被转的到处都是, 先写原文: 第一,谈谈final, finally, finalize的区别。 final 用于声明属性,方法和类,分别表示属性不可变,方法不可覆盖,类不可继承。finally是异常处理语句结构的一部分,表示总是执行。finalize是 Object类的一个方法,在垃圾收集器执行的时候会调用被回收对象的此方法,可以覆盖此方法提供垃圾收集时的其他资源回收,例如关闭文件等。 第二,Anonymous Inner Class (匿名内部类) 是否可以extends(继承)其它类,是否可以implements(实现)interface(接口)? 可以继承其他类或完成其…
2010-02-08 13:16 · java · 评论(0)
static全局变量与普通的全局变量有什么区别
static全局变量与普通的全局变量有什么区别?static局部变量和普通局部变量有什么区别?static函数与普通函数有什么区别? 答 、全局变量(外部变量)的说明之前再冠以static 就构成了静态的全局变量。全局变量本身就是静态存储方式, 静态全局变量当然也是静态存储方式。这两者在存储方式上并无不同。这两者的区别虽在于非静态全局变量的作用域是整个源程序,当一个源程序由多个源文件组成时,非静态的全局变量在各个源文件中都是有效的。而静态全局变量则限制了其作用域, 即只在定义该变量的源文件内有效,在同一源程序的其它源文件中不能使用它。由于静态全局变量的作用域局限于一个源文件内,只能为该源文件…
2010-02-08 11:27 · c++ · 评论(1)
java5中使用interrupt()来停止java线程的方法
在开发java多线程时,如果要停止线程这个问题很头痛吧,不过在Java5的java.util.concurrent中使用interrupt(),让线程在run方法中停止。 简介 在Java的多线程编程中,java.lang.Thread类型包含了一些列的方法start(), stop(), stop(Throwable) and suspend(), destroy() and resume()。通过这些方法,我们可以对线程进行方便的操作,但是这些方法中,只有start()方法得到了保留。 在Sun公司的一篇文章《Why are Thread.stop, Thread.suspend and…
2010-02-08 09:52 · java · 评论(0)
wait()和sleep()的区别
这两者的施加者是有本质区别的. sleep()是让某个线程暂停运行一段时间,其控制范围是由当前线程决定,也就是说,在线程里面决定.好比如说,我要做的事情是 "点火->烧水->煮面",而当我点完火之后我不立即烧水,我要休息一段时间再烧.对于运行的主动权是由我的流程来控制. 而wait(),首先,这是由某个确定的对象来调用的,将这个对象理解成一个传话的人,当这个人在某个线程里面说"暂停!",也是 thisOBJ.wait(),这里的暂停是阻塞,还是"点火->烧水->煮饭",thisOBJ就好比一个监督我的人站在我旁边,本来该线 程应该执行1后执行2,再执行3,而在2处被那个对象喊暂停,那么我就会…
2010-02-08 08:57 · java · 评论(0)
HDFS
Run hadoop fsck / will give you summary of current HDFS status including some useful information : Minimally replicated blocks: 51224 (100.0 %) Over-replicated blocks: 0 (0.0 %) Under-replicated blocks: 0 (0.0 %) Mis-replicated blocks: 7 (0.013665469 %) Default replication factor: 3 Average block r…