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 class
CachedObjectDirectory.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[]
alts
private ObjectIdOwnerMap<CachedObjectDirectory.UnpackedObjectId>
unpackedObjects
The set that contains unpacked objects identifiers, it is created when the cached instance is created.private ObjectDirectory
wrapped
-
Constructor Summary
Constructors Constructor Description CachedObjectDirectory(ObjectDirectory wrapped)
The constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close any resources held by this database.(package private) java.io.File
fileFor(AnyObjectId id)
private ObjectDirectory.AlternateHandle.Id
getAlternateId()
(package private) Config
getConfig()
(package private) java.io.File
getDirectory()
(package private) FS
getFS()
(package private) long
getObjectSize(WindowCursor curs, AnyObjectId objectId)
(package private) java.util.Collection<Pack>
getPacks()
(package private) java.util.Set<ObjectId>
getShallowCommits()
boolean
has(AnyObjectId objectId)
Does the requested object exist in this database?private boolean
has(AnyObjectId objectId, java.util.Set<ObjectDirectory.AlternateHandle.Id> skips)
(package private) FileObjectDatabase.InsertLooseObjectResult
insertUnpackedObject(java.io.File tmp, ObjectId objectId, boolean createDuplicate)
private CachedObjectDirectory[]
myAlternates()
ObjectDatabase
newCachedDatabase()
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, java.util.Set<ObjectDirectory.AlternateHandle.Id> skips)
(package private) Pack
openPack(java.io.File pack)
(package private) void
resolve(java.util.Set<ObjectId> matches, AbbreviatedObjectId id)
private ObjectIdOwnerMap<CachedObjectDirectory.UnpackedObjectId>
scanLoose()
(package private) void
selectObjectRepresentation(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:
close
in 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:
newCachedDatabase
in classObjectDatabase
- Returns:
- new cached database instance
-
getDirectory
java.io.File getDirectory()
- Specified by:
getDirectory
in classFileObjectDatabase
-
fileFor
java.io.File fileFor(AnyObjectId id)
- Specified by:
fileFor
in classFileObjectDatabase
-
getConfig
Config getConfig()
- Specified by:
getConfig
in classFileObjectDatabase
-
getFS
FS getFS()
- Specified by:
getFS
in classFileObjectDatabase
-
getShallowCommits
java.util.Set<ObjectId> getShallowCommits() throws java.io.IOException
- Specified by:
getShallowCommits
in 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:
resolve
in 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:
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:
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:
openObject
in 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:
getObjectSize
in classFileObjectDatabase
- Throws:
java.io.IOException
-
openLooseObject
ObjectLoader openLooseObject(WindowCursor curs, AnyObjectId id) throws java.io.IOException
- Specified by:
openLooseObject
in classFileObjectDatabase
- Throws:
java.io.IOException
-
insertUnpackedObject
FileObjectDatabase.InsertLooseObjectResult insertUnpackedObject(java.io.File tmp, ObjectId objectId, boolean createDuplicate) throws java.io.IOException
- Specified by:
insertUnpackedObject
in classFileObjectDatabase
- Throws:
java.io.IOException
-
openPack
Pack openPack(java.io.File pack) throws java.io.IOException
- Specified by:
openPack
in classFileObjectDatabase
- Throws:
java.io.IOException
-
selectObjectRepresentation
void selectObjectRepresentation(PackWriter packer, ObjectToPack otp, WindowCursor curs) throws java.io.IOException
- Specified by:
selectObjectRepresentation
in classFileObjectDatabase
- Throws:
java.io.IOException
-
getPacks
java.util.Collection<Pack> getPacks()
- Specified by:
getPacks
in classFileObjectDatabase
-
getAlternateId
private ObjectDirectory.AlternateHandle.Id getAlternateId()
-
-