Interface VersionStore
- All Known Implementing Classes:
EventsVersionStore,ObservingVersionStore
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic interfacestatic interfacestatic interfacestatic interface -
Method Summary
Modifier and TypeMethodDescriptionAssign the NamedRef to point to a particular hash.default CommitResult<Commit>commit(BranchName branch, Optional<Hash> referenceHash, org.projectnessie.model.CommitMeta metadata, List<Operation> operations) commit(BranchName branch, Optional<Hash> referenceHash, org.projectnessie.model.CommitMeta metadata, List<Operation> operations, VersionStore.CommitValidator validator, BiConsumer<org.projectnessie.model.ContentKey, String> addedContents) Create a new commit and add to a branch.Assign the NamedRef to point to a particular hash.Delete the provided NamedRefgetCommits(Ref ref, boolean fetchAdditionalInfo) Get a stream of all ancestor commits to a provided ref.getDiffs(Ref from, Ref to, String pagingToken, VersionStore.KeyRestrictions keyRestrictions) Get list of diffs between two refs.List<org.projectnessie.model.IdentifiedContentKey>getIdentifiedKeys(Ref ref, Collection<org.projectnessie.model.ContentKey> keys) getKeys(Ref ref, String pagingToken, boolean withContent, VersionStore.KeyRestrictions keyRestrictions) Get a stream of all available keys for the given ref.ReferenceInfo<org.projectnessie.model.CommitMeta>getNamedRef(String ref, GetNamedRefsParams params) Resolve the givenNamedRefand return information about it, which at least contains the current HEAD commit hash plus, optionally, additional information.PaginationIterator<ReferenceInfo<org.projectnessie.model.CommitMeta>>getNamedRefs(GetNamedRefsParams params, String pagingToken) List named refs.getReferenceHistory(String refName, Integer headCommitsToScan) Retrieve the recorded recent history of a reference.List<org.projectnessie.model.RepositoryConfig>getRepositoryConfig(Set<org.projectnessie.model.RepositoryConfig.Type> repositoryConfigTypes) Get the value for a provided ref.Map<org.projectnessie.model.ContentKey,ContentResult> getValues(Ref ref, Collection<org.projectnessie.model.ContentKey> keys) Get the values for a list of keys.hashOnReference(NamedRef namedReference, Optional<Hash> hashOnReference, List<RelativeCommitSpec> relativeLookups) Verifies that the givennamedReferenceexists and thathashOnReference, if present, is reachable via that reference.merge(VersionStore.MergeOp mergeOp) Merge items from an existing hash into the requested branch.Retrieve the hash for "no ancestor" (or "beginning of time"), which is a hash for which no commit exists.transplant(VersionStore.TransplantOp transplantOp) Transplant a series of commits to a target branch.org.projectnessie.model.RepositoryConfigupdateRepositoryConfig(org.projectnessie.model.RepositoryConfig repositoryConfig)
-
Method Details
-
getRepositoryInformation
-
hashOnReference
Hash hashOnReference(NamedRef namedReference, Optional<Hash> hashOnReference, List<RelativeCommitSpec> relativeLookups) throws ReferenceNotFoundException Verifies that the givennamedReferenceexists and thathashOnReference, if present, is reachable via that reference.- Returns:
- verified
hashOnReferenceor, ifhashOnReferenceis not present, the current HEAD ofnamedReference - Throws:
ReferenceNotFoundException- ifnamedReferencedoes not exist orhashOnReference, if present, is not reachable from that reference
-
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 viacreate(NamedRef, Optional)without specifying thetargetHash.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 BranchName branch, @Nonnull Optional<Hash> referenceHash, @Nonnull org.projectnessie.model.CommitMeta metadata, @Nonnull List<Operation> operations, @Nonnull VersionStore.CommitValidator validator, @Nonnull BiConsumer<org.projectnessie.model.ContentKey, String> addedContents) throws ReferenceNotFoundException, ReferenceConflictExceptionCreate a new commit and add to a branch.If
referenceHashis 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, andReferenceConflictExceptionis 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 detectionmetadata- 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- ifreferenceHashvalues do not match the stored values forbranchReferenceNotFoundException- ifbranchis not present in the storeNullPointerException- if one of the argument isnull
-
commit
default CommitResult<Commit> commit(@Nonnull BranchName branch, @Nonnull Optional<Hash> referenceHash, @Nonnull org.projectnessie.model.CommitMeta metadata, @Nonnull List<Operation> operations) throws ReferenceNotFoundException, ReferenceConflictException -
getRepositoryConfig
-
updateRepositoryConfig
org.projectnessie.model.RepositoryConfig updateRepositoryConfig(org.projectnessie.model.RepositoryConfig repositoryConfig) throws ReferenceConflictException - Throws:
ReferenceConflictException
-
transplant
MergeResult<Commit> transplant(VersionStore.TransplantOp transplantOp) throws ReferenceNotFoundException, ReferenceConflictException Transplant a series of commits to a target branch.This is done as an atomic operation such that only the last of the sequence is ever visible to concurrent readers/writers. The sequence to transplant must be contiguous, in order and share a common ancestor with the target branch.
- Returns:
- merge result
- Throws:
ReferenceConflictException- ifreferenceHashvalues do not match the stored values forbranchReferenceNotFoundException- ifbranchor if any of the hashes fromsequenceToTransplantis not present in the store.
-
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 limitedThrows 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- ifexpectedBranchHashdoesn't match the stored hash fortoBranchReferenceNotFoundException- iftoBranchorfromHashis 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.refshould already exists. IfexpectedHashis not empty, its value is compared with the current stored value forrefand an exception is thrown if values do not match.- Parameters:
ref- The named ref to be assignedexpectedHash- The current head of the NamedRef to validate before updating (required).targetHash- The hash that this ref should refer to.- Returns:
- A
ReferenceAssignedResultcontaining the previous and current head of the reference - Throws:
ReferenceNotFoundException- ifrefis not present in the store or iftargetHashis not present in the storeReferenceConflictException- ifexpectedHashis not empty and its value doesn't match the stored hash forref
-
create
ReferenceCreatedResult create(NamedRef ref, Optional<Hash> targetHash) throws ReferenceNotFoundException, ReferenceAlreadyExistsException Assign the NamedRef to point to a particular hash. If the NamedRef does not exist, it will be created.- Parameters:
ref- The named ref we're assigningtargetHash- The hash that this ref should refer to (optional). Otherwise will reference the beginning of time.- Returns:
- A
ReferenceCreatedResultcontaining the head of the created reference - Throws:
ReferenceNotFoundException- iftargetHashis not empty and not present in the storeReferenceAlreadyExistsException- ifrefalready exists
-
delete
ReferenceDeletedResult delete(NamedRef ref, Hash hash) throws ReferenceNotFoundException, ReferenceConflictException Delete the provided NamedRefThrows exception if the optional hash does not match the provided ref.
- Parameters:
ref- The NamedRef to be deleted.hash- The expected hash (required). The operation will only succeed if the branch is pointing at the provided hash.- Returns:
- A
ReferenceDeletedResultcontaining the head of the deleted reference - Throws:
ReferenceNotFoundException- ifrefis not present in the storeReferenceConflictException- ifhashdoesn't match the stored hash forref
-
getNamedRef
ReferenceInfo<org.projectnessie.model.CommitMeta> getNamedRef(String ref, GetNamedRefsParams params) throws ReferenceNotFoundException Resolve the givenNamedRefand return information about it, which at least contains the current HEAD commit hash plus, optionally, additional information.This is a functionally equivalent to
hashOnReference(ref, Optional.empty(), Collections.emptyList()).- Parameters:
ref- The branch or tag to lookup.params- options that control which information shall be returned inReferenceInfo, seeGetNamedRefsParamsfor details.- Returns:
- Requested information about the requested reference.
- Throws:
NullPointerException- ifrefisnull.ReferenceNotFoundException- if the reference cannot be found
-
getReferenceHistory
ReferenceHistory getReferenceHistory(String refName, 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
-
getNamedRefs
PaginationIterator<ReferenceInfo<org.projectnessie.model.CommitMeta>> getNamedRefs(GetNamedRefsParams params, String pagingToken) throws ReferenceNotFoundException List named refs.IMPORTANT NOTE: The returned
Streammust be closed!- Parameters:
params- options that control which information shall be returned in eachReferenceInfo, seeReferenceInfofor details.pagingToken- paging token to start at- Returns:
- All refs and their associated hashes.
- 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- ifrefis not present in the store
-
getKeys
PaginationIterator<KeyEntry> getKeys(Ref ref, String pagingToken, boolean withContent, VersionStore.KeyRestrictions keyRestrictions) throws ReferenceNotFoundException Get a stream of all available keys for the given ref.- Parameters:
ref- The ref to get keys for.pagingToken- paging token to start atwithContent- whether to populateKeyEntry.getContent()- Returns:
- The stream of keys available for this ref.
- Throws:
ReferenceNotFoundException- ifrefis not present in the store
-
getIdentifiedKeys
List<org.projectnessie.model.IdentifiedContentKey> getIdentifiedKeys(Ref ref, Collection<org.projectnessie.model.ContentKey> keys) throws ReferenceNotFoundException - Throws:
ReferenceNotFoundException
-
getValue
ContentResult getValue(Ref ref, org.projectnessie.model.ContentKey key) throws ReferenceNotFoundException Get the value for a provided ref.- Parameters:
ref- Any ref type allowedkey- The key for the specific value- Returns:
- The value.
- Throws:
ReferenceNotFoundException- ifrefis not present in the store
-
getValues
Map<org.projectnessie.model.ContentKey,ContentResult> getValues(Ref ref, 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- ifrefis not present in the store
-
getDiffs
PaginationIterator<Diff> getDiffs(Ref from, Ref to, String pagingToken, VersionStore.KeyRestrictions keyRestrictions) throws ReferenceNotFoundException Get list of diffs between two refs.- Parameters:
from- The from part of the diff.to- The to part of the diff.pagingToken- paging token to start at- Returns:
- A stream of values that are different.
- Throws:
ReferenceNotFoundException
-