Search in sources :

Example 16 with NodeStateEntry

use of org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry in project jackrabbit-oak by apache.

the class ChildNodeStateProvider method children.

Iterator<NodeStateEntry> children(boolean preferred) {
    PeekingIterator<NodeStateEntry> pitr = Iterators.peekingIterator(entries.iterator());
    if (!pitr.hasNext()) {
        return emptyIterator();
    }
    // Skip till current entry
    while (pitr.hasNext() && !pitr.peek().getPath().equals(path)) {
        pitr.next();
    }
    // Skip past the current find
    checkState(pitr.hasNext() && path.equals(pitr.next().getPath()), "Did not found path [%s] in leftover iterator. Possibly node state accessed " + "after main iterator has moved past it", path);
    // Prepare an iterator to fetch all child node paths i.e. immediate and there children
    return new AbstractIterator<NodeStateEntry>() {

        @Override
        protected NodeStateEntry computeNext() {
            while (pitr.hasNext() && isAncestor(path, pitr.peek().getPath())) {
                NodeStateEntry nextEntry = pitr.next();
                String nextEntryPath = nextEntry.getPath();
                if (isImmediateChild(nextEntryPath)) {
                    String nextEntryName = PathUtils.getName(nextEntryPath);
                    if (preferred && !preferredPathElements.contains(nextEntryName)) {
                        return endOfData();
                    }
                    return nextEntry;
                }
            }
            return endOfData();
        }
    };
}
Also used : NodeStateEntry(org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry) AbstractIterator(com.google.common.collect.AbstractIterator)

Example 17 with NodeStateEntry

use of org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry in project jackrabbit-oak by apache.

the class FlatFileBufferLinkedList method remove.

/**
 * Remove the first item from the list
 * @return {@code NodeStateEntry} data in the removed item
 */
public NodeStateEntry remove() {
    Preconditions.checkState(!isEmpty(), "Cannot remove item from empty list");
    NodeStateEntry ret = head.next.data;
    head.next.isValid = false;
    head.next = head.next.next;
    size--;
    memUsage -= ret.estimatedMemUsage();
    if (size == 0) {
        tail = head;
    }
    return ret;
}
Also used : NodeStateEntry(org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry)

Aggregations

NodeStateEntry (org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry)17 Test (org.junit.Test)13 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)6 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)6 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)4 Stopwatch (com.google.common.base.Stopwatch)2 AbstractIterator (com.google.common.collect.AbstractIterator)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 Arrays.asList (java.util.Arrays.asList)1 List (java.util.List)1 TestUtils.createList (org.apache.jackrabbit.oak.index.indexer.document.flatfile.TestUtils.createList)1 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)1