Record Class CompactionResult

java.lang.Object
java.lang.Record
com.tnsai.context.compaction.CompactionResult

public record CompactionResult(List<Map<String,Object>> messages, int originalMessageCount, int compactedMessageCount, int summarizedMessageCount, int originalTokens, int compactedTokens, String summary, boolean compactionPerformed) extends Record
Result of a context compaction operation.

Contains the compacted message list and metadata about the compaction.

Author:
TnsAI Team
  • Constructor Details

    • CompactionResult

      public CompactionResult(List<Map<String,Object>> messages, int originalMessageCount, int compactedMessageCount, int summarizedMessageCount, int originalTokens, int compactedTokens, String summary, boolean compactionPerformed)
      Creates an instance of a CompactionResult record class.
      Parameters:
      messages - the value for the messages record component
      originalMessageCount - the value for the originalMessageCount record component
      compactedMessageCount - the value for the compactedMessageCount record component
      summarizedMessageCount - the value for the summarizedMessageCount record component
      originalTokens - the value for the originalTokens record component
      compactedTokens - the value for the compactedTokens record component
      summary - the value for the summary record component
      compactionPerformed - the value for the compactionPerformed record component
  • Method Details

    • noCompaction

      public static CompactionResult noCompaction(List<Map<String,Object>> messages, int tokenCount)
      Creates a result indicating no compaction was needed.
    • success

      public static CompactionResult success(List<Map<String,Object>> compactedMessages, int originalCount, int summarizedCount, int originalTokens, int compactedTokens, String summary)
      Creates a result for successful compaction.
    • tokenReductionRatio

      public double tokenReductionRatio()
      Returns the token reduction ratio.
      Returns:
      reduction ratio (0.0-1.0), higher is better
    • messageReduction

      public int messageReduction()
      Returns the message reduction count.
      Returns:
      number of messages removed
    • 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 '=='.
      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.
    • messages

      public List<Map<String,Object>> messages()
      Returns the value of the messages record component.
      Returns:
      the value of the messages record component
    • originalMessageCount

      public int originalMessageCount()
      Returns the value of the originalMessageCount record component.
      Returns:
      the value of the originalMessageCount record component
    • compactedMessageCount

      public int compactedMessageCount()
      Returns the value of the compactedMessageCount record component.
      Returns:
      the value of the compactedMessageCount record component
    • summarizedMessageCount

      public int summarizedMessageCount()
      Returns the value of the summarizedMessageCount record component.
      Returns:
      the value of the summarizedMessageCount record component
    • originalTokens

      public int originalTokens()
      Returns the value of the originalTokens record component.
      Returns:
      the value of the originalTokens record component
    • compactedTokens

      public int compactedTokens()
      Returns the value of the compactedTokens record component.
      Returns:
      the value of the compactedTokens record component
    • summary

      public String summary()
      Returns the value of the summary record component.
      Returns:
      the value of the summary record component
    • compactionPerformed

      public boolean compactionPerformed()
      Returns the value of the compactionPerformed record component.
      Returns:
      the value of the compactionPerformed record component