Top Description Fields Constructors Methods
org.eclipse.jgit.lib

public abstract Class ObjectDatabase

extends Object
implements AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable
Known Direct Subclasses
org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase, org.eclipse.jgit.internal.storage.file.FileObjectDatabase
Imports
java.io.IOException, java.util.Collections, .Set, org.eclipse.jgit.errors.IncorrectObjectTypeException, .MissingObjectException

Abstraction of arbitrary object storage.

An object database stores one or more Git objects, indexed by their unique org.eclipse.jgit.lib.ObjectId.

Field Summary

Modifier and TypeField and Description
private static final Set<ObjectId>

Constructor Summary

AccessConstructor and Description
protected
ObjectDatabase()

Initialize a new database instance for access.

Method Summary

Modifier and TypeMethod and Description
public abstract void
close()

Redeclares java.lang.AutoCloseable.close.

Close any resources held by this database.

public void
create()

Initialize a new object database at this location.

public boolean

Returns:

true if this database is already created; false if the caller should invoke create() to create this database location.
exists
()

Does this database exist yet?

public abstract long

Returns:

quick, rough count of objects in this repository, -1 if an exception occurs
getApproximateObjectCount
()

Get a quick, rough count of objects in this repository.

public Set<ObjectId>

Returns:

the shallow commits of the current repository
getShallowCommits
()

Get the shallow commits of the current repository

public boolean

Returns:

true if the specified object is stored in this database.
has
(AnyObjectId
identity of the object to test for existence of.
objectId
)

Does the requested object exist in this database?

public ObjectDatabase

Returns:

new cached database instance
newCachedDatabase
()

Create a new cached database instance over this database.

public abstract ObjectInserter

Returns:

writer the caller can use to create objects in this database.
newInserter
()

Create a new ObjectInserter to insert new objects.

public abstract ObjectReader

Returns:

reader the caller can use to load objects from this database.
newReader
()

Create a new ObjectReader to read existing objects.

public ObjectLoader

Returns:

a org.eclipse.jgit.lib.ObjectLoader for accessing the object.
open
(AnyObjectId
identity of the object to open.
objectId
)

Open an object from this database.

public ObjectLoader

Returns:

a org.eclipse.jgit.lib.ObjectLoader for accessing the object.
open
(AnyObjectId
identity of the object to open.
objectId
,
int
hint about the type of object being requested, e.g. org.eclipse.jgit.lib.Constants#OBJ_BLOB; org.eclipse.jgit.lib.ObjectReader#OBJ_ANY if the object type is not known, or does not matter to the caller.
typeHint
)

Open an object from this database.

public void
setShallowCommits(Set<ObjectId>
the new shallow commits
shallowCommits
)

Update the shallow commits of the current repository

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

shallowCommitsback to summary
private static final Set<ObjectId> shallowCommits

Constructor Detail

ObjectDatabaseback to summary
protected ObjectDatabase()

Initialize a new database instance for access.

Method Detail

closeback to summary
public abstract void close()

Redeclares java.lang.AutoCloseable.close.

Close any resources held by this database.

Annotations
@Override
createback to summary
public void create() throws IOException

Initialize a new object database at this location.

Exceptions
IOException:
the database could not be created.
existsback to summary
public boolean exists()

Does this database exist yet?

Returns:boolean

true if this database is already created; false if the caller should invoke create() to create this database location.

getApproximateObjectCountback to summary
public abstract long getApproximateObjectCount()

Get a quick, rough count of objects in this repository. Ignores loose objects. Returns -1 if an exception occurs.

Returns:long

quick, rough count of objects in this repository, -1 if an exception occurs

Since
6.1
getShallowCommitsback to summary
public Set<ObjectId> getShallowCommits() throws IOException

Get the shallow commits of the current repository

Returns:Set<ObjectId>

the shallow commits of the current repository

Exceptions
IOException:
the database could not be read
Since
6.3
hasback to summary
public boolean has(AnyObjectId objectId) throws IOException

Does the requested object exist in this database?

This is a one-shot call interface which may be faster than allocating a newReader() to perform the lookup.

Parameters
objectId:AnyObjectId

identity of the object to test for existence of.

Returns:boolean

true if the specified object is stored in this database.

Exceptions
IOException:
the object store cannot be accessed.
newCachedDatabaseback to summary
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.

Returns:ObjectDatabase

new cached database instance

newInserterback to summary
public abstract ObjectInserter newInserter()

Create a new 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.

Returns:ObjectInserter

writer the caller can use to create objects in this database.

newReaderback to summary
public abstract ObjectReader newReader()

Create a new 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.

Returns:ObjectReader

reader the caller can use to load objects from this database.

openback to summary
public ObjectLoader open(AnyObjectId objectId) throws IOException

Open an object from this database.

This is a one-shot call interface which may be faster than allocating a newReader() to perform the lookup.

Parameters
objectId:AnyObjectId

identity of the object to open.

Returns:ObjectLoader

a org.eclipse.jgit.lib.ObjectLoader for accessing the object.

Exceptions
IOException:
the object store cannot be accessed.
MissingObjectException:
the object does not exist.
openback to summary
public ObjectLoader open(AnyObjectId objectId, int typeHint) throws MissingObjectException, IncorrectObjectTypeException, IOException

Open an object from this database.

This is a one-shot call interface which may be faster than allocating a newReader() to perform the lookup.

Parameters
objectId:AnyObjectId

identity of the object to open.

typeHint:int

hint about the type of object being requested, e.g. org.eclipse.jgit.lib.Constants#OBJ_BLOB; org.eclipse.jgit.lib.ObjectReader#OBJ_ANY if the object type is not known, or does not matter to the caller.

Returns:ObjectLoader

a org.eclipse.jgit.lib.ObjectLoader for accessing the object.

Exceptions
MissingObjectException:
the object does not exist.
IncorrectObjectTypeException:
typeHint was not OBJ_ANY, and the object's actual type does not match typeHint.
IOException:
the object store cannot be accessed.
setShallowCommitsback to summary
public void setShallowCommits(Set<ObjectId> shallowCommits) throws IOException

Update the shallow commits of the current repository

Parameters
shallowCommits:Set<ObjectId>

the new shallow commits

Exceptions
IOException:
the database could not be updated
Since
6.3