meetuparchive / archery

2D R-Tree implementation in Scala
MIT License
116 stars 26 forks source link

Use archery as a mutable database : var t: RTree #19

Open jmvanel opened 8 years ago

jmvanel commented 8 years ago

My use case is following a bunch (several hundreds) of mobile objects every few seconds. Currently I'm doing this, together with a Map to keep track of object by ID.

private var followedObjets: RTree[PointData] = RTree()
...
this.synchronized {
      followedObjets = followedObjets.remove(oldPoint)
      followedObjets = followedObjets.insert(newPoint)
    }

There is a bottleneck, because only a single thread can modify followedObjets . On the other hand, in this particular case, the occurences of concurrent modification attempts are unfrequent, so this is not a problem. But suppose the tracking is every millisecond ...

To avoid this bottleneck, I though to use STM, "software transactional memory" , cf the corresponding chapter in the book "Learning Concurrent Programming in Scala" Learn the art of building intricate, modern, scalable concurrent applications using Scala by Aleksandar Prokopec [1]

So, probably , this is not a real issue for Archery, which aims to be a pure immutable data structure, but any comment is apreciated.

[1] https://www.packtpub.com/application-development/learning-concurrent-programming-scala

jmvanel commented 7 years ago

Hi Unndaai you probably wanted to share a document with me, but this was not the right URL.