Top Description Fields Constructors Methods
org.eclipse.jgit.internal.storage.file

pack-priv Class LooseObjects

extends Object
Class Inheritance
Imports
java.io.File, .FileInputStream, .FileNotFoundException, .IOException, .InputStream, java.nio.file.Files, .NoSuchFileException, .StandardCopyOption, java.text.MessageFormat, java.util.Set, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.internal.storage.file.FileObjectDatabase.InsertLooseObjectResult, org.eclipse.jgit.lib.AbbreviatedObjectId, .AnyObjectId, .Config, .Constants, .CoreConfig, .CoreConfig.TrustStat, .ObjectId, .ObjectLoader, org.eclipse.jgit.util.FileUtils, org.slf4j.Logger, .LoggerFactory

Traditional file system based loose objects handler.

This is the loose object representation for a Git object database, where objects are stored loose by hashing them into directories by their org.eclipse.jgit.lib.ObjectId.

Field Summary

Modifier and TypeField and Description
private final File
private static final Logger
private static final int
MAX_STALE_READ_RETRIES

Maximum number of attempts to read a loose object for which a stale file handle exception is thrown

private final CoreConfig.TrustStat
private final UnpackedObjectCache

Constructor Summary

AccessConstructor and Description
pack-priv
LooseObjects(Config
configuration for the loose objects handler.
config
,
File
the location of the objects directory.
dir
)

Initialize a reference to an on-disk object directory.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
pack-priv void
pack-priv File

Returns:

java.io.File location of the specified loose object.
fileFor
(AnyObjectId
identity of the object to get the File location for.
objectId
)

Compute the location of a loose object file.

pack-priv File

Returns:

the location of the objects directory.
getDirectory
()

Getter for the field directory.

pack-priv ObjectLoader

Returns:

a loader for the loose file object
getObjectLoader
(WindowCursor
cursor on the database
curs
,
File
the path of the loose object
path
,
AnyObjectId
the object id
id
)

Provides a loader for an objectId

private ObjectLoader
pack-priv long
private long
pack-priv boolean

Returns:

true if the specified object is stored as a loose object.
has
(AnyObjectId
identity of the object to test for existence of.
objectId
)

Does the requested object exist as a loose object?

pack-priv boolean
private boolean
pack-priv FileObjectDatabase.InsertLooseObjectResult
insert(File tmp, ObjectId id)

pack-priv ObjectLoader
pack-priv boolean

Returns:

true if the matches were exhausted before reaching maxLimit.
resolve
(Set<ObjectId>
set to add any located ObjectIds to. This is an output parameter.
matches
,
AbbreviatedObjectId
prefix to search for.
id
,
int
maximum number of results to return. At most this many ObjectIds should be added to matches before returning.
matchLimit
)

Find objects matching the prefix abbreviation.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private FileObjectDatabase.InsertLooseObjectResult
tryMove(File tmp, File dst, ObjectId id)

pack-priv UnpackedObjectCache

Returns:

the cache of the objects currently unpacked.
unpackedObjectCache
()

Getter for the field unpackedObjectCache.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

directoryback to summary
private final File directory
LOGback to summary
private static final Logger LOG
MAX_STALE_READ_RETRIESback to summary
private static final int MAX_STALE_READ_RETRIES

Maximum number of attempts to read a loose object for which a stale file handle exception is thrown

trustLooseObjectStatback to summary
private final CoreConfig.TrustStat trustLooseObjectStat
unpackedObjectCacheback to summary
private final UnpackedObjectCache unpackedObjectCache

Constructor Detail

LooseObjectsback to summary
pack-priv LooseObjects(Config config, File dir)

Initialize a reference to an on-disk object directory.

Parameters
config:Config

configuration for the loose objects handler.

dir:File

the location of the objects directory.

Method Detail

closeback to summary
pack-priv void close()
createback to summary
pack-priv void create() throws IOException
fileForback to summary
pack-priv File fileFor(AnyObjectId objectId)

Compute the location of a loose object file.

Parameters
objectId:AnyObjectId

identity of the object to get the File location for.

Returns:File

java.io.File location of the specified loose object.

getDirectoryback to summary
pack-priv File getDirectory()

Getter for the field directory.

Returns:File

the location of the objects directory.

getObjectLoaderback to summary
pack-priv ObjectLoader getObjectLoader(WindowCursor curs, File path, AnyObjectId id) throws IOException

Provides a loader for an objectId

Parameters
curs:WindowCursor

cursor on the database

path:File

the path of the loose object

id:AnyObjectId

the object id

Returns:ObjectLoader

a loader for the loose file object

Exceptions
IOException:
when file does not exist or it could not be opened
getObjectLoaderWithoutRefreshback to summary
private ObjectLoader getObjectLoaderWithoutRefresh(WindowCursor curs, File path, AnyObjectId id) throws IOException
getSizeback to summary
pack-priv long getSize(WindowCursor curs, AnyObjectId id) throws IOException
getSizeWithoutRefreshback to summary
private long getSizeWithoutRefresh(WindowCursor curs, AnyObjectId id) throws IOException
hasback to summary
pack-priv boolean has(AnyObjectId objectId)

Does the requested object exist as a loose object?

Parameters
objectId:AnyObjectId

identity of the object to test for existence of.

Returns:boolean

true if the specified object is stored as a loose object.

hasCachedback to summary
pack-priv boolean hasCached(AnyObjectId id)
hasWithoutRefreshback to summary
private boolean hasWithoutRefresh(AnyObjectId objectId)
insertback to summary
pack-priv FileObjectDatabase.InsertLooseObjectResult insert(File tmp, ObjectId id) throws IOException
openback to summary
pack-priv ObjectLoader open(WindowCursor curs, AnyObjectId id) throws IOException
resolveback to summary
pack-priv boolean resolve(Set<ObjectId> matches, AbbreviatedObjectId id, int matchLimit)

Find objects matching the prefix abbreviation.

Parameters
matches:Set<ObjectId>

set to add any located ObjectIds to. This is an output parameter.

id:AbbreviatedObjectId

prefix to search for.

matchLimit:int

maximum number of results to return. At most this many ObjectIds should be added to matches before returning.

Returns:boolean

true if the matches were exhausted before reaching maxLimit.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
tryMoveback to summary
private FileObjectDatabase.InsertLooseObjectResult tryMove(File tmp, File dst, ObjectId id) throws IOException
unpackedObjectCacheback to summary
pack-priv UnpackedObjectCache unpackedObjectCache()

Getter for the field unpackedObjectCache.

This accessor is particularly useful to allow mocking of this class for testing purposes.
Returns:UnpackedObjectCache

the cache of the objects currently unpacked.