> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cyborg.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Getter Functions

## is\_trained

```cpp theme={null}
bool is_trained() const;
```

Returns whether the index has been trained. Returns `true` only when the training state is
`Trained`. While a (re)train rebuild is in progress this returns `false`, and queries
transparently fall back to the untrained (exhaustive) search path. See
[`is_training`](#is_training) and [`training_state`](#training_state).

***

## is\_training

```cpp theme={null}
bool is_training() const;
```

Returns `true` while a (re)train rebuild is in progress, otherwise `false`.

***

## training\_state

```cpp theme={null}
TrainingState training_state() const;
```

Returns the current training state as a [`TrainingState`](./types#trainingstate) enum:
`Untrained`, `Training`, or `Trained`.

***

## index\_name

```cpp theme={null}
std::string index_name() const;
```

Returns the name of the index.

***

## index\_type

```cpp theme={null}
IndexType index_type() const;
```

Returns the type of the index as an [`IndexType`](./types#indextype) enum. The only value is
`DISK_IVF`.

***

## index\_config

```cpp theme={null}
IndexDiskIVF* index_config() const;
```

Returns a pointer to the index configuration ([`IndexDiskIVF`](./types#indexdiskivf)).

***

## ListIDs

```cpp theme={null}
std::vector<std::string> ListIDs(const KeyContext& key);
```

Returns a vector containing all item IDs currently stored in the index.

### Parameters

| Parameter | Type                               | Description                                                                                                      |
| --------- | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| `key`     | [`KeyContext`](./types#keycontext) | Key context for the operation. A bare 32-byte index key (the `index_key`) implicitly converts to a `KeyContext`. |

### Exceptions

* **std::runtime\_error**: Thrown if an error occurs during retrieval.

***

## NumVectors

```cpp theme={null}
size_t NumVectors(const KeyContext& key);
```

Returns the total number of vectors currently stored in the encrypted index.

### Parameters

| Parameter | Type                               | Description                                                                                                      |
| --------- | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| `key`     | [`KeyContext`](./types#keycontext) | Key context for the operation. A bare 32-byte index key (the `index_key`) implicitly converts to a `KeyContext`. |

### Returns

`size_t`: The number of vectors in the index.

### Exceptions

<AccordionGroup>
  <Accordion title="std::runtime_error">
    * Throws if the index was not created or loaded yet.
    * Throws if an error occurs while retrieving the count.
  </Accordion>
</AccordionGroup>

### Example Usage

```cpp theme={null}
// Get the number of vectors in the index
size_t vector_count = index->NumVectors(index_key);
std::cout << "Index contains " << vector_count << " vectors" << std::endl;

// Use count for validation or progress reporting
if (vector_count == 0) {
    std::cout << "Index is empty, consider adding vectors" << std::endl;
}
```

<Tip>`index_key` is the 32-byte `std::array<uint8_t, 32>` index KEK and converts implicitly to a `KeyContext`.</Tip>
