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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:23:58+00:00 2026-06-02T11:23:58+00:00

I have a table called User with two columns, one called visitorId and the

  • 0

I have a table called User with two columns, one called visitorId and the other called friend which is a list of strings. I want to check whether the VisitorId is in the friendlist. Can anyone direct me as to how to access the table columns in a map function?
I’m not able to picture how data is output from a map function in hbase.
My code is as follows:

ublic class MapReduce {

static class Mapper1 extends TableMapper<ImmutableBytesWritable, Text> {

    private int numRecords = 0;
    private static final IntWritable one = new IntWritable(1);       
    private final IntWritable ONE = new IntWritable(1);
    private Text text = new Text();

    @Override
    public void map(ImmutableBytesWritable row, Result values, Context context) throws IOException {

        //What should i do here??
        ImmutableBytesWritable userKey = new ImmutableBytesWritable(row.get(), 0, Bytes.SIZEOF_INT);

        context.write(userkey,One);     
    }

            //context.write(text, ONE);
        } catch (InterruptedException e) {
            throw new IOException(e);
        }

    }
}



public static void main(String[] args) throws Exception {
    Configuration conf = HBaseConfiguration.create();
    Job job = new Job(conf, "CheckVisitor");
    job.setJarByClass(MapReduce.class);
    Scan scan = new Scan();
    Filter f = new RowFilter(CompareOp.EQUAL,new SubstringComparator("mId2"));
    scan.setFilter(f);
    scan.addFamily(Bytes.toBytes("visitor"));
    scan.addFamily(Bytes.toBytes("friend"));
    TableMapReduceUtil.initTableMapperJob("User", scan, Mapper1.class, ImmutableBytesWritable.class,Text.class, job);

}

}

  • 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-02T11:24:00+00:00Added an answer on June 2, 2026 at 11:24 am

    So Result values instance would contain the full row from the scanner.
    To get the appropriate columns from the Result I would do something like :-

    VisitorIdVal = value.getColumnLatest(Bytes.toBytes(columnFamily1), Bytes.toBytes(“VisitorId”))

    friendlistVal = value.getColumnLatest(Bytes.toBytes(columnFamily2), Bytes.toBytes(“friendlist”))

    Here VisitorIdVal and friendlistVal are of the type keyValue http://archive.cloudera.com/cdh/3/hbase/apidocs/org/apache/hadoop/hbase/KeyValue.html, to get their values out you can do a Bytes.toString(VisitorIdVal.getValue())
    Once you have extracted the values from columns you can check for “VisitorId” in “friendlist”

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

Sidebar

Related Questions

I have a table called order which contains columns id , user_id , price
I have a table called keywords. It's simple, two columns - id and keyword.
I have a table in DB called TABLE_3 which has several columns....and I wanna
I have two tables, one called episodes, and one called score. The episode table
I currently have a table called User which has a id column which is
I have a MySQL table with a number of columns, including one called 'Name'.
I have a table called Users ( class User < ActiveRecord::Base ) and a
I have a table called credit_log and the columns are user_id | amount The
i have table called as Support, which have a field named Name and contains
I have a table called Jrl with three columns: code AS varchar(15) total AS

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.