How to create hadoop sequence file on local file system without having hadoop installed?

Is it possible to create a hadoop sequence file from java without having hadoop installed? I need a separate java program that creates a sequence file locally. My java program will run in env, which does not have installo installed.

+2
source share
1 answer

You will need libraries, but not installation. Use

SequenceFile.Writer

Code example:

import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.Text;
public class SequenceFileCreator {

    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        Configuration config = new Configuration();
        FileSystem fs = FileSystem.get(config);

        SequenceFile.Writer writer = new SequenceFile.Writer(fs, config, new Path("LocalPath"), NullWritable.class, Text.class);
        writer.append(NullWritable.get(), new Text(""));
        writer.close();
    }

}
+3
source

Source: https://habr.com/ru/post/1655264/


All Articles