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
PackFile
s.
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 PackFile
s), 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, open
public 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()
ObjectDatabase
exists
in class ObjectDatabase
ObjectDatabase.create()
to create this database location.public void create() throws IOException
ObjectDatabase
create
in class ObjectDatabase
IOException
- the database could not be created.public org.eclipse.jgit.internal.storage.file.ObjectDirectoryInserter newInserter()
ObjectDatabase
ObjectInserter
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()
ObjectDatabase
close
in class ObjectDatabase
public 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 ObjectDatabase
objectId
- 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()
ObjectDatabase
newCachedDatabase
in class ObjectDatabase
public ObjectReader newReader()
ObjectDatabase
ObjectReader
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 ObjectDatabase
Copyright © 2015. All rights reserved.