[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Storing Tree(or tree like) datastructure in terracotta  XML
Forum Index -> Terracotta Platform
Author Message
dshresth

neo

Joined: 02/26/2013 23:12:38
Messages: 2
Offline

Hello,
I would like to understand more about how terracotta handles tree like data structure. Consider the following scenario:
- Leaves are being added and removed from the tree periodically.
- Node level locking to update some node related data.
- Tree search is done constantly.

So my question is that is tree data structure discouraged to add in terracotta heap. Is there any performance penalties? Is there an alternative data structure that is performant and designed to store data structure similar to tree.

Danish
dkumar

neo

Joined: 03/06/2013 16:24:06
Messages: 4
Location: San Francisco
Offline

Can you give some detail about your use case?

There are some collections which Terracotta provides at lower layers which might be useful but before any recommendation I need some insight into what you're trying to achieve.

--
Dhruv Kumar
Software Engineer
Terracotta
dshresth

neo

Joined: 02/26/2013 23:12:38
Messages: 2
Offline

Consider a topic based publish-subscribed messaging pattern. Normally in pub-sub messaging publisher are dumb. They broadcast all events and subscribers filter out events they dont need. Some solutions have a centralized broker that decides where to route messages to. Consider using terracotta to store shared registry and smart publishers where they know what topics each subscribers are listening on (by looking at topic registry stored in terracotta). Ex.
node1 is listening on all hot brown drinks --> hot.*.brown
node2 is listening all cold drinks --> cold.*
node 3 is listening on hot coffee -> hot.coffee.brown

my topic tree would look like
root
      hot
            *
                  brown (node1)
            coffee
                  brown (node2)
      cold
            * (node3)

When a node has a topic it wants to publish, it will do a tree traversal and find all nodes listening for the topic. Say a node needs to publish hot.coffee.brown. it will match node1 and node2 since it matches both hot.*.brown and hot.coffee.brown. Any cold drink would match node3. hot.chocolate.brown would match node1. This is a very simple example. Consider a huge topic tree with a lot of unlocked reads and few locked writes. As the tree grows big we weren't sure how terracotta did its internal caching and locking. Its ok if you tell me terracotta isn't designed for tree.

I've used ConcurrentDistributedMap before, which is great for key value pair storage. I tried representing a tree in map data structure but its hard to maintain, takes a lot of space and searching will require a lot more gets than walking through the tree.

Hope this helps.
 
Forum Index -> Terracotta Platform
Go to:   
Powered by JForum 2.1.7 © JForum Team