---
title: "Inspect segments"
description: "Read cur, segment counts, and list_sessions to verify rollover after 20,000 appends."
---

# Inspect segments

> For the complete documentation index see: [llms.txt](https://aerospike.com/docs/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
    
    ```python
    _, _, 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]}")
    ```
    
    ```text
    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).

::: note
Your segment count and per-segment sizes may differ by hardware. You will still see 20,000 events total across all segments, more than one segment after this append load, and the same read results from the previous page.
:::

Explore the demo source in the [adk-aerospike repository](https://github.com/aerospike-community/adk-aerospike/tree/main/docs/tutorials) for the full step-by-step code walkthrough.

::: undefined
-   I’ve verified cur and segment counts sum to 20,000 events.
-   I’ve confirmed list\_sessions returns the session ID.
:::

[Previous  
Full and recent reads](https://aerospike.com/docs/develop/adk-infinite-chat-history/step/4/part/0/full-and-recent-reads) [Next  
Wrap up](https://aerospike.com/docs/develop/adk-infinite-chat-history/step/5/part/0/wrap-up)