public interface

CommitIndex

com.atlassian.bitbucket.idx.CommitIndex

Class Overview

Index to store meta data against commits. This interface serves to decouple commit indexing from storing metadata in an index.

Summary

Public Methods
void addCommit(Commit commit, Repository repository)
Associates the provided Commit with the specified Repository.
void addProperty(String commitId, String key, String value)
Stores a string commit property.
@Nonnull Page<IndexedCommit> findByProperty(String propertyKey, String propertyValue, boolean caseSensitive, PageRequest pageRequest)
Retrieves all indexed commits that have a given property with a specified value.
@Nullable IndexedCommit getCommit(String commitId)
Retrieves the specified commit if it's been indexed.
@Nonnull PropertyMap getProperties(String commitId, Iterable<String> propertyKeys)
Retrieves a property map containing all properties stored against the given commit, matching propertyKeys.
@Nonnull Map<StringPropertyMap> getProperties(Iterable<String> commitIds, Iterable<String> propertyKeys)
Retrieves a properties for each of the specified commits, matching the provided propertyKeys.
boolean isIndexed(String commitId, Repository repository)
void removeCommit(String commitId, Repository repository)
Removes the association between the specified commit and repository in the index.
void removeProperty(String commitId, String key, String value)
Removes a commit property.
@Nonnull Page<IndexedCommit> search(IndexSearchRequest searchRequest, PageRequest pageRequest)
Searches the index for any matching commits.
@Nonnull Page<MinimalRepositoryCommit> searchRepositoryCommits(IndexSearchRequest indexSearchRequest, PageRequest pageRequest)
Search the index for any commits matching the provided search request.

Public Methods

public void addCommit (Commit commit, Repository repository)

Associates the provided Commit with the specified Repository.

Parameters
commit the commit
repository the repository

public void addProperty (String commitId, String key, String value)

Stores a string commit property. If the property (name-value pair) already exists, calling this method will have no effect.

Parameters
commitId the commit ID
key the property key
value the property value

@Nonnull public Page<IndexedCommit> findByProperty (String propertyKey, String propertyValue, boolean caseSensitive, PageRequest pageRequest)

Retrieves all indexed commits that have a given property with a specified value.

Parameters
propertyKey the property key
propertyValue the property value
caseSensitive whether matches against value should be case-sensitive
pageRequest the page request
Returns
  • a page of IndexedCommit commits that have the provided property. The results in the page are ordered by authorTimestamp descending

@Nullable public IndexedCommit getCommit (String commitId)

Retrieves the specified commit if it's been indexed.

Parameters
commitId the commit ID
Returns
  • the IndexedCommit, or null if the specified commit has not been indexed

@Nonnull public PropertyMap getProperties (String commitId, Iterable<String> propertyKeys)

Retrieves a property map containing all properties stored against the given commit, matching propertyKeys. The value of all the properties is of type Set<String>.

Parameters
commitId the commit id
propertyKeys the property keys to retrieve
Returns
  • properties for commit with commitId, matching propertyKeys. Can be empty, but not null.

@Nonnull public Map<StringPropertyMap> getProperties (Iterable<String> commitIds, Iterable<String> propertyKeys)

Retrieves a properties for each of the specified commits, matching the provided propertyKeys. The value of all the properties is of type Set<String>.

Parameters
commitIds commit IDs
propertyKeys the property keys to retrieve for each commit
Returns
  • properties for each commit in commitIds, matching propertyKeys, mapped by commit IDs. Can be empty, but not null.

public boolean isIndexed (String commitId, Repository repository)

Parameters
commitId the commit ID
repository the repository
Returns
  • true if the provided commit was indexed in the specified repository

public void removeCommit (String commitId, Repository repository)

Removes the association between the specified commit and repository in the index. If the specified repository was the only association for the commit, it will be fully removed from the index. Otherwise, the commit may still appear in the index if it is available in other repositories.

Parameters
commitId the ID of the commit to remove from the index
repository the repository to remove the commit's association for

public void removeProperty (String commitId, String key, String value)

Removes a commit property.

Parameters
commitId the commit ID
key the property key
value the property value

@Nonnull public Page<IndexedCommit> search (IndexSearchRequest searchRequest, PageRequest pageRequest)

Searches the index for any matching commits.

Parameters
searchRequest the criteria to match
pageRequest a pageRequest to delimit the search
Returns
  • a page of IndexedCommits, possibly empty if no indexed commits match

@Nonnull public Page<MinimalRepositoryCommit> searchRepositoryCommits (IndexSearchRequest indexSearchRequest, PageRequest pageRequest)

Search the index for any commits matching the provided search request. Only commits in repositories that the current user has access to will be returned. The provided filter should be at least 7 characters long.

Parameters
indexSearchRequest the search request
pageRequest the page request
Returns
  • a page of commits that match the criteria and that are in repositories the current user has access to
Throws
IllegalArgumentException if criteria.getFilter() is less than 7 characters