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 9037761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:19:16+00:00 2026-06-16T09:19:16+00:00

Is there anyway by which each reducer process could determine the number of elements

  • 0

Is there anyway by which each reducer process could determine the number of elements or records it has to process ?

  • 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-16T09:19:17+00:00Added an answer on June 16, 2026 at 9:19 am

    Your reducer class must extend the MapReducer Reduce class:

    Reducer<KEYIN,VALUEIN,KEYOUT,VALUEOUT>

    and then must implement the reduce method using the KEYIN/VALUEIN arguments specified in the extended Reduce class

    reduce(KEYIN key, Iterable<VALUEIN> values,
    org.apache.hadoop.mapreduce.Reducer.Context context)

    The values associated with a given key can be counted via

    int count = 0;
    Iterator<VALUEIN> it = values.iterator();
    while(it.hasNext()){
      it.Next();
      count++;
    }
    

    Though I’d propose doing this counting along side your other processing as to not make two passes through your value set.

    EDIT

    Here’s an example vector of vectors that will dynamically grow as you add to it (so you won’t have to statically declare your arrays, and hence don’t need the size of the values set). This will work best for non-regular data (IE the number of columns is not the same for every row in your input csv file), but will have the most overhead.

    Vector table = new Vector();
    
    Iterator<Text> it = values.iterator();
    while(it.hasNext()){
    
      Text t = it.Next();
      String[] cols = t.toString().split(",");   
    
      int i = 0;
      Vector row = new Vector(); //new vector will be our row
      while(StringUtils.isNotEmpty(cols[i])){
        row.addElement(cols[i++]); //here were adding a new column for every value in the csv row
      }
    
      table.addElement(row);
    }
    

    Then you can access the Mth column of the Nth row via

    table.get(N).get(M);
    

    Now, if you knew the # of columns would be set, you could modify this to use a Vector of arrays which would probably be a little faster/more space efficient.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there anyway to detect which mouse button was clicked from inside a QItemSelectionModel?
Was there anyway to find the application which is responsible for statusBar notification?. One
I have an android application which contains four modules(I mean four apk's).Each module has
I have a number of buttons generated on the server, each of which is
Is there anyway I could use the same sortCompareFunction for multiple columns instead of
If I have two modules, each has implemented its preprocess_node hook. Then which one
Is there anyway how to check which website is being used with that pool
Hi I have a rest service which has a list of students each student
Is there any way in which I can automatically convert a Custom Class Object
Is there any way by which I can increase the default width of the

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.