Package org.apache.jackrabbit.oak.plugins.index

Examples of org.apache.jackrabbit.oak.plugins.index.Cursor


            // print(mk, tree);
        }
        // indexer.commitChanges();
        for (int i = 0; i < len; i++) {
            // log("#test " + i);
            Cursor c = tree.findFirst("" + i);
            if (c.hasNext()) {
                Assert.assertEquals("" + i, c.next());
            }
        }
        print(mk, tree);
        for (int i = 0; i < len; i++) {
            Assert.assertTrue("not found when removing " + i, tree.remove("" + i, null));
            // print(mk, tree);
        }
        // indexer.commitChanges();
        print(mk, tree);
        for (int i = 0; i < len; i++) {
            Cursor c = tree.findFirst("" + i);
            Assert.assertFalse(c.hasNext());
        }
    }
View Full Code Here


        } else {
            tree.add("1", "p2");
        }

        // search
        Cursor c = tree.findFirst("1");
        Assert.assertEquals("1", c.next());
        Assert.assertEquals("p1", c.getValue());
        if (unique) {
            Assert.assertFalse(c.hasNext());
        } else {
            Assert.assertEquals("1", c.next());
            Assert.assertEquals("p2", c.getValue());
        }
        try {
            c.remove();
            Assert.fail();
        } catch (UnsupportedOperationException e) {
            // expected
        }
        Assert.assertFalse(c.hasNext());
        Assert.assertEquals(null, c.next());

        // remove
        tree.remove("1", "p1");

    }
View Full Code Here

        for (int i = 0; i < 100; i++) {
            log("op #" + i);
            // print(mk, tree);
            int x = r.nextInt(10);
            boolean exists = treeMap.containsKey(x);
            Cursor c = tree.findFirst("" + x);
            boolean gotExists = c.hasNext();
            String x2 = null;
            if (gotExists) {
                x2 = c.next();
                if (!x2.equals("" + x)) {
                    gotExists = false;
                }
            }
            Assert.assertEquals("find " + x, exists, gotExists);
            if (exists) {
                Assert.assertEquals("" + x, x2);
                Assert.assertEquals(treeMap.get(x), c.getValue());
            }
            boolean add = r.nextBoolean();
            if (add) {
                if (!exists) {
                    log("#insert " + x + " = p" + i);
View Full Code Here

    static void print(MicroKernel mk, BTree tree) {
        String head = mk.getHeadRevision();
        String t = mk.getNodes(Indexer.INDEX_CONFIG_PATH, head, 100, 0, -1, null);
        log(t);
        Cursor c = tree.findFirst("0");
        StringBuilder buff = new StringBuilder();
        while (c.hasNext()) {
            buff.append(c.next()).append(' ');
        }
        log(buff.toString());
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.plugins.index.Cursor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.