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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:45:38+00:00 2026-06-02T15:45:38+00:00

So, I have a Mapper that updates an HBase table. In the map() function,

  • 0

So, I have a Mapper that updates an HBase table. In the map() function, I :

1) instantiate an HBaseConfiguration

2) instantiate an HTable

3) call hTable.put() a bunch of times to add rows

4) call hTable.flushCommits() to flush my changes

5) call HConnectionManager.deleteConnection() to kill the connection to HBase

However, this seems inefficient. I would like to instantiate the HBaseConfiguration and the HTable in the constructor for my Mapper class. Then I could have my mapper class implement Closeable, calling hTable.flushCommits() and HConnectionManager.deleteConnection() in the close() method. That way, in each call to map(), I’d be buffering my put() calls, and would be flushing all the changes at once, when close() is called.

However, this is only worthwhile if the Mapper object is re-used for multiple calls to map(). Otherwise, I may as well leave my code alone.

So the main question is : are Mapper objects used for more than one call to map()?

The bonus question is : would the re-written code be more efficient?

  • 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-02T15:45:41+00:00Added an answer on June 2, 2026 at 3:45 pm

    What you are looking for is setup and cleanup. setup runs once before map is called a bunch of times, and cleanup is called once after all the maps are called. You override these just like you override map.

    Use private member objects for your HBaseConfiguration and HTable. Initialize them in the setup. Do your hTable.put() in your map. Do hTable.flushCommits() and HConnectionManager.deleteConnection() in your cleanup. The only thing you might want to be careful is to flush the commits more than just at the end in the case you are buffering more data than your memory can handle. In which case, you might want to flush every 1000 records or something in the map by keeping track of number of records you’ve seen.

    This will definitely be more efficient! Opening and closing that connection is going to incur a significant amount of overhead.

    Check out the documentation for Mapper

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

Sidebar

Related Questions

Let's say I have a data mapper function that aggregates multiple tables and generates
I have a number of mappers that look like this: mapper(Photo,photo_table, properties = {
I have a class that is mapped to a table using NHibernate. The problem
We have a DB table that is mapped into a hibernate entity. So far
I have an ORM mapped object, that I want to update. I have all
I have a class that is mapped in fluent nhibernate but I want one
I have the directory mapped on my machine so that I can browse and
I have an input text that is mapped to a Long property. private Long
Suppose I have a class Customer that is mapped to the database and everything
I have an application that can potentially have hundreds of memory mapped, i.e., mmap()

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.