Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HashMap

 
kantri yama
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to implement a storage structure(inverted index) for information retrieval project. For each keyword, I need to store the document ID in which it is present and position of occurrences. For ex

inverted index :
a->[doc 1, (1,2,4)], [doc2, (2)]
b->[doc 1, (3)], [doc2, (3)]
c->[doc 2, (1)]

i.e 'a' is present in doc 1 at 1,2,and 4 positions and in doc 2 at 2nd position. I am puzzled about how to implement hashmap for this index. I couldn't get an idea about how to implement [doc 1, (1,2,4)] as one part, and [doc2, (2)] as another part using multiple values for each key. Please help me.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48985
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch

Bit difficult to know what would be best, just at a quick look, but can you put those numbers into a List<Integer>?
Then you could have a Map<Something, List<Integer>>; whenever you get a new Something you can add the number to the List.

Or can you create a Location class and have a List<Location>, then Map<Something, List<Location>>?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic