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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:13:50+00:00 2026-06-15T17:13:50+00:00

I am trying to practice with Guava and I have come across a problem

  • 0

I am trying to practice with Guava and I have come across a problem and I am not comfortable with the solution I have found.

In my situation, I have id set per user and server. Despite of incredible simplification by Guava Table I have still problems inside the loop if statement block in construction table.

  Table<Integer, Integer, Set> setPerUser = HashBasedTable.create();

  for(Conversation conversation : conversations) {
     Set uci = setPerUser.get(conversation.x, conversation.y);
     if(uci == null) {
        uci = new HashSet();
        setPerUser.put(conversation.x, conversation.y, uci);
     }
     uci.add(conversation.id);
  }

It seems that I have in wrong direction and if statements are alarming the situtation. Ok,

  1. Is there a better way to transform a iterator to Table such as FluentIterator?

  2. What do you think to have an initial value method such as ThreadLocal or Guava Supplier?

Thanks

  • 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-15T17:13:52+00:00Added an answer on June 15, 2026 at 5:13 pm

    Since you are storing a collection in your Table Cells, what you actually need is a “Multitable”, that automatically creates Collections for you as needed (as Multimap does). I am pretty sure that this requirement is complex enough to be beyond what the Guava team are willing to implements.

    I’d say what you are doing is the best possible way to deal with the situation (apart from the fact that your Set should be generic, of course)

    Here’s a static factory method that does what you want to do in a more generic way:

    public static <X, Y, Z, S extends Collection<Z>> void addCellValue(
        Table<X, Y, S> table, X rowKey, Y colKey, Z value, Supplier<S> supplier) {
    
        final S data;
        if (table.contains(rowKey, colKey)) {
            data = table.get(rowKey, colKey);
        } else {
            data = supplier.get();
            table.put(rowKey, colKey, data);
        }
        data.add(value);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to work out the best practice for my problem. I have
Recently I was trying some practice programs in python and I came across this
Why is my sql injection which i am trying to practice on not working.
I'm trying to learn LINQ by practice. This seems like a situation where I
I've been trying to practice on backbone.js, I found one tutorial online which I
Currently trying to come up with a best practice for a ZF site that
I was messing around with Python trying to practice my sorting algorithms and found
As a practice exercise, I am trying to get five numbers from a user
I am trying to practice programming and I have decide to place some effect
Trying to solve some queries from sql zoo to practice sql skills I have

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.