Package org.apache.jackrabbit.oak.plugins.index.old.mk.simple

Examples of org.apache.jackrabbit.oak.plugins.index.old.mk.simple.NodeImpl


        head = mk.commit("/:root/head/config", "^ \"nodeVersion\": true", head, "");

        head = mk.commit("/", "+ \"test1\": { \"id\": 1 }", head, "");
        head = mk.commit("/", "+ \"test2\": { \"id\": 1 }", head, "");

        NodeImpl n = NodeImpl.parse(mk.getNodes("/", head, 1, 0, -1, null));
        String vra = n.getNodeVersion();
        String v1a = n.getNode("test1").getNodeVersion();
        String v2a = n.getNode("test2").getNodeVersion();

        // changes the node version
        head = mk.commit("/", "^ \"test2/id\": 2", head, "");

        n = NodeImpl.parse(mk.getNodes("/", head, 1, 0, -1, null));
        String vrb = n.getNodeVersion();
        String v1b = n.getNode("test1").getNodeVersion();
        String v2b = n.getNode("test2").getNodeVersion();

        assertFalse(vra.equals(vrb));
        assertEquals(v1a, v1b);
        assertFalse(v2a.equals(v2b));
    }
View Full Code Here


            return;
        }

        head = mk.commit("/", "+ \"test1\": { \"id\": 1 }", mk.getHeadRevision(), "");
        head = mk.commit("/", "+ \"test2\": { \"id\": 1 }", mk.getHeadRevision(), "");
        NodeImpl r = NodeImpl.parse(mk.getNodes("/", head, 1, 0, -1, null));
        assertTrue(r.getHash() != null);
        NodeImpl t1 = NodeImpl.parse(mk.getNodes("/test1", head, 1, 0, -1, null));
        NodeImpl t2 = NodeImpl.parse(mk.getNodes("/test2", head, 1, 0, -1, null));
        assertTrue(Arrays.equals(t1.getHash(), t2.getHash()));
        assertFalse(Arrays.equals(t1.getHash(), r.getHash()));
    }
View Full Code Here

        NodeMap map = new NodeMap();

        map.setMaxMemoryChildren(2);
        map.setDescendantInlineCount(-1);

        NodeImpl n = new NodeImpl(map, 0);
        Assert.assertEquals("{}", n.asString());
        n.setId(NodeId.get(255));
        Assert.assertEquals("nff={};", n.asString());
        n.setPath("/test");
        Assert.assertEquals("nff={};/* /test */", n.toString());
        n = n.createClone(10);
        Assert.assertEquals("{}", n.asString());
        NodeImpl a = new NodeImpl(map, 0);
        map.addNode(a);
        NodeImpl b = new NodeImpl(map, 0);
        map.addNode(b);
        NodeImpl c = new NodeImpl(map, 0);
        map.addNode(c);
        NodeImpl d = new NodeImpl(map, 0);
        map.addNode(d);
        n = n.cloneAndAddChildNode("a", false, null, a, 11);
        n = n.cloneAndSetProperty("x", "1", 12);
        n.setId(NodeId.get(3));
        Assert.assertEquals("n3={\"x\":1,\"a\":n1};", n.asString());
        NodeImpl n2 = NodeImpl.fromString(map, n.asString());
        Assert.assertEquals("n3={\"x\":1,\"a\":n1};", n2.asString());

        n = new NodeImpl(map, 0);
        n = n.cloneAndAddChildNode("a", false, null, a, 1);
        Assert.assertEquals("{\"a\":n1}", n.asString());
        n = n.cloneAndAddChildNode("b", false, null, b, 2);
        Assert.assertEquals("{\"a\":n1,\"b\":n2}", n.asString());
        n = n.cloneAndAddChildNode("c", false, null, c, 3);
        Assert.assertEquals("{\"a\":n1,\"b\":n2,\"c\":n3}", n.asString());
        n = n.cloneAndAddChildNode("d", false, null, d, 4);
        Assert.assertEquals("{\":children\":n5,\":names\":\"a\",\":children\":n6,\":names\":\"b\",\":children\":n7,\":names\":\"c\",\":children\":n8,\":names\":\"d\",\n\":childCount\":4}",
                n.asString());
        n2 = NodeImpl.fromString(map, n.asString());
        Assert.assertEquals("{\":children\":n5,\":names\":\"a\",\":children\":n6,\":names\":\"b\",\":children\":n7,\":names\":\"c\",\":children\":n8,\":names\":\"d\",\n\":childCount\":4}",
                n2.asString());
        Assert.assertTrue(n2.exists("a"));
        Assert.assertTrue(n2.exists("b"));
        Assert.assertTrue(n2.exists("c"));
        Assert.assertTrue(n2.exists("d"));

    }
View Full Code Here

    public void inlineChildNodes() {
        NodeMap map = new NodeMap();
        map.setDescendantCount(true);
        map.setDescendantInlineCount(3);

        NodeImpl n = new NodeImpl(map, 0);
        Assert.assertEquals("{}", n.asString());
        NodeImpl a = new NodeImpl(map, 0);
        a.setProperty("name", "\"a\"");
        map.addNode(a);
        NodeImpl b = new NodeImpl(map, 0);
        b.setProperty("name", "\"b\"");
        map.addNode(b);
        NodeImpl c = new NodeImpl(map, 0);
        c.setProperty("name", "\"c\"");
        map.addNode(c);
        NodeImpl d = new NodeImpl(map, 0);
        d.setProperty("name", "\"d\"");
        map.addNode(d);
        n = n.cloneAndAddChildNode("a", false, null, a, 11);
        n = n.cloneAndSetProperty("x", "1", 12);
        n.setId(NodeId.get(3));
        Assert.assertEquals("n3={\"x\":1,\"a\":{\"name\":\"a\"}};", n.asString());
        NodeImpl n2 = NodeImpl.fromString(map, n.asString());
        Assert.assertEquals("n3={\"x\":1,\"a\":{\"name\":\"a\"}};", n2.asString());

        n = new NodeImpl(map, 0);
        n = n.cloneAndAddChildNode("a", false, null, a, 1);
        Assert.assertEquals("{\"a\":{\"name\":\"a\"}}", n.asString());
        n = n.cloneAndAddChildNode("b", false, null, b, 2);
        String ab = "{\"a\":{\"name\":\"a\"},\"b\":{\"name\":\"b\"}}";
        Assert.assertEquals(ab, n.asString());
        n = n.cloneAndAddChildNode("c", false, null, c, 3);
        String abc = "{\"a\":{\"name\":\"a\"},\"b\":{\"name\":\"b\"},\"c\":{\"name\":\"c\"}}";
        Assert.assertEquals(abc, n.asString());
        Assert.assertEquals(3, n.getDescendantCount());
        Assert.assertEquals(3, n.getDescendantInlineCount());
        n2 = NodeImpl.fromString(map, n.asString());
        Assert.assertTrue(n2.exists("a"));
        Assert.assertTrue(n2.exists("b"));
        Assert.assertTrue(n2.exists("c"));
        Assert.assertEquals(3, n2.getDescendantCount());
        Assert.assertEquals(3, n2.getDescendantInlineCount());

        NodeImpl root = new NodeImpl(map, 0);
        root = root.cloneAndAddChildNode("test", false, null, n2, 1);
        Assert.assertEquals("{\":size\":4,\"test\":n1}", root.asString());
        Assert.assertEquals(0, root.getDescendantInlineCount());

        n2 = n2.cloneAndRemoveChildNode("c", 4);
        root = new NodeImpl(map, 0);
        root = root.cloneAndAddChildNode("test", false, null, n2, 1);
        Assert.assertEquals("{\":size\":3,\"test\":" + ab + "}", root.asString());

    }
View Full Code Here

            c.setTotalCount(i);
            c.setData(null);
            c.create();
            head = mk.getHeadRevision();
            String json = JsopBuilder.prettyPrint(mk.getNodes("/test" + i, head, Integer.MAX_VALUE, 0, -1, null));
            NodeImpl n = NodeImpl.parse(json);
            long count = count(n);
            JsopObject o = (JsopObject) Jsop.parse(json);
            Object d = o.get(NodeImpl.DESCENDANT_COUNT);
            if (d != null) {
                long descendants = Long.parseLong(d.toString());
View Full Code Here

        for (long pos = 0;; pos++) {
            String childName = n.getChildNodeName(pos);
            if (childName == null) {
                break;
            }
            NodeImpl c = n.getNode(childName);
            count += count(c);
        }
        return count;
    }
View Full Code Here

        }
        int i = 0;
        String last = first;
        for (String rev : revs) {
            String n = mk.getNodes("/test", rev, 1, 0, -1, null);
            NodeImpl node = NodeImpl.parse(n);
            assertEquals(i, Integer.parseInt(node.getProperty("id")));
            String journal = mk.getJournal(last, rev, null);
            JsopArray array = (JsopArray) Jsop.parse(journal);
            assertEquals(last + ".." + rev + ": " + journal,
                    2, array.size());
            JsopObject obj = (JsopObject) array.get(0);
View Full Code Here

        if (count >= totalCount) {
            return;
        }

        String parentJson = JsopBuilder.prettyPrint(mk.getNodes("/" + parent, mk.getHeadRevision(), 1, 0, -1, null));
        NodeImpl parentNode = NodeImpl.parse(parentJson);
        int width = Integer.parseInt(parentNode.getProperty("width"));

        for (int i = 0; i < width; i++) {
            if (count >= totalCount) {
                break;
            }
View Full Code Here

    public void setUp() throws Exception {
        mk = MicroKernelFactory.getInstance(url + ";clean");
        cleanRepository(mk);

        String root = mk.getNodes("/", mk.getHeadRevision(), 1, 0, -1, null);
        NodeImpl rootNode = NodeImpl.parse(root);
        if (rootNode.getPropertyCount() > 0) {
            System.out.println("Last mk not disposed: " + root);
        }
        if (rootNode.getChildNodeNames(Integer.MAX_VALUE).hasNext()) {
            System.out.println("Last mk not disposed: " + root);
        }
        if (PROFILE) {
            prof = new Profiler();
            prof.interval = 1;
View Full Code Here

        if (mk.nodeExists(MOUNT, head)) {
            String mounts = mk.getNodes(MOUNT, head, 1, 0, -1, null);
            NodeMap map = new NodeMap();
            JsopReader t = new JsopTokenizer(mounts);
            t.read('{');
            NodeImpl n = NodeImpl.parse(map, t, 0);
            for (long pos = 0;; pos++) {
                String childName = n.getChildNodeName(pos);
                if (childName == null) {
                    break;
                }
                NodeImpl mount = n.getNode(childName);
                String mountUrl = JsopTokenizer.decodeQuoted(mount.getProperty("url"));
                String[] paths = JsopTokenizer.decodeQuoted(mount.getProperty("paths")).split(",");
                addMount(childName, mountUrl, paths);
                getHeadRevision();
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.plugins.index.old.mk.simple.NodeImpl

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.