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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:32:15+00:00 2026-05-29T11:32:15+00:00

My wordcount program is giving me the desired output file which has all the

  • 0

My wordcount program is giving me the desired output file which has all the words and their occurrences. Now, I have to append this code to support a query such that, when I enter a specific word, then it outputs the corresponding filenames & the output of the wordcount program should be the input to query.

I get these errors – Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 2 at org.myorg.InvertedIndex.main(InvertedIndex.java:69) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav‌​a:43) at java.lang.reflect.Method.invoke(Method.java:616) at org.apache.hadoop.util.RunJar.main(RunJar.java:156)

  • 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-05-29T11:32:16+00:00Added an answer on May 29, 2026 at 11:32 am

    Well if you want to input it as a console parameter while starting the job and both you mapper and reducer are in a single file then you can simply make a static String in this class:

    private static String myWord;

    Then initialize it in the main() method:

    myWord = args[2];

    And use it in you map() method like this:

    if(myWord.equals(word.toString()) {
        output.collect(word, one);
    }
    

    This will only emit pairs from the mapper to the reducer and the reducer will sum it up. Should work but I did not test it myself.

    @Edit: this is mighty strange. The only thing left you can try (imho) is to do something similar to this WordCount 2.0 example.

    As you can notice (a bit below the source code), they start it like this:

    $ bin/hadoop jar /usr/joe/wordcount.jar org.myorg.WordCount -Dwordcount.case.sensitive=true /usr/joe/wordcount/input /usr/joe/wordcount/output -skip /user/joe/wordcount/patterns.txt
    

    You can change this to:

    $ bin/hadoop jar InvertedIndex.jar org.myorg.InvertedIndex /user/james/input /user/james/output -word hello
    

    And chage the line I suggested (myWord = args[2]) to:

    for (int i=0; i < args.length; ++i) {
        if ("-word".equals(args[i])) {
            myWord = args[++i];
        }
    }
    

    Guess you can use that example as it does something similar o what you want to achieve (pass something as a parameter and then use it). You can check where they are storing all the data that comes from the parameters (method configure()) etc.

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

Sidebar

Related Questions

I have a program to process very large files. Now I need to show
I have a program which needs to load some text word for word into
This is my FIRST haskell program! wordCount takes in a list of words and
I have a Pig program where I am trying to compute the minimum center
I am very new to Lex and Yacc. I have a Lex program. Example:
I'm going to write a program that takes a URL and counts the occurrences
I'm obviously not quite getting the 'end-of-file' concept with C++ as the below program
I have been evolving an automation and statistics generation program through a series of
I have the following SQL: select Username, COUNT(DISTINCT Message) as Count, AVG(WordCount) as Average,
I am writing a program that counts the number of words in a text

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.