Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8833803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:52:10+00:00 2026-06-14T08:52:10+00:00

Input : a,b,c,d,e q,w,34,r,e 1,2,3,4,e In mapper, I would grab all the values of

  • 0

Input :

a,b,c,d,e

q,w,34,r,e

1,2,3,4,e

In mapper, I would grab all the values of the last field, and I want to emit (e,(a,b,c,d)) i.e. it emits (key, (rest of the fields from the line)).

Help appreciated.

Current code:

public static class Map extends Mapper<LongWritable, Text, Text, Text> {
   private final static IntWritable one = new IntWritable(1);
    private Text word = new Text();

    public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString(); // reads the input line by line   
        String[] attr = line.split(","); // extract each attribute values from the csv record
         context.write(attr[argno-1],line); // gives error seems to like only integer? how to override this?
        }
    }
 } 
 public static class Reduce extends Reducer<Text, IntWritable, Text, IntWritable> {

    public void reduce(Text key, Iterable<IntWritable> values, Context context) 
      throws IOException, InterruptedException {
        // further process , loads the chunk into 2d arraylist object for processing
    }
      public static void main(String[] args) throws Exception {
    String line; 
    String arguements[];
    Configuration conf = new Configuration();

        // compute the total number of attributes in the file
    FileReader infile = new FileReader(args[0]);
    BufferedReader bufread = new BufferedReader(infile);
    line = bufread.readLine();
    arguements = line.split(","); // split the fields separated by comma
    conf.setInt("argno", arguements.length); // saving that attribute value 
    Job job = new Job(conf, "nb");
    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(Text.class);
        job.setMapperClass(Map.class); /* The method setMapperClass(Class<? extends Mapper>) in the type Job is not applicable for the arguments (Class<Map>) */
    job.setReducerClass(Reduce.class);
    job.setInputFormatClass(TextInputFormat.class);
    job.setOutputFormatClass(TextOutputFormat.class);
    FileInputFormat.addInputPath(job, new Path(args[0]));
    FileOutputFormat.setOutputPath(job, new Path(args[1]));
    job.waitForCompletion(true);
 }`

Please note the errors (see comments) I get face.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:52:11+00:00Added an answer on June 14, 2026 at 8:52 am

    So this is simple. First parse your string to get the key and pass the rest of the line as the value. Then use the identity reducer which will combine all the same key values as list together as your output. It should be in the same format.

    So your map function will output:

    e, (a,b,c,d,e)

    e, (q,w,34,r,e)

    e, (1,2,3,4,e)

    Then after the identity reduce it should output:

    e, {a,b,c,d,e; q,w,34,r,e; 1,2,3,4,e}

    public static class Map extends Mapper<LongWritable, Text, Text, Text> {
       private final static IntWritable one = new IntWritable(1);
        private Text word = new Text();
    
        public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
            String line = value.toString(); // reads the input line by line   
            String[] attr = line.split(","); // extract each attribute values from the csv record
             context.write(attr[argno-1],line); // gives error seems to like only integer? how to override this?
            }
        }
    
        public static void main(String[] args) throws Exception {
            String line; 
            String arguements[];
            Configuration conf = new Configuration();
    
            // compute the total number of attributes in the file
            FileReader infile = new FileReader(args[0]);
            BufferedReader bufread = new BufferedReader(infile);
            line = bufread.readLine();
            arguements = line.split(","); // split the fields separated by comma
            conf.setInt("argno", arguements.length); // saving that attribute value 
            Job job = new Job(conf, "nb");
            job.setOutputKeyClass(Text.class);
            job.setOutputValueClass(Text.class);
            job.setMapperClass(Map.class); 
            job.setInputFormatClass(TextInputFormat.class);
            job.setOutputFormatClass(TextOutputFormat.class);
            FileInputFormat.addInputPath(job, new Path(args[0]));
            FileOutputFormat.setOutputPath(job, new Path(args[1]));
            job.waitForCompletion(true);
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I would like to do is add dynamically HTML input fields in one
Everything works fine locally when I do as follows: cat input | python mapper.py
Input rz value In the head I have: Event.observe(window, 'load', function() { $$(input).each(function(field){ Event.observe(field,
I wrote a simple map reduce job that would read in data from the
How can I allow a user to input HTML into a particular field using
I have a the following checkbox field (1) and I would like to add
I have an input text that is mapped to a Long property. private Long
Input: List of keys: [ :name :address :work] Map 1: { :name A :address
Input @StartDate = '01/25/2010' @EndDate = '02/06/2010' I have 2 CTEs in a stored
Input : {5, 13, 6, 5, 13, 7, 8, 6, 5} Output : {5,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.