Search in sources :

Example 1 with ChildNodeEntry

use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.

the class TypePredicate method isOrderable.

@Nonnull
public static TypePredicate isOrderable(@Nonnull NodeState root) {
    Set<String> orderable = newHashSet();
    NodeState types = checkNotNull(root).getChildNode(JCR_SYSTEM).getChildNode(JCR_NODE_TYPES);
    for (ChildNodeEntry entry : types.getChildNodeEntries()) {
        NodeState type = entry.getNodeState();
        if (type.getBoolean(JCR_HASORDERABLECHILDNODES)) {
            orderable.add(entry.getName());
        }
    }
    return new TypePredicate(root, orderable);
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry) Nonnull(javax.annotation.Nonnull)

Example 2 with ChildNodeEntry

use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.

the class UniqueEntryStoreStrategy method query.

@Override
public Iterable<String> query(final Filter filter, final String indexName, final NodeState indexMeta, final Iterable<String> values) {
    final NodeState index = indexMeta.getChildNode(getIndexNodeName());
    return new Iterable<String>() {

        @Override
        public Iterator<String> iterator() {
            if (values == null) {
                return new Iterator<String>() {

                    Iterator<? extends ChildNodeEntry> it = index.getChildNodeEntries().iterator();

                    @Override
                    public boolean hasNext() {
                        return it.hasNext();
                    }

                    @Override
                    public String next() {
                        PropertyState s = it.next().getNodeState().getProperty("entry");
                        return s.getValue(Type.STRING, 0);
                    }

                    @Override
                    public void remove() {
                        it.remove();
                    }
                };
            }
            ArrayList<String> list = new ArrayList<String>();
            for (String p : values) {
                NodeState key = index.getChildNode(p);
                if (key.exists()) {
                    // we have an entry for this value, so use it
                    PropertyState s = key.getProperty("entry");
                    String v = s.getValue(Type.STRING, 0);
                    list.add(v);
                }
            }
            return list.iterator();
        }
    };
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) MultiStringPropertyState(org.apache.jackrabbit.oak.plugins.memory.MultiStringPropertyState) PropertyState(org.apache.jackrabbit.oak.api.PropertyState)

Example 3 with ChildNodeEntry

use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.

the class NodeCounter method collectCounts.

private void collectCounts(StringBuilder buff, String path, int level) {
    long count = getEstimatedNodeCount(path);
    if (count > 0) {
        if (buff.length() > 0) {
            buff.append(",\n");
        }
        buff.append(path).append(": ").append(count);
    }
    if (level <= 0) {
        return;
    }
    NodeState s = child(store.getRoot(), PathUtils.elements(path));
    if (!s.exists()) {
        return;
    }
    ArrayList<String> names = new ArrayList<String>();
    for (ChildNodeEntry c : s.getChildNodeEntries()) {
        names.add(c.getName());
    }
    Collections.sort(names);
    for (String cn : names) {
        s.getChildNode(cn);
        String child = PathUtils.concat(path, cn);
        collectCounts(buff, child, level - 1);
    }
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry) ArrayList(java.util.ArrayList)

Example 4 with ChildNodeEntry

use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.

the class NodeStateJsonUtils method copyNode.

private static void copyNode(NodeState state, JsopWriter json, boolean includeHiddenContent) {
    copyProperties(state, json, includeHiddenContent);
    for (ChildNodeEntry cne : state.getChildNodeEntries()) {
        if (!includeHiddenContent && NodeStateUtils.isHidden(cne.getName())) {
            continue;
        }
        json.key(cne.getName());
        json.object();
        copyNode(cne.getNodeState(), json, includeHiddenContent);
        json.endObject();
    }
}
Also used : ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)

Example 5 with ChildNodeEntry

use of org.apache.jackrabbit.oak.spi.state.ChildNodeEntry in project jackrabbit-oak by apache.

the class DebugTars method filterNodeStates.

private void filterNodeStates(Set<UUID> uuids, List<String> paths, SegmentNodeState state, String path) {
    Set<String> localPaths = newTreeSet();
    for (PropertyState ps : state.getProperties()) {
        if (ps instanceof SegmentPropertyState) {
            SegmentPropertyState sps = (SegmentPropertyState) ps;
            RecordId recordId = sps.getRecordId();
            UUID id = recordId.getSegmentId().asUUID();
            if (uuids.contains(id)) {
                if (ps.getType().tag() == PropertyType.STRING) {
                    String val = "";
                    if (ps.count() > 0) {
                        // only shows the first value, do we need more?
                        val = displayString(ps.getValue(Type.STRING, 0));
                    }
                    localPaths.add(getLocalPath(path, ps, val, recordId));
                } else {
                    localPaths.add(getLocalPath(path, ps, recordId));
                }
            }
            if (ps.getType().tag() == PropertyType.BINARY) {
                // look for extra segment references
                for (int i = 0; i < ps.count(); i++) {
                    Blob b = ps.getValue(Type.BINARY, i);
                    for (SegmentId sbid : SegmentBlob.getBulkSegmentIds(b)) {
                        UUID bid = sbid.asUUID();
                        if (!bid.equals(id) && uuids.contains(bid)) {
                            localPaths.add(getLocalPath(path, ps, recordId));
                        }
                    }
                }
            }
        }
    }
    RecordId stateId = state.getRecordId();
    if (uuids.contains(stateId.getSegmentId().asUUID())) {
        localPaths.add(path + " [SegmentNodeState@" + stateId + "]");
    }
    RecordId templateId = getTemplateId(state);
    if (uuids.contains(templateId.getSegmentId().asUUID())) {
        localPaths.add(path + "[Template@" + templateId + "]");
    }
    paths.addAll(localPaths);
    for (ChildNodeEntry ce : state.getChildNodeEntries()) {
        NodeState c = ce.getNodeState();
        if (c instanceof SegmentNodeState) {
            filterNodeStates(uuids, paths, (SegmentNodeState) c, path + ce.getName() + "/");
        }
    }
}
Also used : SegmentBlob(org.apache.jackrabbit.oak.segment.SegmentBlob) Blob(org.apache.jackrabbit.oak.api.Blob) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) SegmentNodeState(org.apache.jackrabbit.oak.segment.SegmentNodeState) SegmentPropertyState(org.apache.jackrabbit.oak.segment.SegmentPropertyState) SegmentId(org.apache.jackrabbit.oak.segment.SegmentId) ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry) RecordId(org.apache.jackrabbit.oak.segment.RecordId) UUID(java.util.UUID) SegmentNodeState(org.apache.jackrabbit.oak.segment.SegmentNodeState) SegmentPropertyState(org.apache.jackrabbit.oak.segment.SegmentPropertyState) PropertyState(org.apache.jackrabbit.oak.api.PropertyState)

Aggregations

ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)80 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)58 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)23 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)18 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)7 MemoryDocumentStore (org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore)6 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 MemoryChildNodeEntry (org.apache.jackrabbit.oak.plugins.memory.MemoryChildNodeEntry)4 AbstractNodeState (org.apache.jackrabbit.oak.spi.state.AbstractNodeState)4 Calendar (java.util.Calendar)3 VersionGCStats (org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats)3 SegmentNodeState (org.apache.jackrabbit.oak.segment.SegmentNodeState)3 Clock (org.apache.jackrabbit.oak.stats.Clock)3 Iterator (java.util.Iterator)2 Map (java.util.Map)2 UUID (java.util.UUID)2 CheckForNull (javax.annotation.CheckForNull)2 Nonnull (javax.annotation.Nonnull)2