use of org.apache.jackrabbit.core.persistence.util.NodePropBundle.ChildNodeEntry in project jackrabbit by apache.
the class BundleWriter method writeBundle.
/**
* Serializes a <code>NodePropBundle</code> to a data output stream
*
* @param bundle the bundle to serialize
* @throws IOException if an I/O error occurs.
*/
public void writeBundle(NodePropBundle bundle) throws IOException {
long size = out.size();
// primaryType
writeName(bundle.getNodeTypeName());
// parentUUID
NodeId parentId = bundle.getParentId();
if (parentId == null) {
parentId = BundleBinding.NULL_PARENT_ID;
}
writeNodeId(parentId);
// write mod count
writeVarInt(bundle.getModCount());
Collection<Name> mixins = bundle.getMixinTypeNames();
Collection<PropertyEntry> properties = bundle.getPropertyEntries();
Collection<ChildNodeEntry> nodes = bundle.getChildNodeEntries();
Collection<NodeId> shared = bundle.getSharedSet();
int mn = mixins.size();
int pn = properties.size();
int nn = nodes.size();
int sn = shared.size();
int referenceable = 0;
if (bundle.isReferenceable()) {
referenceable = 1;
}
out.writeByte(Math.min(mn, 1) << 7 | Math.min(pn, 7) << 4 | Math.min(nn, 3) << 2 | Math.min(sn, 1) << 1 | referenceable);
// mixin types
writeVarInt(mn, 1);
for (Name name : mixins) {
writeName(name);
}
// properties
writeVarInt(pn, 7);
for (PropertyEntry property : properties) {
writeState(property);
}
// child nodes (list of name/uuid pairs)
writeVarInt(nn, 3);
for (ChildNodeEntry child : nodes) {
// name
writeName(child.getName());
// uuid
writeNodeId(child.getId());
}
// write shared set
writeVarInt(sn, 1);
for (NodeId nodeId : shared) {
writeNodeId(nodeId);
}
// set size of bundle
bundle.setSize(out.size() - size);
}
use of org.apache.jackrabbit.core.persistence.util.NodePropBundle.ChildNodeEntry in project jackrabbit-oak by apache.
the class JackrabbitNodeState method createNodes.
private Map<String, NodeId> createNodes(NodePropBundle bundle) {
Map<String, NodeId> children = newLinkedHashMap();
for (ChildNodeEntry entry : bundle.getChildNodeEntries()) {
String base = createName(entry.getName());
String name = base;
for (int i = 2; children.containsKey(name); i++) {
name = base + '[' + i + ']';
}
if (!ignoredPaths.contains(PathUtils.concat(getPath(), name))) {
children.put(name, entry.getId());
}
}
return children;
}
Aggregations