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 TypeMethodDescriptionvoid
close()
Close any resources held by this database.(package private) File
fileFor
(AnyObjectId id) long
Get a quick, rough count of objects in this repository.(package private) Config
(package private) File
(package private) FS
getFS()
(package private) long
getObjectSize
(WindowCursor curs, AnyObjectId objectId) (package private) Collection<Pack>
getPacks()
boolean
has
(AnyObjectId objectId) Does the requested object exist in this database?private boolean
has
(AnyObjectId objectId, Set<ObjectDirectory.AlternateHandle.Id> skips) (package private) FileObjectDatabase.InsertLooseObjectResult
insertUnpackedObject
(File tmp, ObjectId objectId, boolean createDuplicate) private CachedObjectDirectory[]
Create a new cached database instance over this database.(package private) ObjectLoader
openLooseObject
(WindowCursor curs, AnyObjectId id) (package private) ObjectLoader
openObject
(WindowCursor curs, AnyObjectId objectId) private ObjectLoader
openObject
(WindowCursor curs, AnyObjectId objectId, Set<ObjectDirectory.AlternateHandle.Id> skips) (package private) Pack
(package private) void
resolve
(Set<ObjectId> matches, AbbreviatedObjectId id) (package private) void
selectObjectRepresentation
(PackWriter packer, ObjectToPack otp, WindowCursor curs) private Set<ObjectDirectory.AlternateHandle.Id>
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 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:
close
in interfaceAutoCloseable
- Specified by:
close
in 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:
newCachedDatabase
in classObjectDatabase
- Returns:
- new cached database instance
-
getDirectory
File getDirectory()- Specified by:
getDirectory
in classFileObjectDatabase
-
fileFor
- Specified by:
fileFor
in classFileObjectDatabase
-
getConfig
Config getConfig()- Specified by:
getConfig
in classFileObjectDatabase
-
getFS
FS getFS()- Specified by:
getFS
in classFileObjectDatabase
-
getShallowCommits
- Specified by:
getShallowCommits
in classFileObjectDatabase
- Throws:
IOException
-
myAlternates
-
skipMe
private Set<ObjectDirectory.AlternateHandle.Id> skipMe(Set<ObjectDirectory.AlternateHandle.Id> skips) -
resolve
- Specified by:
resolve
in 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:
has
in 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:
openObject
in classFileObjectDatabase
- Throws:
IOException
-
openObject
private ObjectLoader openObject(WindowCursor curs, AnyObjectId objectId, Set<ObjectDirectory.AlternateHandle.Id> skips) throws IOException - Throws:
IOException
-
getObjectSize
- Specified by:
getObjectSize
in classFileObjectDatabase
- Throws:
IOException
-
openLooseObject
- Specified by:
openLooseObject
in classFileObjectDatabase
- Throws:
IOException
-
insertUnpackedObject
FileObjectDatabase.InsertLooseObjectResult insertUnpackedObject(File tmp, ObjectId objectId, boolean createDuplicate) throws IOException - Specified by:
insertUnpackedObject
in classFileObjectDatabase
- Throws:
IOException
-
openPack
- Specified by:
openPack
in classFileObjectDatabase
- Throws:
IOException
-
selectObjectRepresentation
void selectObjectRepresentation(PackWriter packer, ObjectToPack otp, WindowCursor curs) throws IOException - Specified by:
selectObjectRepresentation
in classFileObjectDatabase
- Throws:
IOException
-
getPacks
Collection<Pack> getPacks()- Specified by:
getPacks
in classFileObjectDatabase
-
getAlternateId
-
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
-