Search in sources :

Example 6 with Revision

use of org.apache.jackrabbit.oak.plugins.document.Revision in project jackrabbit-oak by apache.

the class UtilsTest method getPreviousIdFor.

@Test
public void getPreviousIdFor() {
    Revision r = new Revision(System.currentTimeMillis(), 0, 0);
    assertEquals("2:p/" + r.toString() + "/0", Utils.getPreviousIdFor("/", r, 0));
    assertEquals("3:p/test/" + r.toString() + "/1", Utils.getPreviousIdFor("/test", r, 1));
    assertEquals("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/" + r.toString() + "/3", Utils.getPreviousIdFor("/a/b/c/d/e/f/g/h/i/j/k/l/m", r, 3));
}
Also used : Revision(org.apache.jackrabbit.oak.plugins.document.Revision) Test(org.junit.Test)

Example 7 with Revision

use of org.apache.jackrabbit.oak.plugins.document.Revision in project jackrabbit-oak by apache.

the class SecondaryStoreCacheTest method basicTest.

@Test
public void basicTest() throws Exception {
    SecondaryStoreCache cache = createCache(new PathFilter(of("/a"), empty));
    NodeBuilder nb = primary.getRoot().builder();
    create(nb, "/a/b", "/a/c", "/x/y/z");
    merge(nb);
    RevisionVector rv1 = new RevisionVector(new Revision(1, 0, 1));
    RevisionVector rv2 = new RevisionVector(new Revision(1, 0, 3));
    assertNull(cache.getDocumentNodeState("/a/b", rv1, rv2));
    assertNull(cache.getDocumentNodeState("/x", rv1, rv2));
}
Also used : PathFilter(org.apache.jackrabbit.oak.plugins.index.PathFilter) Revision(org.apache.jackrabbit.oak.plugins.document.Revision) RevisionVector(org.apache.jackrabbit.oak.plugins.document.RevisionVector) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 8 with Revision

use of org.apache.jackrabbit.oak.plugins.document.Revision in project jackrabbit-oak by apache.

the class UtilsTest method performance_getPreviousIdFor.

@Ignore("Performance test")
@Test
public void performance_getPreviousIdFor() {
    Revision r = new Revision(System.currentTimeMillis(), 0, 0);
    String path = "/some/test/path/foo";
    // warm up
    for (int i = 0; i < 1 * 1000 * 1000; i++) {
        Utils.getPreviousIdFor(path, r, 0);
    }
    long time = System.currentTimeMillis();
    for (int i = 0; i < 10 * 1000 * 1000; i++) {
        Utils.getPreviousIdFor(path, r, 0);
    }
    time = System.currentTimeMillis() - time;
    System.out.println(time);
}
Also used : Revision(org.apache.jackrabbit.oak.plugins.document.Revision) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 9 with Revision

use of org.apache.jackrabbit.oak.plugins.document.Revision in project jackrabbit-oak by apache.

the class UtilsTest method min.

@Test
public void min() {
    Revision a = new Revision(42, 1, 1);
    Revision b = new Revision(43, 0, 1);
    assertSame(a, Utils.min(a, b));
    Revision a1 = new Revision(42, 0, 1);
    assertSame(a1, Utils.min(a, a1));
    assertSame(a, Utils.min(a, null));
    assertSame(a, Utils.min(null, a));
    assertNull(Utils.max(null, null));
}
Also used : Revision(org.apache.jackrabbit.oak.plugins.document.Revision) Test(org.junit.Test)

Example 10 with Revision

use of org.apache.jackrabbit.oak.plugins.document.Revision in project jackrabbit-oak by apache.

the class UtilsTest method max.

@Test
public void max() {
    Revision a = new Revision(42, 0, 1);
    Revision b = new Revision(43, 0, 1);
    assertSame(b, Utils.max(a, b));
    Revision a1 = new Revision(42, 1, 1);
    assertSame(a1, Utils.max(a, a1));
    assertSame(a, Utils.max(a, null));
    assertSame(a, Utils.max(null, a));
    assertNull(Utils.max(null, null));
}
Also used : Revision(org.apache.jackrabbit.oak.plugins.document.Revision) Test(org.junit.Test)

Aggregations

Revision (org.apache.jackrabbit.oak.plugins.document.Revision)32 Test (org.junit.Test)17 RevisionVector (org.apache.jackrabbit.oak.plugins.document.RevisionVector)13 BasicDBObject (com.mongodb.BasicDBObject)4 DBObject (com.mongodb.DBObject)4 NodeDocument (org.apache.jackrabbit.oak.plugins.document.NodeDocument)4 PathRev (org.apache.jackrabbit.oak.plugins.document.PathRev)4 UpdateOp (org.apache.jackrabbit.oak.plugins.document.UpdateOp)4 DBCollection (com.mongodb.DBCollection)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 StringValue (org.apache.jackrabbit.oak.plugins.document.util.StringValue)3 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)3 TreeMap (java.util.TreeMap)2 AbstractDocumentNodeState (org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState)2 AbstractMongoConnectionTest (org.apache.jackrabbit.oak.plugins.document.AbstractMongoConnectionTest)2 DocumentStoreException (org.apache.jackrabbit.oak.plugins.document.DocumentStoreException)2 Key (org.apache.jackrabbit.oak.plugins.document.UpdateOp.Key)2 Operation (org.apache.jackrabbit.oak.plugins.document.UpdateOp.Operation)2