Class CachedObjectDirectory
java.lang.Object
org.eclipse.jgit.lib.ObjectDatabase
org.eclipse.jgit.internal.storage.file.FileObjectDatabase
org.eclipse.jgit.internal.storage.file.CachedObjectDirectory
- All Implemented Interfaces:
AutoCloseable
The cached instance of an
ObjectDirectory.
This class caches the list of loose objects in memory, so the file system is not queried with stat calls.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.eclipse.jgit.internal.storage.file.FileObjectDatabase
FileObjectDatabase.InsertLooseObjectResult -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate CachedObjectDirectory[]The set that contains unpacked objects identifiers, it is created when the cached instance is created.private final ObjectDirectory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close any resources held by this database.(package private) FilefileFor(AnyObjectId id) longGet a quick, rough count of objects in this repository.(package private) Config(package private) File(package private) FSgetFS()(package private) longgetObjectSize(WindowCursor curs, AnyObjectId objectId) (package private) Collection<Pack>getPacks()booleanhas(AnyObjectId objectId) Does the requested object exist in this database?private booleanhas(AnyObjectId objectId, Set<ObjectDirectory.AlternateHandle.Id> skips) (package private) FileObjectDatabase.InsertLooseObjectResultinsertUnpackedObject(File tmp, ObjectId objectId, boolean createDuplicate) private CachedObjectDirectory[]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, Set<ObjectDirectory.AlternateHandle.Id> skips) (package private) Pack(package private) voidresolve(Set<ObjectId> matches, AbbreviatedObjectId id) (package private) voidselectObjectRepresentation(PackWriter packer, ObjectToPack otp, WindowCursor curs) private Set<ObjectDirectory.AlternateHandle.Id>Methods inherited from class org.eclipse.jgit.internal.storage.file.FileObjectDatabase
newInserter, newReaderMethods inherited from class org.eclipse.jgit.lib.ObjectDatabase
create, exists, open, open
-
Field Details
-
unpackedObjects
The set that contains unpacked objects identifiers, it is created when the cached instance is created. -
wrapped
-
alts
-
-
Constructor Details
-
CachedObjectDirectory
CachedObjectDirectory(ObjectDirectory wrapped) The constructor- Parameters:
wrapped- the wrapped database
-
-
Method Details
-
scanLoose
-
close
public void close()Close any resources held by this database.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein classObjectDatabase
-
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
File getDirectory()- Specified by:
getDirectoryin classFileObjectDatabase
-
fileFor
- Specified by:
fileForin classFileObjectDatabase
-
getConfig
Config getConfig()- Specified by:
getConfigin classFileObjectDatabase
-
getFS
FS getFS()- Specified by:
getFSin classFileObjectDatabase
-
getShallowCommits
- Specified by:
getShallowCommitsin classFileObjectDatabase- Throws:
IOException
-
myAlternates
-
skipMe
private Set<ObjectDirectory.AlternateHandle.Id> skipMe(Set<ObjectDirectory.AlternateHandle.Id> skips) -
resolve
- Specified by:
resolvein classFileObjectDatabase- Throws:
IOException
-
has
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:
IOException- the object store cannot be accessed.
-
has
private boolean has(AnyObjectId objectId, Set<ObjectDirectory.AlternateHandle.Id> skips) throws IOException - Throws:
IOException
-
openObject
- Specified by:
openObjectin classFileObjectDatabase- Throws:
IOException
-
openObject
private ObjectLoader openObject(WindowCursor curs, AnyObjectId objectId, Set<ObjectDirectory.AlternateHandle.Id> skips) throws IOException - Throws:
IOException
-
getObjectSize
- Specified by:
getObjectSizein classFileObjectDatabase- Throws:
IOException
-
openLooseObject
- Specified by:
openLooseObjectin classFileObjectDatabase- Throws:
IOException
-
insertUnpackedObject
FileObjectDatabase.InsertLooseObjectResult insertUnpackedObject(File tmp, ObjectId objectId, boolean createDuplicate) throws IOException - Specified by:
insertUnpackedObjectin classFileObjectDatabase- Throws:
IOException
-
openPack
- Specified by:
openPackin classFileObjectDatabase- Throws:
IOException
-
selectObjectRepresentation
void selectObjectRepresentation(PackWriter packer, ObjectToPack otp, WindowCursor curs) throws IOException - Specified by:
selectObjectRepresentationin classFileObjectDatabase- Throws:
IOException
-
getPacks
Collection<Pack> getPacks()- Specified by:
getPacksin classFileObjectDatabase
-
getAlternateId
-
getApproximateObjectCount
public long getApproximateObjectCount()Description copied from class:ObjectDatabaseGet a quick, rough count of objects in this repository. Ignores loose objects. Returns-1if an exception occurs.- Specified by:
getApproximateObjectCountin classObjectDatabase- Returns:
- quick, rough count of objects in this repository,
-1if an exception occurs
-