diff --git a/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Compactor.java b/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Compactor.java index 53b2a045c70..a5cefa845c8 100644 --- a/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Compactor.java +++ b/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Compactor.java @@ -56,6 +56,15 @@ public class Compactor { /** Logger instance */ private static final Logger log = LoggerFactory.getLogger(Compactor.class); + private static boolean eagerFlush = Boolean + .getBoolean("oak.compaction.eagerFlush"); + + static { + if (eagerFlush) { + log.debug("Eager flush enabled."); + } + } + /** * Locks down the RecordId persistence structure */ @@ -245,7 +254,12 @@ public boolean childNodeAdded(String name, NodeState after) { progress.onNode(); try { - NodeBuilder child = EMPTY_NODE.builder(); + NodeBuilder child; + if (eagerFlush) { + child = builder.setChildNode(name); + } else { + child = EMPTY_NODE.builder(); + } boolean success = new CompactDiff(child, path, name).diff(EMPTY_NODE, after); if (success) { SegmentNodeState state = writer.writeNode(child.getNodeState());