Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The classes required for this are <a href="http://hadoop.apache.org/docs/r1.0.4/api/org/apache/hadoop/fs/FileSystem.html" rel="noreferrer">FileSystem</a>, <a href="http://hadoop.apache.org/docs/r1.0.4/api/org/apache/hadoop/fs/FSDataInputStream.html" rel="noreferrer">FSDataInputStream</a> and <a href="http://hadoop.apache.org/docs/r1.0.4/api/org/apache/hadoop/fs/Path.html" rel="noreferrer">Path</a>. Client should be something like this :</p> <pre><code>public static void main(String[] args) throws IOException { // TODO Auto-generated method stub Configuration conf = new Configuration(); conf.addResource(new Path("/hadoop/projects/hadoop-1.0.4/conf/core-site.xml")); conf.addResource(new Path("/hadoop/projects/hadoop-1.0.4/conf/hdfs-site.xml")); FileSystem fs = FileSystem.get(conf); FSDataInputStream inputStream = fs.open(new Path("/path/to/input/file")); System.out.println(inputStream.readChar()); } </code></pre> <p>FSDataInputStream has several <code>read</code> methods. Choose the one which suits your needs.</p> <p>If it is MR, it's even easier :</p> <pre><code> public static class YourMapper extends Mapper&lt;LongWritable, Text, Your_Wish, Your_Wish&gt; { public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { //Framework does the reading for you... String line = value.toString(); //line contains one line of your csv file. //do your processing here .................... .................... context.write(Your_Wish, Your_Wish); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload