Search in sources :

Example 76 with ChildNodeEntry

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

the class HybridPropertyIndexInfo method collectBucketData.

private void collectBucketData(NodeState propIdxState) {
    String head = propIdxState.getString(PROP_HEAD_BUCKET);
    String previous = propIdxState.getString(PROP_PREVIOUS_BUCKET);
    for (ChildNodeEntry cne : propIdxState.getChildNodeEntries()) {
        String bucketName = cne.getName();
        NodeState bucket = cne.getNodeState();
        json.key(bucketName).object();
        json.key("type");
        if (Objects.equals(head, bucketName)) {
            json.value("head");
        } else if (Objects.equals(previous, bucketName)) {
            json.value("previous");
        } else {
            json.value("garbage");
        }
        json.key("keyCount").value(bucket.getChildNodeCount(Integer.MAX_VALUE));
        collectCounts(bucket);
        json.endObject();
    }
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)

Example 77 with ChildNodeEntry

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

the class HybridPropertyIndexInfo method collectCounts.

private void collectCounts(NodeState bucket) {
    TreeTraverser<NodeState> t = new TreeTraverser<NodeState>() {

        @Override
        public Iterable<NodeState> children(NodeState root) {
            return Iterables.transform(root.getChildNodeEntries(), ChildNodeEntry::getNodeState);
        }
    };
    AtomicInteger matches = new AtomicInteger();
    int totalCount = t.preOrderTraversal(bucket).transform((st) -> {
        if (st.getBoolean("match")) {
            matches.incrementAndGet();
        }
        return st;
    }).size();
    json.key("entryCount").value(matches.get());
    json.key("totalCount").value(totalCount);
}
Also used : Objects(java.util.Objects) TreeTraverser(com.google.common.collect.TreeTraverser) ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry) Iterables(com.google.common.collect.Iterables) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) JsopBuilder(org.apache.jackrabbit.oak.commons.json.JsopBuilder) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) PROP_HEAD_BUCKET(org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexUtil.PROP_HEAD_BUCKET) PROP_PREVIOUS_BUCKET(org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexUtil.PROP_PREVIOUS_BUCKET) PROPERTY_INDEX(org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexUtil.PROPERTY_INDEX) HybridPropertyIndexUtil.simplePropertyIndex(org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexUtil.simplePropertyIndex) HybridPropertyIndexUtil.uniquePropertyIndex(org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexUtil.uniquePropertyIndex) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TreeTraverser(com.google.common.collect.TreeTraverser) ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)

Example 78 with ChildNodeEntry

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

the class HybridPropertyIndexInfo method getInfoAsJson.

public String getInfoAsJson() {
    json.resetWriter();
    json.object();
    NodeState propertyIndexNode = idx.getChildNode(PROPERTY_INDEX);
    for (ChildNodeEntry cne : propertyIndexNode.getChildNodeEntries()) {
        NodeState propIdxState = cne.getNodeState();
        String propName = cne.getName();
        json.key(propName).object();
        if (simplePropertyIndex(propIdxState)) {
            collectBucketData(propIdxState);
        } else if (uniquePropertyIndex(propIdxState)) {
            json.key("entryCount").value(propIdxState.getChildNodeCount(Integer.MAX_VALUE));
            json.key("unique").value(true);
        }
        json.endObject();
    }
    json.endObject();
    return JsopBuilder.prettyPrint(json.toString());
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)

Example 79 with ChildNodeEntry

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

the class RecursiveDelete method deleteChildNodes.

private int deleteChildNodes(NodeState node, String path) throws CommitFailedException {
    int currentSize = 0;
    for (ChildNodeEntry cne : node.getChildNodeEntries()) {
        String name = cne.getName();
        String childPath = PathUtils.concat(path, name);
        currentSize += delete(cne.getNodeState(), childPath);
        if (save(childPath, currentSize, false)) {
            currentSize = 0;
        }
    }
    return currentSize;
}
Also used : ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)

Example 80 with ChildNodeEntry

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

the class IndexDefinition method buildMimeTypeMap.

private static Map<String, String> buildMimeTypeMap(NodeState node) {
    ImmutableMap.Builder<String, String> map = ImmutableMap.builder();
    for (ChildNodeEntry child : node.getChildNodeEntries()) {
        for (ChildNodeEntry subChild : child.getNodeState().getChildNodeEntries()) {
            StringBuilder typeBuilder = new StringBuilder(child.getName()).append('/').append(subChild.getName());
            PropertyState property = subChild.getNodeState().getProperty(TIKA_MAPPED_TYPE);
            if (property != null) {
                map.put(typeBuilder.toString(), property.getValue(Type.STRING));
            }
        }
    }
    return map.build();
}
Also used : ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry) ImmutableMap(com.google.common.collect.ImmutableMap) 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