Package org.apache.jackrabbit.oak.plugins.segment

Examples of org.apache.jackrabbit.oak.plugins.segment.SegmentWriter


    public MemoryJournal(SegmentStore store, NodeState head) {
        this.store = checkNotNull(store);
        this.parent = null;

        SegmentWriter writer = store.getWriter();
        RecordId id = writer.writeNode(head).getRecordId();
        writer.flush();

        this.base = id;
        this.head = id;
    }
View Full Code Here


    }

    @Override
    public synchronized boolean setHead(RecordId base, RecordId head) {
        if (checkNotNull(base).equals(this.head)) {
            SegmentWriter writer = store.getWriter();
            if (writer.getCurrentSegment(head.getSegmentId()) != null) {
                writer.flush();
            }
            this.head = checkNotNull(head);
            return true;
        } else {
            return false;
View Full Code Here

    }

    @Override
    public synchronized void merge() {
        if (parent != null) {
            SegmentWriter writer = store.getWriter();

            Segment segment = writer.getDummySegment();
            NodeState before = new SegmentNodeState(segment, base);
            NodeState after = new SegmentNodeState(segment, head);

            while (!parent.setHead(base, head)) {
                RecordId newBase = parent.getHead();
                NodeBuilder builder =
                        new SegmentNodeState(segment, newBase).builder();
                after.compareAgainstBaseState(before, new MergeDiff(builder));
                NodeState state = builder.getNodeState();

                RecordId newHead = writer.writeNode(state).getRecordId();

                base = newBase;
                head = newHead;
            }
View Full Code Here

        this.name = "root";

        DBObject id = new BasicDBObject("_id", "root");
        state = journals.findOne(id, null, primaryPreferred());
        if (state == null) {
            SegmentWriter writer = store.getWriter();
            RecordId headId = writer.writeNode(head).getRecordId();
            writer.flush();
            state = new BasicDBObject(of(
                    "_id""root",
                    "head", headId.toString()));
            try {
                journals.insert(state, concern);
View Full Code Here

        if (state.containsField("parent")) {
            RecordId base = RecordId.fromString(state.get("base").toString());
            RecordId head = RecordId.fromString(state.get("head").toString());

            SegmentWriter writer = store.getWriter();
            Segment segment = writer.getDummySegment();

            NodeState before = new SegmentNodeState(segment, base);
            NodeState after = new SegmentNodeState(segment, head);

            Journal parent = store.getJournal(state.get("parent").toString());
            while (!parent.setHead(base, head)) {
                RecordId newBase = parent.getHead();
                NodeBuilder builder =
                        new SegmentNodeState(segment, newBase).builder();
                after.compareAgainstBaseState(before, new MergeDiff(builder));
                RecordId newHead =
                        writer.writeNode(builder.getNodeState()).getRecordId();

                base = newBase;
                head = newHead;
            }
View Full Code Here

        this.name = "root";

        DBObject id = new BasicDBObject("_id", "root");
        state = journals.findOne(id, null, primaryPreferred());
        if (state == null) {
            SegmentWriter writer = store.getWriter();
            RecordId headId = writer.writeNode(head).getRecordId();
            writer.flush();
            state = new BasicDBObject(of(
                    "_id""root",
                    "head", headId.toString()));
            try {
                journals.insert(state, concern);
View Full Code Here

        if (state.containsField("parent")) {
            RecordId base = RecordId.fromString(state.get("base").toString());
            RecordId head = RecordId.fromString(state.get("head").toString());

            SegmentWriter writer = store.getWriter();
            Segment segment = writer.getDummySegment();

            NodeState before = new SegmentNodeState(segment, base);
            NodeState after = new SegmentNodeState(segment, head);

            Journal parent = store.getJournal(state.get("parent").toString());
            while (!parent.setHead(base, head)) {
                RecordId newBase = parent.getHead();
                NodeBuilder builder =
                        new SegmentNodeState(segment, newBase).builder();
                after.compareAgainstBaseState(before, new MergeDiff(builder));
                RecordId newHead =
                        writer.writeNode(builder.getNodeState()).getRecordId();

                base = newBase;
                head = newHead;
            }
View Full Code Here

        this.name = "root";

        DBObject id = new BasicDBObject("_id", "root");
        state = journals.findOne(id, null, primaryPreferred());
        if (state == null) {
            SegmentWriter writer = new SegmentWriter(store);
            RecordId head = writer.writeNode(root).getRecordId();
            writer.flush();
            state = new BasicDBObject(of(
                    "_id""root",
                    "head", head.toString()));
            try {
                journals.insert(state, concern);
View Full Code Here

            NodeState before = new SegmentNodeState(store, base);
            NodeState after = new SegmentNodeState(store, head);

            Journal parent = store.getJournal(state.get("parent").toString());
            SegmentWriter writer = new SegmentWriter(store);
            while (!parent.setHead(base, head)) {
                RecordId newBase = parent.getHead();
                NodeBuilder builder =
                        new SegmentNodeState(store, newBase).builder();
                after.compareAgainstBaseState(before, new MergeDiff(builder));
                RecordId newHead =
                        writer.writeNode(builder.getNodeState()).getRecordId();
                writer.flush();

                base = newBase;
                head = newHead;
            }
View Full Code Here

    public MemoryJournal(SegmentStore store, NodeState root) {
        this.store = checkNotNull(store);
        this.parent = null;

        SegmentWriter writer = new SegmentWriter(store);
        RecordId id = writer.writeNode(root).getRecordId();
        writer.flush();

        this.base = id;
        this.head = id;
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.plugins.segment.SegmentWriter

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.