Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
HBase >> mail # user >> Write data content into HFile.

Copy link to this message
Write data content into HFile.

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?