Search in sources :

Example 1 with SegmentPropertyState

use of org.apache.jackrabbit.oak.segment.SegmentPropertyState 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

UUID (java.util.UUID)1 Blob (org.apache.jackrabbit.oak.api.Blob)1 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)1 RecordId (org.apache.jackrabbit.oak.segment.RecordId)1 SegmentBlob (org.apache.jackrabbit.oak.segment.SegmentBlob)1 SegmentId (org.apache.jackrabbit.oak.segment.SegmentId)1 SegmentNodeState (org.apache.jackrabbit.oak.segment.SegmentNodeState)1 SegmentPropertyState (org.apache.jackrabbit.oak.segment.SegmentPropertyState)1 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)1 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)1