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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:28:10+00:00 2026-06-10T22:28:10+00:00

I was working with Hadoop MapRedue , and had a question. Currently, my mapper’s

  • 0

I was working with Hadoop MapRedue, and had a question.
Currently, my mapper’s input KV type is LongWritable, LongWritable type and
output KV type is also LongWritable, LongWritable type.
InputFileFormat is SequenceFileInputFormat.
Basically What I want to do is to change a txt file into SequenceFileFormat so that I can use this into my mapper.

What I would like to do is

input file is something like this

1\t2 (key = 1, value = 2)

2\t3 (key = 2, value = 3)

and on and on…

I looked at this thread How to convert .txt file to Hadoop's sequence file format but reliazing that TextInputFormat only support Key = LongWritable and Value = Text

Is there any way to get txt and make a sequence file in KV = LongWritable, LongWritable?

  • 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-10T22:28:12+00:00Added an answer on June 10, 2026 at 10:28 pm

    Sure, basically the same way I told in the other thread you’ve linked. But you have to implement your own Mapper.

    Just a quick scratch for you:

    public class LongLongMapper extends
        Mapper<LongWritable, Text, LongWritable, LongWritable> {
    
      @Override
      protected void map(LongWritable key, Text value,
          Mapper<LongWritable, Text, LongWritable, LongWritable>.Context context)
          throws IOException, InterruptedException {
    
        // assuming that your line contains key and value separated by \t
        String[] split = value.toString().split("\t");
    
        context.write(new LongWritable(Long.valueOf(split[0])), new LongWritable(
            Long.valueOf(split[1])));
    
      }
    
      public static void main(String[] args) throws IOException,
          InterruptedException, ClassNotFoundException {
    
        Configuration conf = new Configuration();
        Job job = new Job(conf);
        job.setJobName("Convert Text");
        job.setJarByClass(LongLongMapper.class);
    
        job.setMapperClass(Mapper.class);
        job.setReducerClass(Reducer.class);
    
        // increase if you need sorting or a special number of files
        job.setNumReduceTasks(0);
    
        job.setOutputKeyClass(LongWritable.class);
        job.setOutputValueClass(LongWritable.class);
    
        job.setOutputFormatClass(SequenceFileOutputFormat.class);
        job.setInputFormatClass(TextInputFormat.class);
    
        FileInputFormat.addInputPath(job, new Path("/input"));
        FileOutputFormat.setOutputPath(job, new Path("/output"));
    
        // submit and wait for completion
        job.waitForCompletion(true);
      }
    }
    

    Each value in your mapper function will get a line of your input, so we are just splitting it by your delimiter (tab) and parsing each part of it into longs.

    That’s it.

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

Sidebar

Related Questions

I'm currently working on implementing a logging system for a new Hadoop cluster I've
Grep seems not to be working for hadoop streaming For: hadoop jar /usr/local/hadoop-0.20.2/contrib/streaming/hadoop-0.20.2-streaming.jar -input
Am getting started with Hadoop, and am working on building a MapReduce chain for
As part of trying to learn hadoop, I'm working on a project using a
I'm working on a Hadoop streaming workflow for Amazon Elastic Map Reduce and it
While working on Hadoop Implementation in Pseudo-Distributed Operation, I found following exception of JAVA_HOME
I'm working in Hadoop, and I need to provide a comparator to sort objects
I am working on a project using Hadoop and it seems to natively incorporate
I am currently working on a MapReduce Job which I am only using the
i am working with Hadoop-1.0.1 in Eclipse. I am trying to run wordcount application

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.