- 浏览: 44727 次
- 性别:
- 来自: 深圳
最新评论
文章列表
http://www.cloudera.com/resources/rpc-and-serialization-in-hadoop
RPC and Serialization with Hadoop, Thrift, and Protocol Buffers
This post was originally written by Tom White, published here.
Hadoop and related projects like Thrift provide a choice of protocols and formats for doing RPC and serial ...
protocol buffer(以下简称PB)作为一种效率和兼容性都很优秀的二进制数据传输格式,可以用于诸如
网络传输,配置文件,数据存储等诸多领域。本文的分析基于google发布的源码2.0.1版本
PB的源码结构大致如下:
PB源码
{
...
String.format中参数的形式:
%[argument_index$][flags][width][.precision]conversion
e.g:
%1$-10.2s
- 2009-11-24 10:34
- 浏览 661
- 评论(0)
今天coding的时候,用到了byte[]数组作为hashmap的key值,测试的时候,发现不能够根据相同的byte[],得到相应的value值,google了一下,发现,byte[]数组作为key值,只是数组的地址的引用的hashcode,不能够根据byte[]数组的内容来,创建相应的hashcode,也就是所谓的索引key。所以,如果想用byte[]数组来作为map的key值的话,有三种方法:
1.将byte[],先转化为string,
2.将采用list<byte>
3.将byte[]自己包装,使用byte[]数组的内容来重写hashcode和euquals方法,
write ...
- 2009-11-05 22:00
- 浏览 3360
- 评论(0)
Java has several classes for reading files, with and without buffering, random access, thread safety, and memory mapping. Some of these are much faster than the others. This tip benchmarks 13 ways to read bytes from a file and shows which ways are the fastest.
Table of Contents
A quick review of fil ...
- 2009-10-12 20:42
- 浏览 1090
- 评论(0)
原文:http://www.linuxdiyf.com/blog/?69548/action_viewspace_itemid_1385.html
/bin:存放着一百多个Linux下常用的命令、工具
/dev:存放着Linux下所有的设备文件!
/home:用户主目录,每建一个用户,就会在这里新建一个与用户同名的目录,给该用户一个自 ...
- 2009-09-27 11:57
- 浏览 1208
- 评论(0)
当调用sleep ,yield 的时候,并不释放所拥有的锁,
而调用wait的时候,则释放所拥有的锁,
Thread.sleep(long milliseconds): sends the current thread into Non-Runnable state for the specified amount of time. But, this doesn’t cause the thread to loose ownership of the acquired monitors. So, if the current thread is into a synchronized bloc ...
- 2009-09-24 15:28
- 浏览 659
- 评论(0)
I often see people confuse different ways MySQL can use indexing, getting wrong ideas on what query performance they should expect. There are 3 main ways how MySQL can use the indexes for query execution, which are not mutually exclusive, in fact some queries will use indexes for all 3 purposes liste ...
- 2009-09-18 12:04
- 浏览 798
- 评论(0)
Index Optimization Tips
*****
* Consider creating index on column(s) frequently used in the WHERE, ORDER BY, and GROUP BY clauses.
These column(s) are best candidates for index creating. You should analyze your queries very attentively to avoid creating not useful indexes.
* ...
- 2009-09-18 12:02
- 浏览 700
- 评论(0)
// BAD CODE - DO NOT EMULATE
public class LeakyChecksum {
private byte[] byteArray;
public synchronized int getFileChecksum(String fileName) {
int len = getFileSize(fileName);
if (byteArray == null || byteArray.length < len)
byteArray = new byte[len];
...
- 2009-09-10 21:59
- 浏览 666
- 评论(0)
weak reference
A weak reference is one that does not prevent the referenced object from being garbage collected. You might use them to manage a HashMap to look up a cache of objects. A weak reference is a reference that does not keep the object it refers to alive. A weak reference is not counted ...
- 2009-09-10 20:49
- 浏览 781
- 评论(0)
网上搜索的结果,实践验证后记录
早在JDK 1.2的版本中就提供java.lang.ThreadLocal,ThreadLocal为解决多线程程序的并发问题提供了一种新的思路。ThreadLocal并不是一个Thread,而是Thread的局部变量,也许把它命名为ThreadLocalVariable更容易让人理解一些。
当使用ThreadLocal维护变量时,ThreadLocal为每个使用该变量的线程提供独立的变量副本,所以每一个线程都可以独立地改变自己的副本,而不会影响其它线程所对应的副本。
ThreadLocal类接口很简单,只有4个方法,我们先来了解一下:
void set(O ...
- 2009-09-09 19:53
- 浏览 629
- 评论(0)
1。对于已经建立好的WrokSet,我们如果想直接添加或者减少其中的文件的时候,要打开Edit WrokSet来编辑,比较麻烦,现在Eclipse已经有快捷的工具栏,可以直接把Packager Explorer里面的选择的文件直接添加或除去。
2.有些用户经常编辑代码,又嫌显示器的空间不够,想把toolbar隐藏掉来扩大空间,现在Eclipse提供了这个新功能,直接再Eclipse的工具栏上面上面点击Hide ToolBar就可以隐藏掉工具栏,如果想再显示了,在Windows菜单里面选择Show Toolbar就可以显示了。
3.在一般情况下,我们再Package Explorer里面最 ...
- 2009-09-07 11:28
- 浏览 781
- 评论(0)
Eclipse(3.3)高级技巧(一)
1.当一个类比较大的时候,我们用鼠标滑轮往下移动的时候有时候总觉得比较慢,这时如果我们按住Ctrl键然后再滑动滚轮的时候,那么每滚一下都会翻整个页面,那么浏览的速度就大大加快了。
2.Eclipse中加入了重构脚本(Refactoring Script),如果用户经常有重复的重构的话,可以再refactor菜单里面选择Create Script可以把当前的重构脚本保存下来,下次想用的时候,可以用菜单里面的Apply refactoring直接调用脚本就可以。不用手动的去refactoring。
3.如果你剪贴板里面复制了整个java文件的源码(包括 ...
- 2009-09-07 11:26
- 浏览 973
- 评论(0)
介绍NIO,不错的文章:
http://www.ibm.com/developerworks/java/library/j-javaio/#resources
another good article
http://www.javaworld.com/javaworld/jw-09-2001/jw-0907-merlin.html?page=7#sidebar1
- 2009-09-03 20:25
- 浏览 855
- 评论(0)