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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:01:28+00:00 2026-06-13T19:01:28+00:00

I am trying to implement a Custom WritableComparable as shown In this link I

  • 0

I am trying to implement a Custom WritableComparable as shown In this link

I am getting an error when I am trying to initialize the custom writable comparable class inside my mapper method. I have shown my error in side my code.
Should textpair class be in a sperate file ?

public class Myprog {
    public static class MyMap extends Mapper<Object, Text, TextPair, IntWritable> {
        public void map(Object key, Text value, Context context)
            throws IOException, InterruptedException {
            TextPair writable = new TextPair();

           //ERROR in this line 
           //No enclosing instance of type Myprog is accessible. Must qualify 
           //the allocation with an enclosing instance of type Myprog 
           //(e.g. x.new A() where x is an instance of Myprog).
            ....
    }
}

public static class MyReduce extends Reducer<TextPair, IntWritable, Text, Text> {
    public void reduce(TextPair key, Iterable<IntWritable> values, Context context)
        throws IOException, InterruptedException {
    }
}

public class TextPair implements WritableComparable<TextPair> {
      ....
}

public static void main(String[] args) throws Exception {
    Configuration conf = new Configuration();
    String[] otherArgs = 
        new GenericOptionsParser(conf, args).getRemainingArgs();
    Collections.addAll(headerList, header.split(","));
    Job job = new Job(conf, "Myprog");
    job.setJarByClass(Myprog.class);
    job.setMapperClass(MyMap.class);
    job.setReducerClass(MyReduce.class);
    job.setMapOutputKeyClass(TextPair.class); 
    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(Text.class);

    FileInputFormat.addInputPath(job, new Path(otherArgs[0]));
    FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));

    System.exit(job.waitForCompletion(true) ? 0 : 1);
}
  • 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-13T19:01:29+00:00Added an answer on June 13, 2026 at 7:01 pm

    You have to define your TextPair as static. It can not be instantiated without the outer instance of Myprog. Since your Mapper is static, it has no instance of Myprog to refer to.

    Using

    public static class TextPair 
    

    will resolve your problem.

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

Sidebar

Related Questions

I'm trying to implement a custom class for dataannotations that retrieves error messages from
im trying to implement a custom error page, what i want to be able
I'm trying to implement my custom authorize attribute like: public class MyCustomAuth : AuthorizeAttribute
I am trying to implement Custom Error handling via Action Filter Attributes. My code
I am trying to implement a custom control using a RowClickableGridView class provided on
I'm trying to implement a custom menu in my joomla template. I added this
I am trying to implement a custom slider as shown in figure below. what
I am trying to implement a custom menu for Internet Explorer 7.0. For this
I am trying to implement a custom titlebar: Here is my Helper class: import
I am trying to implement a custom Java widget using GWT.This requires me to

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.