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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:55:25+00:00 2026-06-05T21:55:25+00:00

I have a HBase table (from java) and i want to query the table

  • 0

I have a HBase table (from java) and i want to query the table by list of keys. I did the following, but its not working.

mFilterFeatureIt = mFeatureSet.iterator();
FilterList filterList=new FilterList(FilterList.Operator.MUST_PASS_ONE);

while (mFilterFeatureIt.hasNext()) {
    long myfeatureId = mFilterFeatureIt.next();
System.out.println("FeatureId:"+myfeatureId+" , ");
RowFilter filter = new RowFilter(CompareOp.EQUAL,new BinaryComparator(Bytes.toBytes(myfeatureId)) );
filterList.addFilter(filter);
}

outputMap  = HbaseUtils.getHbaseData("mytable", filterList);
System.out.println("Size of outputMap map:"+ outputMap.szie());

public static Map<String, Map<String, String>> getHbaseData(String table, FilterList filter) {

    Map<String, Map<String, String>> data = new HashMap<String, Map<String, String>>();
HTable htable = null;
try {
    htable = new HTable(HTableConfiguration.getHTableConfiguration(),table);
    Scan scan = new Scan();
    scan.setFilter(filter);

    ResultScanner resultScanner = htable.getScanner(scan);
    Iterator<Result> results = resultScanner.iterator();

    while (results.hasNext()) {

    Result result = results.next();
    String rowId = Bytes.toString(result.getRow());
    List<KeyValue> columns = result.list();
    if (null != columns) {

    HashMap<String, String> colData = new HashMap<String, String>();
    for (KeyValue column : columns) {
        colData.put(Bytes.toString(column.getFamily()) + ":"+ Bytes.toString(column.getQualifier()),Bytes.toString(column.getValue()));
    }
                data.put(rowId, colData);
    }

    }

    } catch (IOException e) {
    e.printStackTrace();
    } finally {
        if (htable != null)
    try {
    htable.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    return data;
}

FeatureId:80515900 ,
FeatureId:80515901 ,
FeatureId:80515902 ,

Size of outputMap map: 0

I see that value of feature id is what i want , but I always get the above output even if the key is present in the hbase table. Can anyone tell me what am i doing wrong ?

EDIT:
I posted the code for my hbase util method too above, so that you can point me to any bugs there.

I am trying to do an SQL equivalent of select * FROM mytable where featureId in (80515900, 80515901, 80515902) My idea to achieve the same in HBase was to create a filter list with one filter for each featureId. Is that correct ?

Here is the content of my table

scan 'mytable', {COLUMNS => ['sample:tag_count'] }

80515900                                            column=sample:tag_count, timestamp=1339304052748, value=4                                                                                                
80515901                                            column=sample:tag_count, timestamp=1339304052748, value=0                                                                                                
80515902                                            column=sample:tag_count, timestamp=1339304052748, value=3       
80515903                                            column=sample:tag_count, timestamp=1339304052748, value=1                                                                                                
80515904                                            column=sample:tag_count, timestamp=1339304052748, value=2                                                                                                
  • 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-05T21:55:26+00:00Added an answer on June 5, 2026 at 9:55 pm

    Its not returning any data as while inserting the data into hbase,
    the data-type for key is ‘String’ (from your scan result) & while fetching, the value passed in RowFilter has ‘long’ data type. Use this filter:

    RowFilter filter = new RowFilter(CompareOp.EQUAL,new    
    BinaryComparator(Bytes.toBytes(myfeatureId.toString())) );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mapreduce program that first scans an HBase table. I want some
I am finding difficulty on modeling HBase table for the following requirement. I have
I have a simple map/reduce job that scans one hbase table, and modifies another
i have written a following hbase client class for remote server: System.out.println(Hbase Demo Application
I am new to HBase but I have setup and got some knowledge about
I have used zohmg and successfully created mapper, table in HBase and test-imported my
I have billion of rows in hbase I want to scan million rows at
My situation is the following: I have a 20-node Hadoop/HBase cluster with 3 ZooKeepers.
I created by own HBase java client code, but I am having a really
I am trying to connect to an HBase node from a Java application. HBaseConfiguration

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.