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) |
File |
getDirectory() |
File |
getPackDirectory()
Getter for the field
packDirectory . |
Collection<PackFile> |
getPacks() |
File |
getPreservedDirectory()
Getter for the field
preservedDirectory . |
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. |
PackInserter |
newPackInserter()
Create a new inserter that inserts all objects as pack files, not loose
objects.
|
ObjectReader |
newReader()
Create a new
ObjectReader to read existing objects. |
PackFile |
openPack(File pack) |
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()
public final File getPackDirectory()
Getter for the field packDirectory
.
pack
directory.public final File getPreservedDirectory()
Getter for the field preservedDirectory
.
preserved
directory.public boolean exists()
exists
in class ObjectDatabase
ObjectDatabase.create()
to create this database location.public void create() throws IOException
create
in class ObjectDatabase
IOException
- the database could not be created.public org.eclipse.jgit.internal.storage.file.ObjectDirectoryInserter newInserter()
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 PackInserter newPackInserter()
public void close()
close
in class ObjectDatabase
public Collection<PackFile> getPacks()
public PackFile openPack(File pack) throws IOException
Add a single existing pack to the list of available pack files.
IOException
public boolean has(AnyObjectId objectId)
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)
Compute the location of a loose object file.
public ObjectDatabase newCachedDatabase()
newCachedDatabase
in class ObjectDatabase
public ObjectReader newReader()
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 © 2017 Eclipse JGit Project. All rights reserved.