ITeye博客

tmrp

tmrp · 共 37 篇文章

RPC and Serialization with Hadoop, Thrift, and Protocol Buffers

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…

2009-12-21 11:25 · 评论(0)

google protocol buffer 源码简析

protocol buffer(以下简称PB)作为一种效率和兼容性都很优秀的二进制数据传输格式,可以用于诸如 网络传输,配置文件,数据存储等诸多领域。本文的分析基于google发布的源码2.0.1版本 PB的源码结构大致如下: PB源码 { PB基础库 { Message抽象层 Descriptor抽象层 IO子系统 } PB编译器----源码生成器 } IO子系统最为简单,不依赖于系统其他部分,实现统一的输入输出接口 Message抽象层主要由一个抽象的Message类和从Message类里面单独分离出来的Reflection类构成. GeneratedMessageReflection是…

2009-12-17 20:57 · 评论(0)

String.Fromat

String.format中参数的形式: %conversion e.g: %1$-10.2s

2009-11-24 10:34 · 评论(0)

byte[]数组作为map的key的问题

今天coding的时候,用到了byte数组作为hashmap的key值,测试的时候,发现不能够根据相同的byte,得到相应的value值,google了一下,发现,byte数组作为key值,只是数组的地址的引用的hashcode,不能够根据byte数组的内容来,创建相应的hashcode,也就是所谓的索引key。所以,如果想用byte数组来作为map的key值的话,有三种方法: 1.将byte,先转化为string, 2.将采用list 3.将byte自己包装,使用byte数组的内容来重写hashcode和euquals方法, write up just for my own referen…

2009-11-05 22:00 · 评论(0)

Java tip : How to read files quickly

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 fi…

2009-10-12 20:42 · 评论(0)

linux文件系统详解

原文: http://www.linuxdiyf.com/blog/?69548/action_viewspace_itemid_1385.html /bin:存放着一百多个Linux下常用的命令、工具 /dev:存放着Linux下所有的设备文件! /home:用户主目录,每建一个用户,就会在这里新建一个与用户同名的目录,给该用户一个自己的空间 /lost+found:顾名思义,一些丢失的文件可能可以在这里找到 /mnt:外部设备的挂接点,通常用cdrom与floppy两个子目录!它的存在简化了光盘与软盘的使用。你只需在塞 入光盘后,运行:mount /mnt/ cdrom,就可以将光盘上的…

2009-09-27 11:57 · 评论(0)

difference of wait ,sleep.

当调用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 bl…

2009-09-24 15:28 · 评论(0)

3 ways MySQL uses indexes

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 lis…

2009-09-18 12:04 · 评论(0)

Index Optimization Tips

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. ***** * Keep your indexes…

2009-09-18 12:02 · 评论(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; readFileContents(fileName, byteArray); // calculate ch…

2009-09-10 21:59 · 评论(0)

weakReference vs softReference

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 as…

2009-09-10 20:49 · 评论(0)

threadLocal 笔记

网上搜索的结果,实践验证后记录 早在JDK 1.2的版本中就提供java.lang.ThreadLocal,ThreadLocal为解决多线程程序的并发问题提供了一种新的思路。ThreadLocal并不是一个Thread,而是Thread的局部变量,也许把它命名为ThreadLocalVariable更容易让人理解一些。 当使用ThreadLocal维护变量时,ThreadLocal为每个使用该变量的线程提供独立的变量副本,所以每一个线程都可以独立地改变自己的副本,而不会影响其它线程所对应的副本。 ThreadLocal类接口很简单,只有4个方法,我们先来了解一下: void set(Obj…

2009-09-09 19:53 · 评论(0)

Eclipse(3.3)技巧(二)

1。对于已经建立好的WrokSet,我们如果想直接添加或者减少其中的文件的时候,要打开Edit WrokSet来编辑,比较麻烦,现在Eclipse已经有快捷的工具栏,可以直接把Packager Explorer里面的选择的文件直接添加或除去。 2.有些用户经常编辑代码,又嫌显示器的空间不够,想把toolbar隐藏掉来扩大空间,现在Eclipse提供了这个新功能,直接再Eclipse的工具栏上面上面点击Hide ToolBar就可以隐藏掉工具栏,如果想再显示了,在Windows菜单里面选择Show Toolbar就可以显示了。 3.在一般情况下,我们再Package Explorer里面最顶层…

2009-09-07 11:28 · 评论(0)

Eclipse(3.3)高级技巧(一)

Eclipse(3.3)高级技巧(一) 1.当一个类比较大的时候,我们用鼠标滑轮往下移动的时候有时候总觉得比较慢,这时如果我们按住Ctrl键然后再滑动滚轮的时候,那么每滚一下都会翻整个页面,那么浏览的速度就大大加快了。 2.Eclipse中加入了重构脚本(Refactoring Script),如果用户经常有重复的重构的话,可以再refactor菜单里面选择Create Script可以把当前的重构脚本保存下来,下次想用的时候,可以用菜单里面的Apply refactoring直接调用脚本就可以。不用手动的去refactoring。 3.如果你剪贴板里面复制了整个java文件的源码(包括包结…

2009-09-07 11:26 · 评论(0)

(NIO)just for my own reference

介绍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 · 评论(0)