Record Class BlobIndex

java.lang.Object
java.lang.Record
network.ike.docs.plugin.registry.BlobIndex
Record Components:
blobs - the files, path to blob id, iterating in path order
findings - what the index could not take: a symbolic link, prefixed with the path it concerns
source - where the ids came from

public record BlobIndex(Map<String,String> blobs, List<String> findings, BlobIndex.Source source) extends Record
Every .adoc file under a registry root with the git blob id of its content: the key the incremental registry decides staleness by (dev-adoc-packages, IKE-Network/ike-issues#1341). Dates are the wrong key, since a checkout, a rebase, a sync between machines or a restored file all change dates without changing content; the blob id addresses the content itself, and git already keeps it for every tracked file. GitBlobIndex reads it from git without opening a file; hashed(Path) is the fallback for a tree without git, which reads every file once to compute the same id, so the two never disagree about an unchanged file.

Paths are relative to the root with / separators, in path order, with the directories TopicRegistry.SKIPPED_DIRS left out, as the full scan leaves them out. A symbolic link is never followed; it is a finding instead, as it is in the full scan.

Since:
136
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Where a BlobIndex took its blob ids from.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BlobIndex(Map<String,String> blobs, List<String> findings, BlobIndex.Source source)
    Creates an instance of a BlobIndex record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    blobId(byte[] content)
    The git blob id of content: the SHA-1 of "blob <length>\0" followed by the bytes, as git hash-object computes it for a file with no clean filter.
    Returns the value of the blobs record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the findings record component.
    final int
    Returns a hash code value for this object.
    static BlobIndex
    hashed(Path root)
    Index a root by reading every .adoc file under it and hashing the content as git hashes a blob ("blob " + length + NUL + content, SHA-1).
    Returns the value of the source record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • BlobIndex

      public BlobIndex(Map<String,String> blobs, List<String> findings, BlobIndex.Source source)
      Creates an instance of a BlobIndex record class.
      Parameters:
      blobs - the value for the blobs record component
      findings - the value for the findings record component
      source - the value for the source record component
  • Method Details

    • hashed

      public static BlobIndex hashed(Path root) throws IOException
      Index a root by reading every .adoc file under it and hashing the content as git hashes a blob ("blob " + length + NUL + content, SHA-1). This is the full scan's cost, paid when git is not there to answer for free.
      Parameters:
      root - the registry root
      Returns:
      the index
      Throws:
      IOException - if the tree cannot be read
    • blobId

      public static String blobId(byte[] content)
      The git blob id of content: the SHA-1 of "blob <length>\0" followed by the bytes, as git hash-object computes it for a file with no clean filter.
      Parameters:
      content - the file content
      Returns:
      the forty-character lowercase hex id
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • blobs

      public Map<String,String> blobs()
      Returns the value of the blobs record component.
      Returns:
      the value of the blobs record component
    • findings

      public List<String> findings()
      Returns the value of the findings record component.
      Returns:
      the value of the findings record component
    • source

      public BlobIndex.Source source()
      Returns the value of the source record component.
      Returns:
      the value of the source record component