Interface VersionStore
-
- All Known Implementing Classes:
EventsVersionStore,MetricsVersionStore,TracingVersionStore
public interface VersionStoreA storage interface that maintains multiple versions of the VALUE type with each commit having an associated CommitMeta value.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceVersionStore.CommitValidatorstatic interfaceVersionStore.KeyRestrictionsstatic interfaceVersionStore.MergeOpstatic interfaceVersionStore.MergeTransplantOpBasestatic interfaceVersionStore.TransplantOp
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description ReferenceAssignedResultassign(NamedRef ref, java.util.Optional<Hash> expectedHash, Hash targetHash)Assign the NamedRef to point to a particular hash.default CommitResult<Commit>commit(BranchName branch, java.util.Optional<Hash> referenceHash, org.projectnessie.model.CommitMeta metadata, java.util.List<Operation> operations)CommitResult<Commit>commit(BranchName branch, java.util.Optional<Hash> referenceHash, org.projectnessie.model.CommitMeta metadata, java.util.List<Operation> operations, VersionStore.CommitValidator validator, java.util.function.BiConsumer<org.projectnessie.model.ContentKey,java.lang.String> addedContents)Create a new commit and add to a branch.ReferenceCreatedResultcreate(NamedRef ref, java.util.Optional<Hash> targetHash)Assign the NamedRef to point to a particular hash.ReferenceDeletedResultdelete(NamedRef ref, java.util.Optional<Hash> hash)Delete the provided NamedRefPaginationIterator<Commit>getCommits(Ref ref, boolean fetchAdditionalInfo)Get a stream of all ancestor commits to a provided ref.PaginationIterator<Diff>getDiffs(Ref from, Ref to, java.lang.String pagingToken, VersionStore.KeyRestrictions keyRestrictions)Get list of diffs between two refs.java.util.List<org.projectnessie.model.IdentifiedContentKey>getIdentifiedKeys(Ref ref, java.util.Collection<org.projectnessie.model.ContentKey> keys)PaginationIterator<KeyEntry>getKeys(Ref ref, java.lang.String pagingToken, boolean withContent, VersionStore.KeyRestrictions keyRestrictions)Get a stream of all available keys for the given ref.ReferenceInfo<org.projectnessie.model.CommitMeta>getNamedRef(java.lang.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, java.lang.String pagingToken)List named refs.java.util.stream.Stream<RefLogDetails>getRefLog(Hash refLogId)Deprecated.java.util.List<org.projectnessie.model.RepositoryConfig>getRepositoryConfig(java.util.Set<org.projectnessie.model.RepositoryConfig.Type> repositoryConfigTypes)RepositoryInformationgetRepositoryInformation()ContentResultgetValue(Ref ref, org.projectnessie.model.ContentKey key)Get the value for a provided ref.java.util.Map<org.projectnessie.model.ContentKey,ContentResult>getValues(Ref ref, java.util.Collection<org.projectnessie.model.ContentKey> keys)Get the values for a list of keys.HashhashOnReference(NamedRef namedReference, java.util.Optional<Hash> hashOnReference, java.util.List<RelativeCommitSpec> relativeLookups)Verifies that the givennamedReferenceexists and thathashOnReference, if present, is reachable via that reference.MergeResult<Commit>merge(VersionStore.MergeOp mergeOp)Merge items from an existing hash into the requested branch.HashnoAncestorHash()Retrieve the hash for "no ancestor" (or "beginning of time"), which is a hash for which no commit exists.MergeResult<Commit>transplant(VersionStore.TransplantOp transplantOp)Transplant a series of commits to a target branch.org.projectnessie.model.RepositoryConfigupdateRepositoryConfig(org.projectnessie.model.RepositoryConfig repositoryConfig)
-
-
-
Method Detail
-
getRepositoryInformation
@Nonnull @Nonnull RepositoryInformation getRepositoryInformation()
-
hashOnReference
Hash hashOnReference(NamedRef namedReference, java.util.Optional<Hash> hashOnReference, java.util.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
@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 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 @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
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 storejava.lang.NullPointerException- if one of the argument isnull
-
commit
default 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) throws ReferenceNotFoundException, ReferenceConflictException
-
getRepositoryConfig
java.util.List<org.projectnessie.model.RepositoryConfig> getRepositoryConfig(java.util.Set<org.projectnessie.model.RepositoryConfig.Type> repositoryConfigTypes)
-
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, java.util.Optional<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. If not present, force assignment.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, java.util.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, java.util.Optional<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- An optional hash. If provided, this operation will only succeed if the branch is pointing at the provided- 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(java.lang.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:
java.lang.NullPointerException- ifrefisnull.ReferenceNotFoundException- if the reference cannot be found
-
getNamedRefs
PaginationIterator<ReferenceInfo<org.projectnessie.model.CommitMeta>> getNamedRefs(GetNamedRefsParams params, java.lang.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, java.lang.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
java.util.List<org.projectnessie.model.IdentifiedContentKey> getIdentifiedKeys(Ref ref, java.util.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
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- ifrefis not present in the store
-
getDiffs
PaginationIterator<Diff> getDiffs(Ref from, Ref to, java.lang.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
-
getRefLog
@MustBeClosed @Deprecated java.util.stream.Stream<RefLogDetails> getRefLog(Hash refLogId) throws RefLogNotFoundException
Deprecated.Get a stream of all reflog entries from the initial refLogId.- Parameters:
refLogId- initial reflog id to be used- Returns:
- A stream of reflog entries.
- Throws:
RefLogNotFoundException
-
-