hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yonghu <yongyong...@gmail.com>
Subject Write data content into HFile.
Date Tue, 06 Mar 2012 12:24:57 GMT

I wrote a single program to directly write data content to HFile.
Hbase is installed as pseudo-mode.

here is my code:
public static void putData() throws Exception{
		FileSystem fs = new RawLocalFileSystem();
		fs.setConf(new Configuration());
		//block size is 2K
		HFile.Writer hwriter = new HFile.Writer(fs, new
Path("hdfs://localhost:8020/test"), 2, (Compression.Algorithm)null,
		//value size is 1K, it means one block can contain 2 key/value pairs
		byte[] key1 = "tom".getBytes();
		byte[] value1 = new byte[1024];
		for(int i=0;i<1024;i++){
			value1[i] = 'a';
		hwriter.append(key1, value1);
		byte[] key2 = "jim".getBytes();
		byte[] value2 = new byte[1024];
		for(int i=0;i<1024;i++){
			value2[i] = 'b';
after I run this method, it returned error information as follows:
Exception in thread "main" java.lang.IllegalArgumentException: Wrong
FS: hdfs://localhost:8020/test, expected: file:///.

How can I set the second parameter in the HFile.Writer constructor?



View raw message