Record Class SessionMemoryEntity.State
- Enclosing class:
SessionMemoryEntity
-
Constructor Summary
ConstructorsConstructorDescriptionState(String sessionId, long maxSizeInBytes, long currentSizeInBytes, List<SessionMessage> messages) State(String sessionId, long maxSizeInBytes, long currentSizeInBytes, List<SessionMessage> messages, SessionMessage.TokenUsage tokenUsage, boolean truncated, long compactionSeqNr) Creates an instance of aStaterecord class. -
Method Summary
Modifier and TypeMethodDescriptionaddMessage(SessionMessage message) clear()Reset the in-memory history on deletion.compact(long compactedAtSeqNr) Reset the in-memory history but record the journal sequence number where compaction took place, so a subsequent chunked read from the journal can skip the events that were superseded by the compaction summary.longReturns the value of thecompactionSeqNrrecord component.longReturns the value of thecurrentSizeInBytesrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanisEmpty()longReturns the value of themaxSizeInBytesrecord component.messages()Returns the value of themessagesrecord component.Returns the value of thesessionIdrecord component.Returns the value of thetokenUsagerecord component.final StringtoString()Returns a string representation of this record class.booleanReturns the value of thetruncatedrecord component.withMaxSize(int newMaxSize)
-
Constructor Details
-
State
public State(String sessionId, long maxSizeInBytes, long currentSizeInBytes, List<SessionMessage> messages) -
State
public State(String sessionId, long maxSizeInBytes, long currentSizeInBytes, List<SessionMessage> messages, SessionMessage.TokenUsage tokenUsage, boolean truncated, long compactionSeqNr) Creates an instance of aStaterecord class.- Parameters:
sessionId- the value for thesessionIdrecord componentmaxSizeInBytes- the value for themaxSizeInBytesrecord componentcurrentSizeInBytes- the value for thecurrentSizeInBytesrecord componentmessages- the value for themessagesrecord componenttokenUsage- the value for thetokenUsagerecord componenttruncated- the value for thetruncatedrecord componentcompactionSeqNr- the value for thecompactionSeqNrrecord component
-
-
Method Details
-
isEmpty
public boolean isEmpty() -
withMaxSize
-
addMessage
-
clear
Reset the in-memory history on deletion.On entity deletion, the entity is kept around for some time before being purged, can still serve reads, and rejects any further persists. After this reset
getHistoryreturns an empty session, so the agent sees no context and never falls back to a chunked journal read. We therefore have nothing to anchor with a journal sequence number here: thecompactionSeqNrcarried by any prior compaction is no longer relevant on a deleted entity, and is reset to0along with the rest of the state. -
compact
Reset the in-memory history but record the journal sequence number where compaction took place, so a subsequent chunked read from the journal can skip the events that were superseded by the compaction summary.Clears the
truncatedflag: the compaction summary plus a chunked read fromcompactedAtSeqNrcan rebuild the full history losslessly, so the entity is no longer in a lossy state from the caller's perspective. If the post-compaction history later overflows again,State(java.lang.String, long, long, java.util.List<akka.javasdk.agent.SessionMessage>, akka.javasdk.agent.SessionMessage.TokenUsage, boolean, long)will settruncatedback totrue. -
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 '=='. -
sessionId
Returns the value of thesessionIdrecord component.- Returns:
- the value of the
sessionIdrecord component
-
maxSizeInBytes
public long maxSizeInBytes()Returns the value of themaxSizeInBytesrecord component.- Returns:
- the value of the
maxSizeInBytesrecord component
-
currentSizeInBytes
public long currentSizeInBytes()Returns the value of thecurrentSizeInBytesrecord component.- Returns:
- the value of the
currentSizeInBytesrecord component
-
messages
Returns the value of themessagesrecord component.- Returns:
- the value of the
messagesrecord component
-
tokenUsage
Returns the value of thetokenUsagerecord component.- Returns:
- the value of the
tokenUsagerecord component
-
truncated
public boolean truncated()Returns the value of thetruncatedrecord component.- Returns:
- the value of the
truncatedrecord component
-
compactionSeqNr
public long compactionSeqNr()Returns the value of thecompactionSeqNrrecord component.- Returns:
- the value of the
compactionSeqNrrecord component
-