Interface VersionStore

  • All Known Implementing Classes:
    EventsVersionStore, ObservingVersionStore

    public interface VersionStore
    A storage interface that maintains multiple versions of the VALUE type with each commit having an associated CommitMeta value.
    • Method Detail

      • hashOnReference

        Hash hashOnReference​(NamedRef namedReference,
                             java.util.Optional<Hash> hashOnReference,
                             java.util.List<RelativeCommitSpec> relativeLookups)
                      throws ReferenceNotFoundException
        Verifies that the given namedReference exists and that hashOnReference, if present, is reachable via that reference.
        Returns:
        verified hashOnReference or, if hashOnReference is not present, the current HEAD of namedReference
        Throws:
        ReferenceNotFoundException - if namedReference does not exist or hashOnReference, if present, is not reachable from that reference
      • noAncestorHash

        @Nonnull
        @Nonnull
        Hash noAncestorHash()
        Retrieve the hash for "no ancestor" (or "beginning of time"), which is a hash for which no commit exists. "no ancestor" or "beginning of time" are the initial hash of the default branch and branches that are created via create(NamedRef, Optional) without specifying the targetHash.

        This "no ancestor" value is readable for all users, and it is a valid hash for every named reference.

        The result of this function must not change for any store instance, but it can be different for different backends and even for different instances of the same backend.

      • commit

        CommitResult<Commit> commit​(@Nonnull @Nonnull
                                    BranchName branch,
                                    @Nonnull @Nonnull
                                    java.util.Optional<Hash> referenceHash,
                                    @Nonnull @Nonnull
                                    org.projectnessie.model.CommitMeta metadata,
                                    @Nonnull @Nonnull
                                    java.util.List<Operation> operations,
                                    @Nonnull @Nonnull
                                    VersionStore.CommitValidator validator,
                                    @Nonnull @Nonnull
                                    java.util.function.BiConsumer<org.projectnessie.model.ContentKey,​java.lang.String> addedContents)
                             throws ReferenceNotFoundException,
                                    ReferenceConflictException
        Create a new commit and add to a branch.

        If referenceHash is not empty, for each key referenced by one of the operations, the current key's value is compared with the stored value for referenceHash's tree, and ReferenceConflictException is thrown if values are not matching.

        Parameters:
        branch - The branch to commit to.
        referenceHash - The hash to use as a reference for conflict detection. If not present, do not perform conflict detection
        metadata - The metadata associated with the commit.
        operations - The set of operations to apply.
        validator - Gets called during the atomic commit operations, callers can implement validation logic.
        addedContents - callback that receives the content-ID of _new_ content per content-key
        Throws:
        ReferenceConflictException - if referenceHash values do not match the stored values for branch
        ReferenceNotFoundException - if branch is not present in the store
        java.lang.NullPointerException - if one of the argument is null
      • getRepositoryConfig

        java.util.List<org.projectnessie.model.RepositoryConfig> getRepositoryConfig​(java.util.Set<org.projectnessie.model.RepositoryConfig.Type> repositoryConfigTypes)
      • merge

        MergeResult<Commit> merge​(VersionStore.MergeOp mergeOp)
                           throws ReferenceNotFoundException,
                                  ReferenceConflictException
        Merge items from an existing hash into the requested branch. The merge is always a rebase + fast-forward merge and is only completed if the rebase is conflict free. The set of commits added to the branch will be all of those until we arrive at a common ancestor. Depending on the underlying implementation, the number of commits allowed as part of this operation may be limited

        Throws if any of the following are true:

        • the hash or the branch do not exists
        • the rebase has conflicts
        • the expected branch hash does not match the actual branch hash
        Returns:
        merge result
        Throws:
        ReferenceConflictException - if expectedBranchHash doesn't match the stored hash for toBranch
        ReferenceNotFoundException - if toBranch or fromHash is not present in the store.
      • assign

        ReferenceAssignedResult assign​(NamedRef ref,
                                       Hash expectedHash,
                                       Hash targetHash)
                                throws ReferenceNotFoundException,
                                       ReferenceConflictException
        Assign the NamedRef to point to a particular hash.

        ref should already exists. If expectedHash is not empty, its value is compared with the current stored value for ref and an exception is thrown if values do not match.

        Parameters:
        ref - The named ref to be assigned
        expectedHash - The current head of the NamedRef to validate before updating (required).
        targetHash - The hash that this ref should refer to.
        Returns:
        A ReferenceAssignedResult containing the previous and current head of the reference
        Throws:
        ReferenceNotFoundException - if ref is not present in the store or if targetHash is not present in the store
        ReferenceConflictException - if expectedHash is not empty and its value doesn't match the stored hash for ref
      • getReferenceHistory

        ReferenceHistory getReferenceHistory​(java.lang.String refName,
                                             java.lang.Integer headCommitsToScan)
                                      throws ReferenceNotFoundException
        Retrieve the recorded recent history of a reference. A reference's history is a size and time limited record of changes of the reference's current pointer, aka HEAD. The size and time limits are configured in the Nessie server configuration.
        Returns:
        recorded reference history
        Throws:
        ReferenceNotFoundException
      • getCommits

        PaginationIterator<Commit> getCommits​(Ref ref,
                                              boolean fetchAdditionalInfo)
                                       throws ReferenceNotFoundException
        Get a stream of all ancestor commits to a provided ref.
        Parameters:
        ref - the stream to get commits for.
        fetchAdditionalInfo - include additional information like operations and parent hash
        Returns:
        A stream of commits.
        Throws:
        ReferenceNotFoundException - if ref is not present in the store
      • getValues

        java.util.Map<org.projectnessie.model.ContentKey,​ContentResult> getValues​(Ref ref,
                                                                                        java.util.Collection<org.projectnessie.model.ContentKey> keys)
                                                                                 throws ReferenceNotFoundException
        Get the values for a list of keys.
        Parameters:
        ref - The ref to use.
        keys - An ordered list of keys to retrieve within the provided ref.
        Returns:
        A parallel list of values.
        Throws:
        ReferenceNotFoundException - if ref is not present in the store