Class InMemoryRepository.MemObjDatabase
- java.lang.Object
-
- org.eclipse.jgit.lib.ObjectDatabase
-
- org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase
-
- org.eclipse.jgit.internal.storage.dfs.InMemoryRepository.MemObjDatabase
-
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
- InMemoryRepository
public static class InMemoryRepository.MemObjDatabase extends DfsObjDatabase
DfsObjDatabase used by InMemoryRepository.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase
DfsObjDatabase.PackList, DfsObjDatabase.PackSource
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
commitPackImpl(Collection<DfsPackDescription> desc, Collection<DfsPackDescription> replace)
Implementation of pack commit.long
getApproximateObjectCount()
Get a quick, rough count of objects in this repository.Set<ObjectId>
getShallowCommits()
protected List<DfsPackDescription>
listPacks()
List the available pack files.protected DfsPackDescription
newPack(DfsObjDatabase.PackSource source)
Generate a new unique name for a pack file.protected ReadableChannel
openFile(DfsPackDescription desc, PackExt ext)
Open a pack, pack index, or other related file for reading.protected void
rollbackPack(Collection<DfsPackDescription> desc)
Try to rollback a pack creation.void
setReadableChannelBlockSizeForTest(int blockSize)
void
setShallowCommits(Set<ObjectId> shallowCommits)
Update the shallow commits of the current repositoryprotected DfsOutputStream
writeFile(DfsPackDescription desc, PackExt ext)
Open a pack, pack index, or other related file for writing.-
Methods inherited from class org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase
clearCache, close, commitPack, getCurrentPackList, getCurrentPacks, getCurrentReftables, getPackList, getPacks, getReaderOptions, getReftables, getRepository, has, newInserter, newPack, newReader, reftableComparator, setPackComparator
-
Methods inherited from class org.eclipse.jgit.lib.ObjectDatabase
create, exists, has, newCachedDatabase, open, open
-
-
-
-
Method Detail
-
setReadableChannelBlockSizeForTest
public void setReadableChannelBlockSizeForTest(int blockSize)
- Parameters:
blockSize
- force a different block size for testing.
-
listPacks
protected List<DfsPackDescription> listPacks()
Description copied from class:DfsObjDatabase
List the available pack files.The returned list must support random access and must be mutable by the caller. It is sorted in place using the natural sorting of the returned DfsPackDescription objects.
- Specified by:
listPacks
in classDfsObjDatabase
- Returns:
- available packs. May be empty if there are no packs.
-
newPack
protected DfsPackDescription newPack(DfsObjDatabase.PackSource source)
Description copied from class:DfsObjDatabase
Generate a new unique name for a pack file.- Specified by:
newPack
in classDfsObjDatabase
- Parameters:
source
- where the pack stream is created.- Returns:
- a unique name for the pack file. Must not collide with any other pack file name in the same DFS.
-
commitPackImpl
protected void commitPackImpl(Collection<DfsPackDescription> desc, Collection<DfsPackDescription> replace)
Description copied from class:DfsObjDatabase
Implementation of pack commit.- Specified by:
commitPackImpl
in classDfsObjDatabase
- Parameters:
desc
- description of the new packs.replace
- if not null, list of packs to remove.- See Also:
DfsObjDatabase.commitPack(Collection, Collection)
-
rollbackPack
protected void rollbackPack(Collection<DfsPackDescription> desc)
Description copied from class:DfsObjDatabase
Try to rollback a pack creation.JGit DFS always writes the pack first, then the index. If the pack does not yet exist, then neither does the index. A safe DFS implementation would try to remove both files to ensure they are really gone.
A rollback does not support failures, as it only occurs when there is already a failure in progress. A DFS implementor may wish to log warnings/error messages when a rollback fails, but should not send new exceptions up the Java callstack.
- Specified by:
rollbackPack
in classDfsObjDatabase
- Parameters:
desc
- pack to delete.
-
openFile
protected ReadableChannel openFile(DfsPackDescription desc, PackExt ext) throws FileNotFoundException, IOException
Description copied from class:DfsObjDatabase
Open a pack, pack index, or other related file for reading.- Specified by:
openFile
in classDfsObjDatabase
- Parameters:
desc
- description of pack related to the data that will be read. This is an instance previously obtained fromDfsObjDatabase.listPacks()
, but not necessarily from the same DfsObjDatabase instance.ext
- file extension that will be read i.e "pack" or "idx".- Returns:
- channel to read the file.
- Throws:
FileNotFoundException
- the file does not exist.IOException
- the file cannot be opened.
-
writeFile
protected DfsOutputStream writeFile(DfsPackDescription desc, PackExt ext) throws IOException
Description copied from class:DfsObjDatabase
Open a pack, pack index, or other related file for writing.- Specified by:
writeFile
in classDfsObjDatabase
- Parameters:
desc
- description of pack related to the data that will be written. This is an instance previously obtained fromDfsObjDatabase.newPack(PackSource)
.ext
- file extension that will be written i.e "pack" or "idx".- Returns:
- channel to write the file.
- Throws:
IOException
- the file cannot be opened.
-
getShallowCommits
public Set<ObjectId> getShallowCommits() throws IOException
- Overrides:
getShallowCommits
in classObjectDatabase
- Returns:
- the shallow commits of the current repository
- Throws:
IOException
- the database could not be read
-
setShallowCommits
public void setShallowCommits(Set<ObjectId> shallowCommits)
Description copied from class:ObjectDatabase
Update the shallow commits of the current repository- Overrides:
setShallowCommits
in classObjectDatabase
- Parameters:
shallowCommits
- the new shallow commits
-
getApproximateObjectCount
public long getApproximateObjectCount()
Description copied from class:ObjectDatabase
Get a quick, rough count of objects in this repository. Ignores loose objects. Returns-1
if an exception occurs.- Specified by:
getApproximateObjectCount
in classObjectDatabase
- Returns:
- quick, rough count of objects in this repository,
-1
if an exception occurs
-
-