public abstract class ObjectReader extends Object implements AutoCloseable
ObjectDatabase
for a single thread.
Readers that can support efficient reuse of pack encoded objects should also
implement the companion interface ObjectReuseAsIs
.
Modifier and Type | Field and Description |
---|---|
static int |
OBJ_ANY
Type hint indicating the caller doesn't know the type.
|
Constructor and Description |
---|
ObjectReader() |
Modifier and Type | Method and Description |
---|---|
AbbreviatedObjectId |
abbreviate(AnyObjectId objectId)
Obtain a unique abbreviation (prefix) of an object SHA-1.
|
AbbreviatedObjectId |
abbreviate(AnyObjectId objectId,
int len)
Obtain a unique abbreviation (prefix) of an object SHA-1.
|
abstract void |
close()
Release any resources used by this reader.
|
BitmapIndex |
getBitmapIndex()
An index that can be used to speed up ObjectWalks.
|
long |
getObjectSize(AnyObjectId objectId,
int typeHint)
Get only the size of an object.
|
<T extends ObjectId> |
getObjectSize(Iterable<T> objectIds,
boolean reportMissing)
Asynchronous object size lookup.
|
abstract Set<ObjectId> |
getShallowCommits()
Returns IDs for those commits which should be considered as shallow.
|
boolean |
has(AnyObjectId objectId)
Does the requested object exist in this database?
|
boolean |
has(AnyObjectId objectId,
int typeHint)
Does the requested object exist in this database?
|
abstract ObjectReader |
newReader()
Construct a new reader from the same data.
|
ObjectLoader |
open(AnyObjectId objectId)
Open an object from this database.
|
abstract ObjectLoader |
open(AnyObjectId objectId,
int typeHint)
Open an object from this database.
|
<T extends ObjectId> |
open(Iterable<T> objectIds,
boolean reportMissing)
Asynchronous object opening.
|
abstract Collection<ObjectId> |
resolve(AbbreviatedObjectId id)
Resolve an abbreviated ObjectId to its full form.
|
void |
setAvoidUnreachableObjects(boolean avoid)
Advise the reader to avoid unreachable objects.
|
public static final int OBJ_ANY
public abstract ObjectReader newReader()
Applications can use this method to build a new reader from the same data source, but for an different thread.
public AbbreviatedObjectId abbreviate(AnyObjectId objectId) throws IOException
resolve(AbbreviatedObjectId)
, assuming no new objects
are added to this repository between calls.objectId
- object identity that needs to be abbreviated.IOException
- the object store cannot be read.public AbbreviatedObjectId abbreviate(AnyObjectId objectId, int len) throws IOException
resolve(AbbreviatedObjectId)
, assuming no new objects
are added to this repository between calls.
The default implementation of this method abbreviates the id to the
minimum length, then resolves it to see if there are multiple results.
When multiple results are found, the length is extended by 1 and resolve
is tried again.objectId
- object identity that needs to be abbreviated.len
- minimum length of the abbreviated string. Must be in the range
[2, ].IOException
- the object store cannot be read.public abstract Collection<ObjectId> resolve(AbbreviatedObjectId id) throws IOException
id
- abbreviated id to resolve to a complete identity. The
abbreviation must have a length of at least 2.IOException
- the object store cannot be read.public boolean has(AnyObjectId objectId) throws IOException
objectId
- identity of the object to test for existence of.IOException
- the object store cannot be accessed.public boolean has(AnyObjectId objectId, int typeHint) throws IOException
objectId
- identity of the object to test for existence of.typeHint
- hint about the type of object being requested, e.g.
Constants.OBJ_BLOB
; OBJ_ANY
if the object
type is not known, or does not matter to the caller.IncorrectObjectTypeException
- typeHint was not OBJ_ANY, and the object's actual type does
not match typeHint.IOException
- the object store cannot be accessed.public ObjectLoader open(AnyObjectId objectId) throws MissingObjectException, IOException
objectId
- identity of the object to open.ObjectLoader
for accessing the object.MissingObjectException
- the object does not exist.IOException
- the object store cannot be accessed.public abstract ObjectLoader open(AnyObjectId objectId, int typeHint) throws MissingObjectException, IncorrectObjectTypeException, IOException
objectId
- identity of the object to open.typeHint
- hint about the type of object being requested, e.g.
Constants.OBJ_BLOB
; OBJ_ANY
if the object
type is not known, or does not matter to the caller.ObjectLoader
for accessing the object.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.public abstract Set<ObjectId> getShallowCommits() throws IOException
IOException
public <T extends ObjectId> AsyncObjectLoaderQueue<T> open(Iterable<T> objectIds, boolean reportMissing)
T
- type of identifier being supplied.objectIds
- objects to open from the object store. The supplied collection
must not be modified until the queue has finished.reportMissing
- if true missing objects are reported by calling failure with a
MissingObjectException. This may be more expensive for the
implementation to guarantee. If false the implementation may
choose to report MissingObjectException, or silently skip over
the object with no warning.public long getObjectSize(AnyObjectId objectId, int typeHint) throws MissingObjectException, IncorrectObjectTypeException, IOException
The default implementation of this method opens an ObjectLoader. Databases are encouraged to override this if a faster access method is available to them.
objectId
- identity of the object to open.typeHint
- hint about the type of object being requested, e.g.
Constants.OBJ_BLOB
; OBJ_ANY
if the object
type is not known, or does not matter to the caller.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.public <T extends ObjectId> AsyncObjectSizeQueue<T> getObjectSize(Iterable<T> objectIds, boolean reportMissing)
T
- type of identifier being supplied.objectIds
- objects to get the size of from the object store. The supplied
collection must not be modified until the queue has finished.reportMissing
- if true missing objects are reported by calling failure with a
MissingObjectException. This may be more expensive for the
implementation to guarantee. If false the implementation may
choose to report MissingObjectException, or silently skip over
the object with no warning.public void setAvoidUnreachableObjects(boolean avoid)
While enabled the reader will skip over anything previously proven to be unreachable. This may be dangerous in the face of concurrent writes.
avoid
- true to avoid unreachable objects.public BitmapIndex getBitmapIndex() throws IOException
IOException
- when the index fails to loadpublic abstract void close()
A reader that has been released can be used again, but may need to be released after the subsequent usage.
close
in interface AutoCloseable
Copyright © 2015 Eclipse JGit Project. All rights reserved.