nbronson / snaptree Goto Github PK
View Code? Open in Web Editor NEWConcurrent TreeMap w/ efficient support for clone() and consistent iteration
License: Other
Concurrent TreeMap w/ efficient support for clone() and consistent iteration
License: Other
This repository contains SnapTree, a concurrent AVL tree with fast cloning, snapshots, and consistent iteration. It is described in the paper "A Practical Concurrent Binary Search Tree", by N. Bronson, J. Casper, H. Chafi, and K. Olukotun, published in PPoPP'10. SnapTreeMap is a drop-in replacement for ConcurrentSkipListMap, with the additional guarantee that clone() is atomic and iteration has snapshot isolation. For more details see http://ppl.stanford.edu/papers/ppopp207-bronson.pdf The current release is 0.2, which has been published to the maven central repository under the groupId edu.stanford.ppl and the artifactId snaptree. VERSION 0.2: * Incorporates an important bugfix to isEmpty() VERSION 0.1: * Initial release
Only v0.1 is published:
Following up on #2. Pending https://issues.sonatype.org/browse/OSSRH-2656
It seems that in some places it is needed to return noUpdateResult(func, null) instead of just null. Test case:
SnapTreeMap<Integer, Integer> m = new SnapTreeMap<Integer, Integer>();
m.put(5, 15);
m.remove(10, 10);
Sometimes routing node does not get deleted. The issue can be reproduced by running multiple times following simple test:
public void testSnapTree() throws Exception {
final SnapTreeMap<Integer, Integer> m = new SnapTreeMap<Integer, Integer>();
multithreaded(new Runnable() {
@Override public void run() {
Random rnd = new Random();
for (int i = 0; i < 5000; i++) {
int x = 1 + rnd.nextInt(25);
Integer res = rnd.nextBoolean() ? m.put(x, x) : m.remove(x);
}
}
}, 2);
for (int i = 1; i <= 25; i++)
m.remove(i);
assertEquals(0, m.size());
assertTrue(m.isEmpty());
}
Don't have consistently reproducible test case but it happens with concurrent updates, removes and iterations over snapshots. It seems that sometimes height + 1 is not enough to accommodate full tree branch.
java.lang.ArrayIndexOutOfBoundsException: 5
at edu.stanford.ppl.concurrent.SnapTreeMap$AbstractIter.pushFirst(SnapTreeMap.java:2062)
at edu.stanford.ppl.concurrent.SnapTreeMap$AbstractIter.advance(SnapTreeMap.java:2102)
at edu.stanford.ppl.concurrent.SnapTreeMap$AbstractIter.nextNode(SnapTreeMap.java:2130)
at edu.stanford.ppl.concurrent.SnapTreeMap$KeyIter.next(SnapTreeMap.java:1976)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.