0

I have Table like Table<String, String, String> distributions = HashBasedTable.create();

|----------------------------------------------|
| Row             | Column   | Value           |
|----------------------------------------------|
| aaa             | a        | Hard Rock       |
| aaa             | n        | Art Pop         |
| abc             | b        | Surrealist Film |
| abc             | c        | Blockbuster     |
|----------------------------------------------|


My Column values are all unique but my Row values can be repeated.

so How can I get all the Column keys given a Row key?

Sapnesh Naik
  • 11,011
  • 7
  • 63
  • 98

2 Answers2

0

If you want values based on rows. it will give you multiple values

0

You can use Table.rowMap() to get "a view that associates each row key with the corresponding map from column keys to values"; the view is a Map and its keySet() contains all of the Column keys for a given Row key:

 distributions.rowMap().get("aaa").keySet(); // [a, n]
 distributions.rowMap().get("abc").keySet(); // [b, c]
mfulton26
  • 29,956
  • 6
  • 64
  • 88