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);
}
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();
}
};
}
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);
}
}
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();
}
}
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() + "/");
}
}
}
Aggregations