Package com.tnsai.context.compaction
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of thecompactedMessageCountrecord component.intReturns the value of thecompactedTokensrecord component.booleanReturns the value of thecompactionPerformedrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intReturns the message reduction count.messages()Returns the value of themessagesrecord component.static CompactionResultnoCompaction(List<Map<String, Object>> messages, int tokenCount) Creates a result indicating no compaction was needed.intReturns the value of theoriginalMessageCountrecord component.intReturns the value of theoriginalTokensrecord component.static CompactionResultsuccess(List<Map<String, Object>> compactedMessages, int originalCount, int summarizedCount, int originalTokens, int compactedTokens, String summary) Creates a result for successful compaction.intReturns the value of thesummarizedMessageCountrecord component.summary()Returns the value of thesummaryrecord component.doubleReturns the token reduction ratio.final StringtoString()Returns a string representation of this record class.
-
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 aCompactionResultrecord class.- Parameters:
messages- the value for themessagesrecord componentoriginalMessageCount- the value for theoriginalMessageCountrecord componentcompactedMessageCount- the value for thecompactedMessageCountrecord componentsummarizedMessageCount- the value for thesummarizedMessageCountrecord componentoriginalTokens- the value for theoriginalTokensrecord componentcompactedTokens- the value for thecompactedTokensrecord componentsummary- the value for thesummaryrecord componentcompactionPerformed- the value for thecompactionPerformedrecord component
-
-
Method Details
-
noCompaction
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
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
messages
Returns the value of themessagesrecord component.- Returns:
- the value of the
messagesrecord component
-
originalMessageCount
public int originalMessageCount()Returns the value of theoriginalMessageCountrecord component.- Returns:
- the value of the
originalMessageCountrecord component
-
compactedMessageCount
public int compactedMessageCount()Returns the value of thecompactedMessageCountrecord component.- Returns:
- the value of the
compactedMessageCountrecord component
-
summarizedMessageCount
public int summarizedMessageCount()Returns the value of thesummarizedMessageCountrecord component.- Returns:
- the value of the
summarizedMessageCountrecord component
-
originalTokens
public int originalTokens()Returns the value of theoriginalTokensrecord component.- Returns:
- the value of the
originalTokensrecord component
-
compactedTokens
public int compactedTokens()Returns the value of thecompactedTokensrecord component.- Returns:
- the value of the
compactedTokensrecord component
-
summary
Returns the value of thesummaryrecord component.- Returns:
- the value of the
summaryrecord component
-
compactionPerformed
public boolean compactionPerformed()Returns the value of thecompactionPerformedrecord component.- Returns:
- the value of the
compactionPerformedrecord component
-