Class CachedObjectDirectory
- java.lang.Object
-
- org.eclipse.jgit.lib.ObjectDatabase
-
- org.eclipse.jgit.internal.storage.file.FileObjectDatabase
-
- org.eclipse.jgit.internal.storage.file.CachedObjectDirectory
-
class CachedObjectDirectory extends FileObjectDatabase
The cached instance of anObjectDirectory.This class caches the list of loose objects in memory, so the file system is not queried with stat calls.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classCachedObjectDirectory.UnpackedObjectId-
Nested classes/interfaces inherited from class org.eclipse.jgit.internal.storage.file.FileObjectDatabase
FileObjectDatabase.InsertLooseObjectResult
-
-
Field Summary
Fields Modifier and Type Field Description private CachedObjectDirectory[]altsprivate ObjectIdOwnerMap<CachedObjectDirectory.UnpackedObjectId>unpackedObjectsThe set that contains unpacked objects identifiers, it is created when the cached instance is created.private ObjectDirectorywrapped
-
Constructor Summary
Constructors Constructor Description CachedObjectDirectory(ObjectDirectory wrapped)The constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close any resources held by this database.(package private) java.io.FilefileFor(AnyObjectId id)private ObjectDirectory.AlternateHandle.IdgetAlternateId()(package private) ConfiggetConfig()(package private) java.io.FilegetDirectory()(package private) FSgetFS()(package private) longgetObjectSize(WindowCursor curs, AnyObjectId objectId)(package private) java.util.Collection<Pack>getPacks()(package private) java.util.Set<ObjectId>getShallowCommits()booleanhas(AnyObjectId objectId)Does the requested object exist in this database?private booleanhas(AnyObjectId objectId, java.util.Set<ObjectDirectory.AlternateHandle.Id> skips)(package private) FileObjectDatabase.InsertLooseObjectResultinsertUnpackedObject(java.io.File tmp, ObjectId objectId, boolean createDuplicate)private CachedObjectDirectory[]myAlternates()ObjectDatabasenewCachedDatabase()Create a new cached database instance over this database.(package private) ObjectLoaderopenLooseObject(WindowCursor curs, AnyObjectId id)(package private) ObjectLoaderopenObject(WindowCursor curs, AnyObjectId objectId)private ObjectLoaderopenObject(WindowCursor curs, AnyObjectId objectId, java.util.Set<ObjectDirectory.AlternateHandle.Id> skips)(package private) PackopenPack(java.io.File pack)(package private) voidresolve(java.util.Set<ObjectId> matches, AbbreviatedObjectId id)private ObjectIdOwnerMap<CachedObjectDirectory.UnpackedObjectId>scanLoose()(package private) voidselectObjectRepresentation(PackWriter packer, ObjectToPack otp, WindowCursor curs)private java.util.Set<ObjectDirectory.AlternateHandle.Id>skipMe(java.util.Set<ObjectDirectory.AlternateHandle.Id> skips)-
Methods inherited from class org.eclipse.jgit.internal.storage.file.FileObjectDatabase
newInserter, newReader
-
Methods inherited from class org.eclipse.jgit.lib.ObjectDatabase
create, exists, open, open
-
-
-
-
Field Detail
-
unpackedObjects
private ObjectIdOwnerMap<CachedObjectDirectory.UnpackedObjectId> unpackedObjects
The set that contains unpacked objects identifiers, it is created when the cached instance is created.
-
wrapped
private final ObjectDirectory wrapped
-
alts
private CachedObjectDirectory[] alts
-
-
Constructor Detail
-
CachedObjectDirectory
CachedObjectDirectory(ObjectDirectory wrapped)
The constructor- Parameters:
wrapped- the wrapped database
-
-
Method Detail
-
scanLoose
private ObjectIdOwnerMap<CachedObjectDirectory.UnpackedObjectId> scanLoose()
-
close
public void close()
Close any resources held by this database.- Specified by:
closein classObjectDatabase
-
newCachedDatabase
public ObjectDatabase newCachedDatabase()
Create a new cached database instance over this database. This instance might optimize queries by caching some information about database. So some modifications done after instance creation might fail to be noticed.- Overrides:
newCachedDatabasein classObjectDatabase- Returns:
- new cached database instance
-
getDirectory
java.io.File getDirectory()
- Specified by:
getDirectoryin classFileObjectDatabase
-
fileFor
java.io.File fileFor(AnyObjectId id)
- Specified by:
fileForin classFileObjectDatabase
-
getConfig
Config getConfig()
- Specified by:
getConfigin classFileObjectDatabase
-
getFS
FS getFS()
- Specified by:
getFSin classFileObjectDatabase
-
getShallowCommits
java.util.Set<ObjectId> getShallowCommits() throws java.io.IOException
- Specified by:
getShallowCommitsin classFileObjectDatabase- Throws:
java.io.IOException
-
myAlternates
private CachedObjectDirectory[] myAlternates()
-
skipMe
private java.util.Set<ObjectDirectory.AlternateHandle.Id> skipMe(java.util.Set<ObjectDirectory.AlternateHandle.Id> skips)
-
resolve
void resolve(java.util.Set<ObjectId> matches, AbbreviatedObjectId id) throws java.io.IOException
- Specified by:
resolvein classFileObjectDatabase- Throws:
java.io.IOException
-
has
public boolean has(AnyObjectId objectId) throws java.io.IOException
Does the requested object exist in this database?This is a one-shot call interface which may be faster than allocating a
ObjectDatabase.newReader()to perform the lookup.- Overrides:
hasin classObjectDatabase- Parameters:
objectId- identity of the object to test for existence of.- Returns:
- true if the specified object is stored in this database.
- Throws:
java.io.IOException- the object store cannot be accessed.
-
has
private boolean has(AnyObjectId objectId, java.util.Set<ObjectDirectory.AlternateHandle.Id> skips) throws java.io.IOException
- Throws:
java.io.IOException
-
openObject
ObjectLoader openObject(WindowCursor curs, AnyObjectId objectId) throws java.io.IOException
- Specified by:
openObjectin classFileObjectDatabase- Throws:
java.io.IOException
-
openObject
private ObjectLoader openObject(WindowCursor curs, AnyObjectId objectId, java.util.Set<ObjectDirectory.AlternateHandle.Id> skips) throws java.io.IOException
- Throws:
java.io.IOException
-
getObjectSize
long getObjectSize(WindowCursor curs, AnyObjectId objectId) throws java.io.IOException
- Specified by:
getObjectSizein classFileObjectDatabase- Throws:
java.io.IOException
-
openLooseObject
ObjectLoader openLooseObject(WindowCursor curs, AnyObjectId id) throws java.io.IOException
- Specified by:
openLooseObjectin classFileObjectDatabase- Throws:
java.io.IOException
-
insertUnpackedObject
FileObjectDatabase.InsertLooseObjectResult insertUnpackedObject(java.io.File tmp, ObjectId objectId, boolean createDuplicate) throws java.io.IOException
- Specified by:
insertUnpackedObjectin classFileObjectDatabase- Throws:
java.io.IOException
-
openPack
Pack openPack(java.io.File pack) throws java.io.IOException
- Specified by:
openPackin classFileObjectDatabase- Throws:
java.io.IOException
-
selectObjectRepresentation
void selectObjectRepresentation(PackWriter packer, ObjectToPack otp, WindowCursor curs) throws java.io.IOException
- Specified by:
selectObjectRepresentationin classFileObjectDatabase- Throws:
java.io.IOException
-
getPacks
java.util.Collection<Pack> getPacks()
- Specified by:
getPacksin classFileObjectDatabase
-
getAlternateId
private ObjectDirectory.AlternateHandle.Id getAlternateId()
-
-