public class ObjectDirectory extends ObjectDatabase
ObjectDatabase.
This is the classical object database representation for a Git repository,
where objects are stored loose by hashing them into directories by their
ObjectId, or are stored in compressed containers known as
PackFiles.
Optionally an object database can reference one or more alternates; other ObjectDatabase instances that are searched in addition to the current database.
Databases are divided into two halves: a half that is considered to be fast
to search (the PackFiles), and a half that is considered to be slow
to search (loose objects). When alternates are present the fast half is fully
searched (recursively through all alternates) before the slow half is
considered.
| Constructor and Description |
|---|
ObjectDirectory(Config cfg,
File dir,
File[] alternatePaths,
FS fs,
File shallowFile)
Initialize a reference to an on-disk object directory.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close any resources held by this database.
|
void |
create()
Initialize a new object database at this location.
|
boolean |
exists()
Does this database exist yet?
|
File |
fileFor(AnyObjectId objectId)
Compute the location of a loose object file.
|
File |
getDirectory() |
Collection<PackFile> |
getPacks() |
boolean |
has(AnyObjectId objectId)
Does the requested object exist in this database?
|
ObjectDatabase |
newCachedDatabase()
Create a new cached database instance over this database.
|
org.eclipse.jgit.internal.storage.file.ObjectDirectoryInserter |
newInserter()
Create a new
ObjectInserter to insert new objects. |
ObjectReader |
newReader()
Create a new
ObjectReader to read existing objects. |
PackFile |
openPack(File pack)
Add a single existing pack to the list of available pack files.
|
String |
toString() |
open, openpublic ObjectDirectory(Config cfg, File dir, File[] alternatePaths, FS fs, File shallowFile) throws IOException
cfg - configuration this directory consults for write settings.dir - the location of the objects directory.alternatePaths - a list of alternate object directoriesfs - the file system abstraction which will be necessary to perform
certain file system operations.shallowFile - file which contains IDs of shallow commits, null if shallow
commits handling should be turned offIOException - an alternate object cannot be opened.public final File getDirectory()
objects directory.public boolean exists()
ObjectDatabaseexists in class ObjectDatabaseObjectDatabase.create() to create this database location.public void create()
throws IOException
ObjectDatabasecreate in class ObjectDatabaseIOException - the database could not be created.public org.eclipse.jgit.internal.storage.file.ObjectDirectoryInserter newInserter()
ObjectDatabaseObjectInserter to insert new objects.
The returned inserter is not itself thread-safe, but multiple concurrent
inserter instances created from the same ObjectDatabase must be
thread-safe.
public void close()
ObjectDatabaseclose in class ObjectDatabasepublic Collection<PackFile> getPacks()
public PackFile openPack(File pack) throws IOException
pack - path of the pack file to open.IOException - index file could not be opened, read, or is not recognized as
a Git pack file index.public boolean has(AnyObjectId objectId)
ObjectDatabase
This is a one-shot call interface which may be faster than allocating a
ObjectDatabase.newReader() to perform the lookup.
has in class ObjectDatabaseobjectId - identity of the object to test for existence of.public File fileFor(AnyObjectId objectId)
objectId - identity of the loose object to map to the directory.public ObjectDatabase newCachedDatabase()
ObjectDatabasenewCachedDatabase in class ObjectDatabasepublic ObjectReader newReader()
ObjectDatabaseObjectReader to read existing objects.
The returned reader is not itself thread-safe, but multiple concurrent
reader instances created from the same ObjectDatabase must be
thread-safe.
newReader in class ObjectDatabaseCopyright © 2014. All rights reserved.