Package org.apache.jackrabbit.oak.spi.state

Examples of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry


    @Override
    public NodeState getChildNode(@Nonnull String name) {
        NodeState child = state.getChildNode(checkNotNull(name));
        if (child.exists() && !context.canReadAll()) {
            ChildNodeEntry entry = new MemoryChildNodeEntry(name, child);
            return new WrapChildEntryFunction().apply(entry).getNodeState();
        } else {
            return child;
        }
    }
View Full Code Here


                        return iterator.hasNext();
                    }

                    @Override
                    public Tree next() {
                        ChildNodeEntry entry = iterator.next();
                        return new ImmutableTree(
                                ImmutableTree.this,
                                entry.getName(), entry.getNodeState());
                    }

                    @Override
                    public void remove() {
                        throw new UnsupportedOperationException();
View Full Code Here

        private void fetchNextPossiblyDuplicate() {
            while (!nodeIterators.isEmpty()) {
                Iterator<? extends ChildNodeEntry> iterator = nodeIterators.getLast();
                if (iterator.hasNext()) {
                    ChildNodeEntry entry = iterator.next();

                    readCount++;
                    if (readCount % 1000 == 0) {
                        FilterIterators.checkReadLimit(readCount, maxMemoryEntries);
                        LOG.warn("Traversed " + readCount + " nodes using index " + indexName + " with filter " + filter);
                    }

                    NodeState node = entry.getNodeState();

                    String name = entry.getName();
                    if (NodeStateUtils.isHidden(name)) {
                        continue;
                    }
                    currentPath = PathUtils.concat(parentPath, name);
View Full Code Here

                return;
            } else if (node.exists()) {
                if (node.hasProperty(NEXT)) {
                    // it's an index key and we have to relink the list
                    // (1) find the previous element
                    ChildNodeEntry previous = findPrevious(
                            index.getNodeState(), node.getNodeState());
                    if (previous == null) {
                        LOG.debug("previous not found. Already deleted in the meanwhile. Skipping re-link");
                    } else {
                        LOG.debug("previous: {}", previous);
                        // (2) find the next element
                        String next = node.getString(NEXT);
                        if (next == null) {
                            next = "";
                        }
                        // (3) re-link the previous to the next
                        index.getChildNode(previous.getName()).setProperty(NEXT, next);
                    }
                }
                node.remove();
            }
        }
View Full Code Here

     * @param node the node we want to compare
     * @return the previous item or null if not found.
     */
    @Nullable
    ChildNodeEntry findPrevious(@Nonnull final NodeState index, @Nonnull final NodeState node) {
        ChildNodeEntry previous = null;
        ChildNodeEntry current = null;
        boolean found = false;
        Iterator<? extends ChildNodeEntry> it = getChildNodeEntries(index, true).iterator();

        while (!found && it.hasNext()) {
            current = it.next();
            if (previous == null) {
                // first iteration
                previous = current;
            } else {
                found = node.equals(current.getNodeState());
                if (!found) {
                    previous = current;
                }
            }
        }
View Full Code Here

        final NodeState index = indexMeta.getChildNode(indexStorageNodeName);

        if (pr.first != null && !pr.first.equals(pr.last)) {
            // '>' & '>=' use case
            ChildNodeEntry firstValueableItem = seek(index,
                new PredicateGreaterThan(pr.first.getValue(Type.STRING), pr.firstIncluding));
            Iterable<String> it = Collections.emptyList();
            if (firstValueableItem != null) {
                Iterable<ChildNodeEntry> childrenIterable = (pr.last == null) ? new SeekedIterable(
                    index, firstValueableItem) : new BetweenIterable(index, firstValueableItem,
                    pr.last.getValue(Type.STRING), pr.lastIncluding);
                it = new QueryResultsWrapper(filter, indexName, childrenIterable);
            }
            return it;
        } else if (pr.last != null && !pr.last.equals(pr.first)) {
            // '<' & '<=' use case
            ChildNodeEntry firstValueableItem = seek(index,
                new PredicateLessThan(pr.last.getValue(Type.STRING), pr.lastIncluding));
            Iterable<String> it = Collections.emptyList();
            if (firstValueableItem != null) {
                it = new QueryResultsWrapper(filter, indexName, new SeekedIterable(index,
                    firstValueableItem));
View Full Code Here

                                      @Nonnull Predicate<ChildNodeEntry> condition) {
       
        // TODO the FullIterable will have to be replaced with something else once we'll have the
        // Skip part of the list implemented.
        Iterable<ChildNodeEntry> children = new FullIterable(index, false);
        ChildNodeEntry entry = null;
        for (ChildNodeEntry child : children) {
            if (condition.apply(child)) {
                entry = child;
                break;
            }
View Full Code Here

                   || (!includeStart && !Strings.isNullOrEmpty(current.getString(NEXT)));
        }

        @Override
        public ChildNodeEntry next() {
            ChildNodeEntry entry = null;
            if (includeStart && start.equals(current)) {
                entry = new OrderedChildNodeEntry(START, current);
                // let's set it to false. We just included it.
                includeStart = false;
            } else {
View Full Code Here

        Iterable<ChildNodeEntry> children = (Iterable<ChildNodeEntry>) store.getChildNodeEntries(indexState);
        assertNotNull("The iterable cannot be null", children);
        assertEquals("Expecting 2 items in the index", 2, Iterators.size(children.iterator()));

        // ensuring the right sequence
        ChildNodeEntry entry = null;
        children = (Iterable<ChildNodeEntry>) store.getChildNodeEntries(indexState);
        Iterator<ChildNodeEntry> it = children.iterator();
        assertTrue("We should have 2 elements left to loop through", it.hasNext());
        entry = it.next();
        assertEquals("The first element should be n1", n1, entry.getName());
        assertEquals("Wrong entry returned", node1, entry.getNodeState());
        assertTrue("We should have 1 elements left to loop through", it.hasNext());
        entry = it.next();
        assertEquals("The second element should be n0", n0, entry.getName());
        assertEquals("Wrong entry returned", node0, entry.getNodeState());
        assertFalse("We should have be at the end of the list", it.hasNext());
    }
View Full Code Here

        Iterable<ChildNodeEntry> children = (Iterable<ChildNodeEntry>) store.getChildNodeEntries(indexState, false);
        assertNotNull("The iterable cannot be null", children);
        assertEquals("Expecting 2 items in the index", 2, Iterators.size(children.iterator()));

        // ensuring the right sequence
        ChildNodeEntry entry = null;
        children = (Iterable<ChildNodeEntry>) store.getChildNodeEntries(indexState);
        Iterator<ChildNodeEntry> it = children.iterator();
        assertTrue("We should have 2 elements left to loop through", it.hasNext());
        entry = it.next();
        assertEquals("The first element should be n1", n1, entry.getName());
        assertEquals("Wrong entry returned", node1, entry.getNodeState());
        assertTrue("We should have 1 elements left to loop through", it.hasNext());
        entry = it.next();
        assertEquals("The second element should be n0", n0, entry.getName());
        assertEquals("Wrong entry returned", node0, entry.getNodeState());
        assertFalse("We should have be at the end of the list", it.hasNext());
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry

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.