use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class PropertyIndexInfoProvider method getInfo.
@Override
public IndexInfo getInfo(String indexPath) throws IOException {
NodeState idxState = NodeStateUtils.getNode(nodeStore.getRoot(), indexPath);
checkArgument(PropertyIndexEditorProvider.TYPE.equals(idxState.getString(IndexConstants.TYPE_PROPERTY_NAME)), "Index definition at [%s] is not of type 'property'", indexPath);
PropertyIndexInfo info = new PropertyIndexInfo(indexPath);
computeCountEstimate(info, idxState);
return info;
}
use of org.apache.jackrabbit.oak.spi.state.NodeState 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.NodeState 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.NodeState in project jackrabbit-oak by apache.
the class NodeTypePredicateTest method multipleNodeTypesMatch.
@Test
public void multipleNodeTypesMatch() {
NodeState node = createNodeOfType(NT_FILE);
TypePredicate p = new TypePredicate(node, new String[] { NT_FOLDER, NT_RESOURCE, NT_FILE });
assertTrue(p.apply(node));
}
use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class NodeTypePredicateTest method multipleNodeTypesMiss.
@Test
public void multipleNodeTypesMiss() {
NodeState node = createNodeOfType(NT_FILE);
TypePredicate p = new TypePredicate(node, new String[] { NT_FOLDER, NT_RESOURCE, JCR_CONTENT });
assertFalse(p.apply(node));
}
Aggregations