Class NodeDocument

java.lang.Object
org.apache.jackrabbit.oak.plugins.document.Document
org.apache.jackrabbit.oak.plugins.document.NodeDocument
All Implemented Interfaces:
CacheValue

public final class NodeDocument extends Document
A document storing data about a node.
  • Field Details

    • NULL

      public static final NodeDocument NULL
      Marker document, which indicates the document does not exist.
    • MIN_ID_VALUE

      public static final String MIN_ID_VALUE
      All NodeDocument ID value would be greater than this value It can be used as startKey in DocumentStore#query methods
      See Also:
    • MAX_ID_VALUE

      public static final String MAX_ID_VALUE
      All NodeDocument ID value would be less than this value It can be used as endKey in DocumentStore#query methods
      See Also:
    • COLLISIONS

      public static final String COLLISIONS
      Revision collision markers set by commits with modifications, which overlap with un-merged branch commits. Key: revision, value: always true
      See Also:
    • MODIFIED_IN_SECS

      public static final String MODIFIED_IN_SECS
      The modified time in seconds (5 second resolution).
      See Also:
    • DELETED_ONCE

      public static final String DELETED_ONCE
      Flag indicating that whether this node was ever deleted. Its just used as a hint. If set to true then it indicates that node was once deleted.

      Note that a true value does not mean that node should be considered deleted as it might have been resurrected in later revision. Further note that it might get reset by maintenance tasks once they discover that it indeed was resurrected.

      See Also:
    • PATH

      public static final String PATH
      The node path, in case the id can not be converted to a path.
      See Also:
    • HAS_BINARY_FLAG

      public static final String HAS_BINARY_FLAG
      See Also:
    • SD_TYPE

      public static final String SD_TYPE
      Defines the type of split document. Its value is an integer whose value is defined as per
      See Also:
    • SD_MAX_REV_TIME_IN_SECS

      public static final String SD_MAX_REV_TIME_IN_SECS
      Property name which refers to timestamp (long) of the latest revision kept in the document
      See Also:
    • HAS_BINARY_VAL

      public static final long HAS_BINARY_VAL
      See Also:
  • Constructor Details

    • NodeDocument

      public NodeDocument(@NotNull @NotNull DocumentStore store, long creationTime)
      Required for serialization
      Parameters:
      store - the document store.
      creationTime - time at which it was created. Would be different from current time in case of being resurrected from a serialized for
  • Method Details

    • getModifiedInSecs

      public static long getModifiedInSecs(long timestamp)
      Return time in seconds with 5 second resolution
      Parameters:
      timestamp - time in millis to convert
      Returns:
      the time in seconds with the given resolution.
    • getValueMap

      @NotNull public @NotNull Map<Revision,String> getValueMap(@NotNull @NotNull String key)
      Gets the value map for the given key. This method is similar to Document.get(String) but will always return a value map. The returned value map may span multiple documents if the values of the given key were split off to PREVIOUS documents.
      Parameters:
      key - a string key.
      Returns:
      the map associated with the key.
    • getCreated

      public long getCreated()
      Returns:
      the system time this object was created.
    • getModified

      @Nullable public @Nullable Long getModified()
      Returns:
      the time in seconds this document was last modified with five seconds precision. Returns null if none is set.
    • hasChildren

      public boolean hasChildren()
      Returns true if this node possibly has children. If false then that indicates that there are no child
      Returns:
      true if this node has children
    • wasDeletedOnce

      public boolean wasDeletedOnce()
      Returns true if this document was ever deleted in past.
    • hasBeenModifiedSince

      public boolean hasBeenModifiedSince(long lastModifiedTime)
      Checks if this document has been modified after the given lastModifiedTime
      Parameters:
      lastModifiedTime - time to compare against in millis
      Returns:
      true if this document was modified after the given lastModifiedTime
    • hasAllRevisionLessThan

      public boolean hasAllRevisionLessThan(long maxRevisionTime)
      Checks if revision time of all entries in this document is less than the passed time
      Parameters:
      maxRevisionTime - timemstamp (in millis) of revision to check
      Returns:
      true if timestamp of maximum revision stored in this document is less than than the passed revision timestamp
    • isSplitDocument

      public boolean isSplitDocument()
      Determines if this document is a split document
      Returns:
      true if this document is a split document
    • getSplitDocType

      public NodeDocument.SplitDocType getSplitDocType()
      Determines the type of split document
      Returns:
      type of Split Document
    • markUpToDate

      public void markUpToDate(long checkTime)
      Mark this instance as up-to-date (matches the state in persistence store).
      Parameters:
      checkTime - time at which the check was performed
    • getLastCheckTime

      public long getLastCheckTime()
      Returns the last time when this object was checked for consistency.
      Returns:
      the last check time
    • hasBinary

      public boolean hasBinary()
    • getMainPath

      @NotNull public @NotNull Path getMainPath()
      Returns the path of the main document if this document is part of a _prev history tree. Otherwise this method simply returns getPath().
      Returns:
      the path of the main document.
    • getLastRev

      @NotNull public @NotNull Map<Integer,Revision> getLastRev()
      Returns:
      a map of the last known revision for each clusterId.
    • containsRevision

      public boolean containsRevision(@NotNull @NotNull Revision revision)
      Returns true if this document contains an entry for the given revision in the REVISIONS map. Please note that an entry in the REVISIONS map does not necessarily mean the the revision is committed. Use RevisionContext.getCommitValue(Revision, NodeDocument) to get the commit state of a revision.
      Parameters:
      revision - the revision to check.
      Returns:
      true if this document contains the given revision.
    • getCommitRootPath

      @Nullable public @Nullable Path getCommitRootPath(Revision revision)
      Returns the commit root path for the given revision or null if this document does not have a commit root entry for the given revision.
      Parameters:
      revision - a revision.
      Returns:
      the commit root path or null.
    • getNodeAtRevision

      @Nullable public @Nullable DocumentNodeState getNodeAtRevision(@NotNull @NotNull DocumentNodeStore nodeStore, @NotNull @NotNull RevisionVector readRevision, @Nullable @Nullable Revision lastModified)
      Returns a DocumentNodeState as seen at the given readRevision.
      Parameters:
      nodeStore - the node store.
      readRevision - the read revision.
      lastModified - the revision when this node was last modified, but the value is potentially not yet reflected in this document. See RevisionContext.getPendingModifications().
      Returns:
      the node or null if the node doesn't exist at the given read revision.
    • getLiveRevision

      @Nullable public @Nullable Revision getLiveRevision(RevisionContext context, RevisionVector readRevision, Map<Revision,String> validRevisions, org.apache.jackrabbit.oak.plugins.document.LastRevs lastRevs)
      Get the earliest (oldest) revision where the node was alive at or before the provided revision, if the node was alive at the given revision.
      Parameters:
      context - the revision context
      readRevision - the read revision
      validRevisions - the map of revisions to commit value already checked against readRevision and considered valid.
      lastRevs - to keep track of the last modification.
      Returns:
      the earliest revision, or null if the node is deleted at the given revision
    • split

      @NotNull public @NotNull Iterable<UpdateOp> split(@NotNull @NotNull RevisionContext context, @NotNull @NotNull RevisionVector head, @NotNull @NotNull Function<String,Long> binarySize)
      Returns update operations to split this document. The implementation may decide to not return any operations if no splitting is required. A caller must explicitly pass a head revision even though it is available through the RevisionContext. The given head revision must reflect a head state before doc was retrieved from the document store. This is important in order to maintain consistency. See OAK-3081 for details.
      Parameters:
      context - the revision context.
      head - the head revision before this document was retrieved from the document store.
      binarySize - a function that returns the binary size of the given JSON property value String.
      Returns:
      the split operations, whereby the last updateOp is guaranteed to be the update of the main document (unless the entire list is empty)
    • getLocalBranchCommits

      @NotNull public @NotNull Set<Revision> getLocalBranchCommits()
      Returns the branch commit entries on this document (BRANCH_COMMITS). This method does not consider previous documents, but only returns the entries on this document.
    • setChildrenFlag

      public static void setChildrenFlag(@NotNull @NotNull UpdateOp op, boolean hasChildNode)
    • setModified

      public static void setModified(@NotNull @NotNull UpdateOp op, @NotNull @NotNull Revision revision)
    • setRevision

      public static void setRevision(@NotNull @NotNull UpdateOp op, @NotNull @NotNull Revision revision, @NotNull @NotNull String commitValue)
    • unsetRevision

      public static void unsetRevision(@NotNull @NotNull UpdateOp op, @NotNull @NotNull Revision revision)
    • isRevisionsEntry

      public static boolean isRevisionsEntry(String name)
    • isCommitRootEntry

      public static boolean isCommitRootEntry(String name)
    • isDeletedEntry

      public static boolean isDeletedEntry(String name)
    • isLastRevEntry

      public static boolean isLastRevEntry(String name)
    • removeRevision

      public static void removeRevision(@NotNull @NotNull UpdateOp op, @NotNull @NotNull Revision revision)
    • addCollision

      public static void addCollision(@NotNull @NotNull UpdateOp op, @NotNull @NotNull Revision revision, @NotNull @NotNull Revision other)
      Add a collision marker for the given revision.
      Parameters:
      op - the update operation.
      revision - the commit for which a collision was detected.
      other - the revision for the commit, which detected the collision.
    • removeCollision

      public static void removeCollision(@NotNull @NotNull UpdateOp op, @NotNull @NotNull Revision revision)
    • setLastRev

      public static void setLastRev(@NotNull @NotNull UpdateOp op, @NotNull @NotNull Revision revision)
    • setCommitRoot

      public static void setCommitRoot(@NotNull @NotNull UpdateOp op, @NotNull @NotNull Revision revision, int commitRootDepth)
    • removeCommitRoot

      public static void removeCommitRoot(@NotNull @NotNull UpdateOp op, @NotNull @NotNull Revision revision)
    • unsetCommitRoot

      public static void unsetCommitRoot(@NotNull @NotNull UpdateOp op, @NotNull @NotNull Revision revision)
    • setDeleted

      public static void setDeleted(@NotNull @NotNull UpdateOp op, @NotNull @NotNull Revision revision, boolean deleted)
    • setDeletedOnce

      public static void setDeletedOnce(@NotNull @NotNull UpdateOp op)
    • removeDeleted

      public static void removeDeleted(@NotNull @NotNull UpdateOp op, @NotNull @NotNull Revision revision)
    • setPrevious

      public static void setPrevious(@NotNull @NotNull UpdateOp op, @NotNull @NotNull org.apache.jackrabbit.oak.plugins.document.Range range)
    • removePrevious

      public static void removePrevious(@NotNull @NotNull UpdateOp op, @NotNull @NotNull org.apache.jackrabbit.oak.plugins.document.Range range)
    • removePrevious

      public static void removePrevious(@NotNull @NotNull UpdateOp op, @NotNull @NotNull Revision revision)
    • setStalePrevious

      public static void setStalePrevious(@NotNull @NotNull UpdateOp op, @NotNull @NotNull Revision revision, int height)
    • removeStalePrevious

      public static void removeStalePrevious(@NotNull @NotNull UpdateOp op, @NotNull @NotNull Revision revision)
    • setHasBinary

      public static void setHasBinary(@NotNull @NotNull UpdateOp op)
    • setBranchCommit

      public static void setBranchCommit(@NotNull @NotNull UpdateOp op, @NotNull @NotNull Revision revision)
    • removeBranchCommit

      public static void removeBranchCommit(@NotNull @NotNull UpdateOp op, @NotNull @NotNull Revision revision)
    • setSweepRevision

      public static void setSweepRevision(@NotNull @NotNull UpdateOp op, @NotNull @NotNull Revision revision)
    • hasLastRev

      public static void hasLastRev(@NotNull @NotNull UpdateOp op, @NotNull @NotNull Revision revision)
    • getPath

      @NotNull public @NotNull Path getPath()
    • asString

      public String asString()
    • fromString

      public static NodeDocument fromString(DocumentStore store, String s)