Skip to content

Inspect segments

For the complete documentation index see: llms.txt

All documentation pages available in markdown.

On the previous page, you loaded full or partial history from a long session. The inspection phase that follows in your script output reports how many segment records were created and how events were distributed across them. Recall that the session row stores the current segment index in its cur bin. Each segment record holds one slice of event history.

Keep the terminal open if the script is still running from the previous page.

Review the inspection phase output

  1. Find the inspection section in your terminal output:

    After the read lines, the script inspects the session row and counts events per segment:

    infinite-chat-history-demo.py
    _, _, sbins = client.select(pk, ["cur", "state"])
    cur = int(sbins.get("cur", 0))
    n_segs, sizes = summarize_segments(client, cur)
    print(
    f"session record — cur={cur}, segments={n_segs}, "
    f"events_in_segments={sum(sizes)}, "
    f"session_state_keys={len(sbins.get('state') or {})}"
    )
    listed = await session_service.list_sessions(app_name=APP, user_id=USER)
    print(f"list_sessions: {[s.id for s in listed.sessions]}")
    session record — cur=26, segments=27, events_in_segments=20000, session_state_keys=1
    segment sizes (first 3): [757, 756, 756] ... (last 3): [755, 755, 355]
    list_sessions: ['session-1']
    Connection closed.
  2. Confirm segment rollover:

    Segment rollover is what happens when a segment record fills up. The service starts writing new events to the next segment and updates cur on the session row. Earlier segments stay unchanged.

    The append phase packed events until each segment record reached the namespace write limit, then opened the next segment. The inspection phase reads the cur bin from the session row and counts events in each segment record.

    • events_in_segments equals 20,000 across all segment records.
    • segments is greater than one, confirming overflow-driven rollover occurred.
    • list_sessions returns ['session-1'].
    • Segment sizes in the middle pack near the write limit (~755 events). The last segment is smaller (remainder events).

Explore the demo source in the adk-aerospike repository for the full step-by-step code walkthrough.

Feedback

Was this page helpful?

What type of feedback are you giving?

What would you like us to know?

+Capture screenshot

Can we reach out to you?