You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by th...@apache.org on 2014/07/31 08:55:36 UTC
svn commit: r1614817 -
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/
Author: thomasm
Date: Thu Jul 31 06:55:35 2014
New Revision: 1614817
URL: http://svn.apache.org/r1614817
Log:
OAK-1995 Improved SegmentNodeStore documentation
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MapRecord.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/PropertyTemplate.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/RecordId.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/RecordType.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Segment.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentId.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeBuilder.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeState.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentPropertyState.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStream.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentTracker.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Template.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MapRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MapRecord.java?rev=1614817&r1=1614816&r2=1614817&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MapRecord.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MapRecord.java Thu Jul 31 06:55:35 2014
@@ -63,12 +63,14 @@ class MapRecord extends Record {
/**
* Number of bits needed to indicate the current trie level.
+ * Currently 4.
*/
protected static final int LEVEL_BITS = // 4, using nextPowerOfTwo():
numberOfTrailingZeros(highestOneBit(MAX_NUMBER_OF_LEVELS) << 1);
/**
* Number of bits used to indicate the size of a map.
+ * Currently 28.
*/
protected static final int SIZE_BITS = 32 - LEVEL_BITS;
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/PropertyTemplate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/PropertyTemplate.java?rev=1614817&r1=1614816&r2=1614817&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/PropertyTemplate.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/PropertyTemplate.java Thu Jul 31 06:55:35 2014
@@ -25,6 +25,10 @@ import com.google.common.collect.Compari
class PropertyTemplate implements Comparable<PropertyTemplate> {
+ /**
+ * The index of this property within the list of properties in the node
+ * template.
+ */
private final int index;
private final String name;
@@ -39,7 +43,7 @@ class PropertyTemplate implements Compar
PropertyTemplate(PropertyState state) {
checkNotNull(state);
- this.index = 0; // TODO: is this used anywhere
+ this.index = 0;
this.name = state.getName();
this.type = state.getType();
}
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/RecordId.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/RecordId.java?rev=1614817&r1=1614816&r2=1614817&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/RecordId.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/RecordId.java Thu Jul 31 06:55:35 2014
@@ -25,6 +25,10 @@ import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+/**
+ * The record id. This includes the segment id and the offset within the
+ * segment.
+ */
public final class RecordId implements Comparable<RecordId> {
private static final Pattern PATTERN = Pattern.compile(
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/RecordType.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/RecordType.java?rev=1614817&r1=1614816&r2=1614817&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/RecordType.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/RecordType.java Thu Jul 31 06:55:35 2014
@@ -16,22 +16,109 @@
*/
package org.apache.jackrabbit.oak.plugins.segment;
+/**
+ * The type of a record in a segment.
+ */
enum RecordType {
+ /**
+ * A leaf of a map (which is a HAMT tree). This contains
+ * <ul>
+ * <li>the size (int)</li>
+ * <li>for each entry, the hash code of the key (4 bytes), then the record id of
+ * the key and the record id of the value</li>
+ * </ul>
+ */
LEAF,
+ /**
+ * A branch of a map (which is a HAMT tree). This contains
+ * <ul>
+ * <li>level within the HAMT structure (4 most significant bits), plus size
+ * of the that branch of the map</li>
+ * <li>bitmap (4 bytes)</li>
+ * <li>record ids of the buckets of the next level of the map</li>
+ * </ul>
+ * There is a special case: if the first int (level/size) is -1, then it's a
+ * diff record, to handle the common case of when exactly one existing child
+ * node was modified. This is common because whenever one node was changed,
+ * we need to propagate that up to the root.
+ * <ul>
+ * <li>-1 (int)</li>
+ * <li>hash code of the key that was changed (4 bytes)</li>
+ * <li>the record id of the key</li>
+ * <li>the record id of the value</li>
+ * <li>the record id of the (base version of the) modified map</li>
+ * </ul>
+ * There is only ever one single diff record for a map.
+ */
BRANCH,
+ /**
+ * A bucket (a list of references). It always includes at least 2 elements,
+ * up to 255 entries (because each entry could in theory point to a
+ * different segment, in which case this couldn't be stored in a segement).
+ * This contains just the record ids. The size of the list is not stored, as
+ * it is stored along with the reference to this record.
+ */
BUCKET,
+ /**
+ * A list including the size (an int). This could be 0, in which case there
+ * is no reference. If the size is 1, then reference points to the value of
+ * the list. If the size is larger, then a record id follows, which points
+ * to a bucket with the actual record ids. If there are more than 255
+ * entries in the list, then the list is partitioned into sublists of 255
+ * entries each, which are stored kind of recursively.
+ */
LIST,
+ /**
+ * A short value (for example a string, or a long). The format is: length
+ * (variable length encoding, one byte if shorter than 128, else more
+ * bytes), then the data as a byte array, or, for large values, a record id
+ * of the top level bucket that contains the list of block record ids of the
+ * actual binary data.
+ */
VALUE,
+ /**
+ * A block of bytes (a binary value, or a part of a binary value, or part of
+ * large strings). It only contains the raw data.
+ */
BLOCK,
+ /**
+ * A template (the "hidden class" of a node; inspired by the Chrome V8
+ * Javascript engine). This includes a list of property templates. Format:
+ * <ul>
+ * <li>head (int), which is: 1 bit (most significant one) whether the node
+ * has a single valued jcr:primaryType property. 1 bit whether it has
+ * mixins, in which case 10 bits (27 to 18) are used for the number of
+ * mixins. 1 bit whether the node has no child nodes. 1 bit whether the node
+ * has more than one child nodes. 18 bits (0 to 17) the number of properties
+ * (0 to 262143).</li>
+ * <li>The record ids of: if needed, record id of the primary type (a
+ * value), record ids of the mixin names (value records), for single child
+ * node: the name of the child node</li>
+ * <li>The list of record ids of property names (which are stored before the
+ * template in separate value records), and the property type (negative
+ * values for multi-value properties).</li>
+ * </ul>
+ */
TEMPLATE,
+ /**
+ * A JCR node, which contains a list of record ids:
+ * <ul>
+ * <li>the record id of the template</li>
+ * <li>depending on the template, the record id of the map of the ids of the
+ * child node name(s) and child node record id(s), or if there is just one
+ * child node, the child node record id</li>
+ * <li>the record ids of the property values (for multi-valued property a
+ * pointer to the list record)</li>
+ * </ul>
+ */
NODE
}
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Segment.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Segment.java?rev=1614817&r1=1614816&r2=1614817&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Segment.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Segment.java Thu Jul 31 06:55:35 2014
@@ -41,6 +41,12 @@ import org.apache.jackrabbit.oak.plugins
import com.google.common.base.Charsets;
+/**
+ * A list of records.
+ * <p>
+ * Record data is not kept in memory, but some entries are cached (templates,
+ * all strings in the segment).
+ */
public class Segment {
/**
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentId.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentId.java?rev=1614817&r1=1614816&r2=1614817&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentId.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentId.java Thu Jul 31 06:55:35 2014
@@ -44,6 +44,11 @@ public class SegmentId implements Compar
private final long lsb;
+ /**
+ * A reference to the segment object, if it is available in memory. It is
+ * used for fast lookup. The segment tracker will set or reset this field.
+ */
+ // TODO: possibly we could remove the volatile
private volatile Segment segment;
public SegmentId(SegmentTracker tracker, long msb, long lsb, Segment segment) {
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeBuilder.java?rev=1614817&r1=1614816&r2=1614817&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeBuilder.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeBuilder.java Thu Jul 31 06:55:35 2014
@@ -19,6 +19,12 @@ package org.apache.jackrabbit.oak.plugin
import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder;
import org.apache.jackrabbit.oak.spi.state.NodeState;
+/**
+ * A node builder that keeps track of the number of updates
+ * (set property calls and so on). If there are too many updates,
+ * getNodeState() is called, which will write the records to the segment,
+ * and that might persist the changes (if the segment is flushed).
+ */
public class SegmentNodeBuilder extends MemoryNodeBuilder {
/**
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeState.java?rev=1614817&r1=1614816&r2=1614817&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeState.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeState.java Thu Jul 31 06:55:35 2014
@@ -48,6 +48,10 @@ import static org.apache.jackrabbit.oak.
import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.MISSING_NODE;
import static org.apache.jackrabbit.oak.spi.state.AbstractNodeState.checkValidName;
+/**
+ * A node, which can read a node record from a segment.
+ * It currently doesn't cache data.
+ */
public class SegmentNodeState extends Record implements NodeState {
private volatile RecordId templateId = null;
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java?rev=1614817&r1=1614816&r2=1614817&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java Thu Jul 31 06:55:35 2014
@@ -52,6 +52,9 @@ import org.apache.jackrabbit.oak.spi.sta
import org.apache.jackrabbit.oak.spi.state.NodeState;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
+/**
+ * The top level class for the segment store.
+ */
public class SegmentNodeStore implements NodeStore, Observable {
static final String ROOT = "root";
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java?rev=1614817&r1=1614816&r2=1614817&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java Thu Jul 31 06:55:35 2014
@@ -57,6 +57,9 @@ import org.osgi.service.component.Compon
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * An OSGi wrapper for the segment node store.
+ */
@Component(policy = ConfigurationPolicy.REQUIRE)
public class SegmentNodeStoreService extends ProxyNodeStore
implements Observable {
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentPropertyState.java?rev=1614817&r1=1614816&r2=1614817&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentPropertyState.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentPropertyState.java Thu Jul 31 06:55:35 2014
@@ -49,6 +49,10 @@ import static org.apache.jackrabbit.oak.
import static org.apache.jackrabbit.oak.api.Type.URI;
import static org.apache.jackrabbit.oak.api.Type.WEAKREFERENCE;
+/**
+ * A property, which can read a value or list record from a segment.
+ * It currently doesn't cache data.
+ */
public class SegmentPropertyState extends Record implements PropertyState {
private final PropertyTemplate template;
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.java?rev=1614817&r1=1614816&r2=1614817&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.java Thu Jul 31 06:55:35 2014
@@ -22,6 +22,9 @@ import javax.annotation.Nonnull;
import org.apache.jackrabbit.oak.api.Blob;
import org.apache.jackrabbit.oak.spi.blob.BlobStore;
+/**
+ * The backend storage interface used by the segment node store.
+ */
public interface SegmentStore {
SegmentTracker getTracker();
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStream.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStream.java?rev=1614817&r1=1614816&r2=1614817&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStream.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStream.java Thu Jul 31 06:55:35 2014
@@ -31,6 +31,9 @@ import javax.annotation.CheckForNull;
import com.google.common.base.Charsets;
import com.google.common.io.ByteStreams;
+/**
+ * For reading any value records as binary streams.
+ */
public class SegmentStream extends InputStream {
@CheckForNull
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentTracker.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentTracker.java?rev=1614817&r1=1614816&r2=1614817&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentTracker.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentTracker.java Thu Jul 31 06:55:35 2014
@@ -36,6 +36,8 @@ import org.slf4j.LoggerFactory;
/**
* Tracker of references to segment identifiers and segment instances
* that are currently kept in memory.
+ * <p>
+ * It is also responsible to cache segment objects in memory.
*/
public class SegmentTracker {
@@ -133,6 +135,7 @@ public class SegmentTracker {
log.debug("Added segment {} to tracker cache ({} bytes)",
id, size);
+ // TODO possibly this cache could be improved
while (currentSize > cacheSize && segments.size() > 1) {
Segment last = segments.removeLast();
SegmentId lastId = last.getSegmentId();
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java?rev=1614817&r1=1614816&r2=1614817&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java Thu Jul 31 06:55:35 2014
@@ -72,6 +72,9 @@ import com.google.common.io.Closeables;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Converts records to byte arrays, in order to create segments.
+ */
public class SegmentWriter {
/** Logger instance */
@@ -163,6 +166,11 @@ public class SegmentWriter {
}
}
+ /**
+ * Adds a segment header to the buffer and writes a segment to the segment
+ * store. This is done automatically (called from prepare) when there is not
+ * enough space for a record. It can also be called explicitly.
+ */
public synchronized void flush() {
if (length > 0) {
int refcount = segment.getRefCount();
@@ -237,6 +245,23 @@ public class SegmentWriter {
return prepare(type, size, Collections.<RecordId>emptyList());
}
+ /**
+ * Before writing a record (which are written backwards, from the end of the
+ * file to the beginning), this method is called, to ensure there is enough
+ * space. A new segment is also created if there is not enough space in the
+ * segment lookup table or elsewhere.
+ * <p>
+ * This method does not actually write into the segment, just allocates the
+ * space (flushing the segment if needed and starting a new one), and sets
+ * the write position (records are written from the end to the beginning,
+ * but within a record from left to right).
+ *
+ * @param type the record type (only used for root records)
+ * @param size the size of the record, excluding the size used for the
+ * record ids
+ * @param ids the record ids
+ * @return a new record id
+ */
private RecordId prepare(
RecordType type, int size, Collection<RecordId> ids) {
checkArgument(size >= 0);
@@ -312,6 +337,12 @@ public class SegmentWriter {
return refcount;
}
+ /**
+ * Write a record id, and marks the record id as referenced (removes it from
+ * the unreferenced set).
+ *
+ * @param recordId the record id
+ */
private synchronized void writeRecordId(RecordId recordId) {
checkNotNull(recordId);
roots.remove(recordId);
@@ -905,6 +936,8 @@ public class SegmentWriter {
RecordId[] propertyNames = new RecordId[properties.length];
byte[] propertyTypes = new byte[properties.length];
for (int i = 0; i < properties.length; i++) {
+ // Note: if the property names are stored in more than 255 separate
+ // segments, this will not work.
propertyNames[i] = writeString(properties[i].getName());
Type<?> type = properties[i].getType();
if (type.isArray()) {
@@ -940,6 +973,14 @@ public class SegmentWriter {
return id;
}
+ /**
+ * If the given node was compacted, return the compacted node, otherwise
+ * return the passed node. This is to avoid pointing to old nodes, if they
+ * have been compacted.
+ *
+ * @param state the node
+ * @return the compacted node (if it was compacted)
+ */
private SegmentNodeState uncompact(SegmentNodeState state) {
RecordId id = tracker.getCompactionMap().get(state.getRecordId());
if (id != null) {
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Template.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Template.java?rev=1614817&r1=1614816&r2=1614817&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Template.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Template.java Thu Jul 31 06:55:35 2014
@@ -39,6 +39,12 @@ import org.apache.jackrabbit.oak.plugins
import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
import org.apache.jackrabbit.oak.spi.state.NodeState;
+/**
+ * The in-memory representation of a "hidden class" of a node; inspired by the
+ * Chrome V8 Javascript engine).
+ * <p>
+ * Templates are always read fully in-memory.
+ */
public class Template {
static final String ZERO_CHILD_NODES = null;