Class ObjectReader.Filter

java.lang.Object
org.eclipse.jgit.lib.ObjectReader
org.eclipse.jgit.lib.ObjectReader.Filter
All Implemented Interfaces:
AutoCloseable
Enclosing class:
ObjectReader

public abstract static class ObjectReader.Filter extends ObjectReader
Wraps a delegate ObjectReader.
Since:
4.4
  • Constructor Details

    • Filter

      public Filter()
  • Method Details

    • delegate

      protected abstract ObjectReader delegate()
      Returns:
      delegate ObjectReader to handle all processing.
      Since:
      4.4
    • newReader

      public ObjectReader newReader()
      Description copied from class: ObjectReader
      Construct a new reader from the same data.

      Applications can use this method to build a new reader from the same data source, but for an different thread.

      Specified by:
      newReader in class ObjectReader
      Returns:
      a brand new reader, using the same data source.
    • abbreviate

      public AbbreviatedObjectId abbreviate(AnyObjectId objectId) throws IOException
      Description copied from class: ObjectReader
      Obtain a unique abbreviation (prefix) of an object SHA-1. This method uses a reasonable default for the minimum length. Callers who don't care about the minimum length should prefer this method. The returned abbreviation would expand back to the argument ObjectId when passed to ObjectReader.resolve(AbbreviatedObjectId), assuming no new objects are added to this repository between calls.
      Overrides:
      abbreviate in class ObjectReader
      Parameters:
      objectId - object identity that needs to be abbreviated.
      Returns:
      SHA-1 abbreviation.
      Throws:
      IOException - the object store cannot be read.
    • abbreviate

      public AbbreviatedObjectId abbreviate(AnyObjectId objectId, int len) throws IOException
      Description copied from class: ObjectReader
      Obtain a unique abbreviation (prefix) of an object SHA-1. The returned abbreviation would expand back to the argument ObjectId when passed to ObjectReader.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.
      Overrides:
      abbreviate in class ObjectReader
      Parameters:
      objectId - object identity that needs to be abbreviated.
      len - minimum length of the abbreviated string. Must be in the range [2, 40].
      Returns:
      SHA-1 abbreviation. If no matching objects exist in the repository, the abbreviation will match the minimum length.
      Throws:
      IOException - the object store cannot be read.
    • resolve

      public Collection<ObjectId> resolve(AbbreviatedObjectId id) throws IOException
      Description copied from class: ObjectReader
      Resolve an abbreviated ObjectId to its full form. This method searches for an ObjectId that begins with the abbreviation, and returns at least some matching candidates. If the returned collection is empty, no objects start with this abbreviation. The abbreviation doesn't belong to this repository, or the repository lacks the necessary objects to complete it. If the collection contains exactly one member, the abbreviation is (currently) unique within this database. There is a reasonably high probability that the returned id is what was previously abbreviated. If the collection contains 2 or more members, the abbreviation is not unique. In this case the implementation is only required to return at least 2 candidates to signal the abbreviation has conflicts. User friendly implementations should return as many candidates as reasonably possible, as the caller may be able to disambiguate further based on context. However since databases can be very large (e.g. 10 million objects) returning 625,000 candidates for the abbreviation "0" is simply unreasonable, so implementors should draw the line at around 256 matches.
      Specified by:
      resolve in class ObjectReader
      Parameters:
      id - abbreviated id to resolve to a complete identity. The abbreviation must have a length of at least 2.
      Returns:
      candidates that begin with the abbreviated identity.
      Throws:
      IOException - the object store cannot be read.
    • has

      public boolean has(AnyObjectId objectId) throws IOException
      Description copied from class: ObjectReader
      Does the requested object exist in this database?
      Overrides:
      has in class ObjectReader
      Parameters:
      objectId - identity of the object to test for existence of.
      Returns:
      true if the specified object is stored in this database.
      Throws:
      IOException - the object store cannot be accessed.
    • has

      public boolean has(AnyObjectId objectId, int typeHint) throws IOException
      Description copied from class: ObjectReader
      Does the requested object exist in this database?
      Overrides:
      has in class ObjectReader
      Parameters:
      objectId - identity of the object to test for existence of.
      typeHint - hint about the type of object being requested, e.g. Constants.OBJ_BLOB; ObjectReader.OBJ_ANY if the object type is not known, or does not matter to the caller.
      Returns:
      true if the specified object is stored in this database.
      Throws:
      IOException - the object store cannot be accessed.
    • open

      Description copied from class: ObjectReader
      Open an object from this database.
      Overrides:
      open in class ObjectReader
      Parameters:
      objectId - identity of the object to open.
      Returns:
      a ObjectLoader for accessing the object.
      Throws:
      MissingObjectException - the object does not exist.
      IOException - the object store cannot be accessed.
    • open

      Description copied from class: ObjectReader
      Open an object from this database.
      Specified by:
      open in class ObjectReader
      Parameters:
      objectId - identity of the object to open.
      typeHint - hint about the type of object being requested, e.g. Constants.OBJ_BLOB; ObjectReader.OBJ_ANY if the object type is not known, or does not matter to the caller.
      Returns:
      a ObjectLoader for accessing the object.
      Throws:
      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.
    • getShallowCommits

      public Set<ObjectId> getShallowCommits() throws IOException
      Description copied from class: ObjectReader
      Returns IDs for those commits which should be considered as shallow.
      Specified by:
      getShallowCommits in class ObjectReader
      Returns:
      IDs of shallow commits
      Throws:
      IOException
    • open

      public <T extends ObjectId> AsyncObjectLoaderQueue<T> open(Iterable<T> objectIds, boolean reportMissing)
      Description copied from class: ObjectReader
      Asynchronous object opening.
      Overrides:
      open in class ObjectReader
      Parameters:
      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.
      Returns:
      queue to read the objects from.
    • getObjectSize

      public long getObjectSize(AnyObjectId objectId, int typeHint) throws MissingObjectException, IncorrectObjectTypeException, IOException
      Description copied from class: ObjectReader
      Get only the size of an object.

      The default implementation of this method opens an ObjectLoader. Databases are encouraged to override this if a faster access method is available to them.

      Overrides:
      getObjectSize in class ObjectReader
      Parameters:
      objectId - identity of the object to open.
      typeHint - hint about the type of object being requested, e.g. Constants.OBJ_BLOB; ObjectReader.OBJ_ANY if the object type is not known, or does not matter to the caller.
      Returns:
      size of object in bytes.
      Throws:
      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.
    • getObjectSize

      public <T extends ObjectId> AsyncObjectSizeQueue<T> getObjectSize(Iterable<T> objectIds, boolean reportMissing)
      Description copied from class: ObjectReader
      Asynchronous object size lookup.
      Overrides:
      getObjectSize in class ObjectReader
      Parameters:
      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.
      Returns:
      queue to read object sizes from.
    • setAvoidUnreachableObjects

      public void setAvoidUnreachableObjects(boolean avoid)
      Description copied from class: ObjectReader
      Advise the reader to avoid unreachable objects.

      While enabled the reader will skip over anything previously proven to be unreachable. This may be dangerous in the face of concurrent writes.

      Overrides:
      setAvoidUnreachableObjects in class ObjectReader
      Parameters:
      avoid - true to avoid unreachable objects.
    • getBitmapIndex

      public BitmapIndex getBitmapIndex() throws IOException
      Description copied from class: ObjectReader
      An index that can be used to speed up ObjectWalks.
      Overrides:
      getBitmapIndex in class ObjectReader
      Returns:
      the index or null if one does not exist.
      Throws:
      IOException - when the index fails to load
    • getCreatedFromInserter

      @Nullable public ObjectInserter getCreatedFromInserter()
      Description copied from class: ObjectReader
      Get the ObjectInserter from which this reader was created using inserter.newReader()
      Overrides:
      getCreatedFromInserter in class ObjectReader
      Returns:
      the ObjectInserter from which this reader was created using inserter.newReader(), or null if this reader was not created from an inserter.
    • close

      public void close()
      Description copied from class: ObjectReader

      Release any resources used by this reader.

      A reader that has been released can be used again, but may need to be released after the subsequent usage.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in class ObjectReader