-
public interface CommitGraphThe CommitGraph is a supplemental data structure that accelerates commit graph walks.If a user downgrades or disables the
core.commitGraphconfig setting, then the existing object database is sufficient.It stores the commit graph structure along with some extra metadata to speed up graph walks. By listing commit OIDs in lexicographic order, we can identify an integer position for each commit and refer to the parents of a commit using those integer positions. We use binary search to find initial commits and then use the integer positions for fast lookups during the walk.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceCommitGraph.CommitDataMetadata of a commit in commit data chunk.
-
Field Summary
Fields Modifier and Type Field Description static CommitGraphEMPTYEmptyCommitGraphwith no results.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intfindGraphPosition(AnyObjectId commit)Find the position in the commit-graph of the commit.longgetCommitCnt()Obtain the total number of commits described by this commit-graph.CommitGraph.CommitDatagetCommitData(int graphPos)Get the metadata of a commit。ObjectIdgetObjectId(int graphPos)Get the object at the commit-graph position.
-
-
-
Field Detail
-
EMPTY
static final CommitGraph EMPTY
EmptyCommitGraphwith no results.
-
-
Method Detail
-
findGraphPosition
int findGraphPosition(AnyObjectId commit)
Find the position in the commit-graph of the commit.The position can only be used within the CommitGraph Instance you got it from. That's because the graph position of the same commit may be different in CommitGraph obtained at different times (eg., regenerated new commit-graph).
- Parameters:
commit- the commit for which the commit-graph position will be found.- Returns:
- the commit-graph position or -1 if the object was not found.
-
getCommitData
CommitGraph.CommitData getCommitData(int graphPos)
Get the metadata of a commit。This function runs in time O(1).
In the process of commit history traversal,
CommitGraph.CommitData.getParents()makes us get the graphPos of the commit's parents in advance, so that we can avoid O(logN) lookup and use O(1) lookup instead.- Parameters:
graphPos- the position in the commit-graph of the object.- Returns:
- the metadata of a commit or null if it's not found.
-
getObjectId
ObjectId getObjectId(int graphPos)
Get the object at the commit-graph position.- Parameters:
graphPos- the position in the commit-graph of the object.- Returns:
- the ObjectId or null if it's not found.
-
getCommitCnt
long getCommitCnt()
Obtain the total number of commits described by this commit-graph.- Returns:
- number of commits in this commit-graph.
-
-