Record Class OllamaPullProgress

java.lang.Object
java.lang.Record
uno.anahata.asi.ollama.OllamaPullProgress
Record Components:
status - the current progress status description (e.g., "pulling manifest", "downloading", "verifying sha256 digest")
digest - the sha256 digest of the layer currently being downloaded
total - the total size in bytes of the current layer
completed - the number of bytes downloaded so far
error - the error message if the pull operation failed

public record OllamaPullProgress(String status, String digest, long total, long completed, String error) extends Record
Immutable record representing download and verification progress reported by Ollama's /api/pull endpoint.
Author:
anahata
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final long
    The field for the completed record component.
    private final String
    The field for the digest record component.
    private final String
    The field for the error record component.
    private final String
    The field for the status record component.
    private final long
    The field for the total record component.
  • Constructor Summary

    Constructors
    Constructor
    Description
    OllamaPullProgress(String status, String digest, long total, long completed, String error)
    Creates an instance of a OllamaPullProgress record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the value of the completed record component.
    Returns the value of the digest record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the error record component.
    fromNode(com.fasterxml.jackson.databind.JsonNode node)
    Parses an Ollama pull progress event from an SSE JSON chunk.
    int
    Calculates the completion percentage for the current layer.
    final int
    Returns a hash code value for this object.
    Returns the value of the status record component.
    final String
    Returns a string representation of this record class.
    long
    Returns the value of the total record component.

    Methods inherited from class Object

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

    • status

      private final String status
      The field for the status record component.
    • digest

      private final String digest
      The field for the digest record component.
    • total

      private final long total
      The field for the total record component.
    • completed

      private final long completed
      The field for the completed record component.
    • error

      private final String error
      The field for the error record component.
  • Constructor Details

    • OllamaPullProgress

      public OllamaPullProgress(String status, String digest, long total, long completed, String error)
      Creates an instance of a OllamaPullProgress record class.
      Parameters:
      status - the value for the status record component
      digest - the value for the digest record component
      total - the value for the total record component
      completed - the value for the completed record component
      error - the value for the error record component
  • Method Details

    • getPercent

      public int getPercent()
      Calculates the completion percentage for the current layer.
      Returns:
      the percentage from 0 to 100, or -1 if the total byte count is unknown
    • fromNode

      public static OllamaPullProgress fromNode(com.fasterxml.jackson.databind.JsonNode node)
      Parses an Ollama pull progress event from an SSE JSON chunk.
      Parameters:
      node - the JSON node received from the stream
      Returns:
      a populated OllamaPullProgress instance
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      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.
    • status

      public String status()
      Returns the value of the status record component.
      Returns:
      the value of the status record component
    • digest

      public String digest()
      Returns the value of the digest record component.
      Returns:
      the value of the digest record component
    • total

      public long total()
      Returns the value of the total record component.
      Returns:
      the value of the total record component
    • completed

      public long completed()
      Returns the value of the completed record component.
      Returns:
      the value of the completed record component
    • error

      public String error()
      Returns the value of the error record component.
      Returns:
      the value of the error record component