use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class DocumentBundlingTest method journalDiffAndBundling.
@Test
public void journalDiffAndBundling() throws Exception {
NodeBuilder builder = store.getRoot().builder();
NodeBuilder fileNode = newNode("nt:file");
fileNode.child("jcr:content").setProperty("jcr:data", "foo");
builder.child("test").setChildNode("book.jpg", fileNode.getNodeState());
NodeState r1 = merge(builder);
builder = store.getRoot().builder();
childBuilder(builder, "/test/book.jpg/jcr:content").setProperty("fooContent", "bar");
childBuilder(builder, "/test/book.jpg").setProperty("fooBook", "bar");
NodeState r2 = merge(builder);
final List<String> addedPropertyNames = Lists.newArrayList();
r2.compareAgainstBaseState(r1, new DefaultNodeStateDiff() {
@Override
public boolean propertyAdded(PropertyState after) {
addedPropertyNames.add(after.getName());
return super.propertyAdded(after);
}
@Override
public boolean childNodeChanged(String name, NodeState before, NodeState after) {
return after.compareAgainstBaseState(before, this);
}
});
assertTrue("No change reported for /test/book.jpg", addedPropertyNames.contains("fooBook"));
assertTrue("No change reported for /test/book.jpg/jcr:content", addedPropertyNames.contains("fooContent"));
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class AllPermissionsTest method testIsGranted.
@Test
public void testIsGranted() {
for (String path : paths) {
Tree tree = RootFactory.createReadOnlyRoot(root).getTree(path);
assertTrue(tree.exists());
assertTrue(all.isGranted(tree, null, Permissions.ALL));
for (PropertyState prop : tree.getProperties()) {
assertTrue(all.isGranted(tree, prop, Permissions.ALL));
}
for (Tree child : tree.getChildren()) {
assertTrue(all.isGranted(child, null, Permissions.ALL));
}
}
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class EmptyCugTreePermissionTest method testIsGrantedProperty.
@Test
public void testIsGrantedProperty() {
PropertyState ps = PropertyStates.createProperty("prop", "val");
assertFalse(tp.isGranted(Permissions.ALL, ps));
assertFalse(tp.isGranted(Permissions.WRITE, ps));
assertFalse(tp.isGranted(Permissions.READ, ps));
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class DocumentPropertyState method size.
@Override
public long size(int index) {
long size;
PropertyState parsed = parsed();
if (parsed.getType() == Type.BINARIES) {
size = parsed.getValue(Type.BINARY, index).length();
} else {
size = parsed.size(index);
}
return size;
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class DocumentNodeState method getMemory.
@Override
public int getMemory() {
long size = // shallow
40 + (lastRevision != null ? lastRevision.getMemory() : 0) + rootRevision.getMemory() + estimateMemoryUsage(path);
// rough approximation for properties
for (Map.Entry<String, PropertyState> entry : bundlingContext.getAllProperties().entrySet()) {
// name
size += estimateMemoryUsage(entry.getKey());
PropertyState propState = entry.getValue();
if (propState.getType() != Type.BINARY && propState.getType() != Type.BINARIES) {
for (int i = 0; i < propState.count(); i++) {
// size() returns length of string
// shallow memory:
// - 8 bytes per reference in values list
// - 48 bytes per string
// double useage per property because of parsed PropertyState
size += (56 + propState.size(i) * 2) * 2;
}
} else {
// calculate size based on blobId value
// referencing the binary in the blob store
// double the size because the parsed PropertyState
// will have a similarly sized blobId as well
size += (long) estimateMemoryUsage(getPropertyAsString(entry.getKey())) * 2;
}
}
if (size > Integer.MAX_VALUE) {
log.debug("Estimated memory footprint larger than Integer.MAX_VALUE: {}.", size);
size = Integer.MAX_VALUE;
}
return (int) size;
}
Aggregations