The Artima Developer Community
Sponsored Link

Java Buzz Forum
Introducing Distributed MultiMap

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Talip Ozturk

Posts: 103
Nickname: talip
Registered: May, 2003

Talip Ozturk is founder of Hazelcast, distributed queue, set, map and lock implementation.
Introducing Distributed MultiMap Posted: May 4, 2009 9:43 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Talip Ozturk.
Original Post: Introducing Distributed MultiMap
Feed Title: Shared Memory
Feed URL: http://www.jroller.com/talipozturk/feed/entries/rss
Feed Description: about java, jcache, jini, javaspaces, distributed data structures and a little bit of me and life.
Latest Java Buzz Posts
Latest Java Buzz Posts by Talip Ozturk
Latest Posts From Shared Memory

Advertisement
Don't you love Google Collections MultiMap stuff? I love it. Apache Collections also have it. It is great for one to many relations. If you've never heard of it, you should definitely check it out. MultiMap is a specialized map where you can associate each key with multiple values. One-to-Many!

So we thought it would be really cool to have a distributed version of it. Here we go... Hazelcast Distributed MultiMap:

import com.hazelcast.core.MultiMap;
import com.hazelcast.core.Hazelcast;
import java.util.Collection;

// a multimap to hold customerId-Order pairs
MultiMap mmCustomerOrders = Hazelcast.getMultiMap("customerOrders");
mmCustomerOrders.put("1", new Order ("iPhone", 440));
mmCustomerOrders.put("1", new Order ("MacBook Pro", 2400));
mmCustomerOrders.put("1", new Order ("iPod", 79));

// get orders of the customer with customerId 1.
Collection colOrders = mmCustomerOrders.get ("1");
for (Order order : colOrders) {
        // process order
}

// remove specific key/value pair
boolean removed = mmCustomerOrders.remove("1", new Order ("iPhone", 440));

Download it from Google Code. Enjoy!

Read: Introducing Distributed MultiMap

Topic: Digital River posts lower 1st-quarter profit, still beats Wall Street's expectations Previous Topic   Next Topic Topic: Time Warner Cable 1st-qtr profit dips on charges, but revenue rose as people stay with cable

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use