Hi,

I am going through examples in this book (which I have obtained as early
draft from Safari), and they all work, with occasional fixes. However, the
SequenceFileWriteDemo, even though it works without an error, does not show
the create file when I use this command

hadoop fs -ls /

I remember reading somewhere that the file needs to be at least 64 M to be
seen, or something to that effect. How can I see the created file?

If you want the code (with a few minor changes)

public class SequenceFileWriteDemo {

    private static final String[] DATA = {
        "One, two, buckle my shoe",
        "Three, four, shut the door",
        "Five, six, pick up sticks",
        "Seven, eight, lay them straight",
        "Nine, ten, a big fat hen"
    };

    public static void main(String[] args) throws IOException {
        String uri = args[0];
        Configuration conf = new Configuration();
        FileSystem fs = FileSystem.get(URI.create(uri), conf);
        Path path = new Path(uri);

        IntWritable key = new IntWritable();
        Text value = new Text();
        SequenceFile.Writer writer = null;
        try {
            writer = SequenceFile.createWriter(fs, conf, path,
                    key.getClass(), value.getClass());

            int n = 10000;
            for (int i = 0; i < n; i++) {
                key.set(n - i);
                value.set(DATA[i % DATA.length]);
                if (i % 100 == 0) {
                    System.out.printf("[%s]\t%s\t%s\n", writer.getLength(),
key, value);
                }
                writer.append(key, value);
            }
        } finally {
            IOUtils.closeStream(writer);
        }
    }
}


Thank you,
Mark

Reply via email to