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

  • Home
  • SEARCH
  • 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 974023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:22:08+00:00 2026-05-16T03:22:08+00:00

In my code I have a map that is used heavily, several thousand times

  • 0

In my code I have a map that is used heavily, several thousand times in a few seconds. Originally I had a TreeMap, but when testing with 9,000 entries I watched my old processor melt. And this needs to scale. So I moved to a HashMap and performance was excellent.

Now I am changing my design and am looking for a MultiMap. However I’m afraid of the performance impact on the get() side, as it must iterate over said large map picking out the matching keys, and when called many many times even synchronized it seems like it would be slow.

Is there a good MultiMap that can handle such large values with great performance? Performance is critical in this application, as there could be many large separate maps handling a very large workload, making “small” performance losses very big issues.

Bonus points if it can be extracted to work alone without any dependencies.

  • 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-05-16T03:22:09+00:00Added an answer on May 16, 2026 at 3:22 am

    The one that was recommended to me in one of my questions was the Apache Commons MultiMap:
    http://commons.apache.org/collections/api-3.2.1/org/apache/commons/collections/MultiHashMap.html

    It’s free software, so you can at least get the source to look at it, and depending on your license situation, you can modify it or use it standalone.

    It uses an ArrayList internally, but I imagine you can probably change it to use a HashSet or something. I would look at the createCollection(Collection coll) method.

    UPDATE: Actually, Guava’s HashMultiMap appears to already be what I was talking about:
    https://github.com/google/guava/blob/master/guava/src/com/google/common/collect/Multimap.java

    I looked at the source and it seems that each collection of values is in fact backed by a HashSet.

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

Sidebar

Related Questions

We have several areas where code like this can be seen public Map extractData(ResultSet
I have a Google Map (API 2) that used to work fine as a
I have a std::map that is used by multiple threads to store data. The
i have to display google map in my php code. for that i have
I have a custom user type that is used to map from a decimal
I want to have a map that has a homogeneous key type but heterogeneous
I have a program that heavily uses std::map . Under Windows, much more memory
I have several DAO objects that are used to retrieve information from a database
I have code like this that sets the map type to Terrain View: map
I have the following code that saves a map into shared memory using boost

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.