Skip to content

Commit eab4a10

Browse files
chore: add missing ChangeType enum and doc in C++. Add test coverage for ChangeType in integration test. (#334)
1 parent a950ca9 commit eab4a10

1 file changed

Lines changed: 33 additions & 6 deletions

File tree

website/docs/user-guide/cpp/api-reference.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,14 @@ When using `table.NewRow()`, the `Set()` method auto-routes to the correct type
226226

227227
## `ScanRecord`
228228

229-
| Field | Type | Description |
230-
|-------------|--------------|-------------------------------|
231-
| `bucket_id` | `int32_t` | Bucket this record belongs to |
232-
| `offset` | `int64_t` | Record offset in the log |
233-
| `timestamp` | `int64_t` | Record timestamp |
234-
| `row` | `GenericRow` | Row data |
229+
| Field | Type | Description |
230+
|----------------|--------------------------|---------------------------------------------------------------------|
231+
| `bucket_id` | `int32_t` | Bucket this record belongs to |
232+
| `partition_id` | `std::optional<int64_t>` | Partition ID (present only for partitioned tables) |
233+
| `offset` | `int64_t` | Record offset in the log |
234+
| `timestamp` | `int64_t` | Record timestamp |
235+
| `change_type` | `ChangeType` | Change type (AppendOnly, Insert, UpdateBefore, UpdateAfter, Delete) |
236+
| `row` | `RowView` | Row data |
235237

236238
## `ScanRecords`
237239

@@ -450,6 +452,31 @@ scanner.Subscribe(0, offsets[0]);
450452
451453
## Enums
452454
455+
### `ChangeType`
456+
457+
| Value | Short String | Description |
458+
|----------------|--------------|----------------------------------|
459+
| `AppendOnly` | `+A` | Append-only record |
460+
| `Insert` | `+I` | Inserted row |
461+
| `UpdateBefore` | `-U` | Previous value of an updated row |
462+
| `UpdateAfter` | `+U` | New value of an updated row |
463+
| `Delete` | `-D` | Deleted row |
464+
465+
You may refer to the following example to convert ChangeType enum to its short string representation.
466+
467+
```cpp
468+
inline const char* ChangeTypeShortString(ChangeType ct) {
469+
switch (ct) {
470+
case ChangeType::AppendOnly: return "+A";
471+
case ChangeType::Insert: return "+I";
472+
case ChangeType::UpdateBefore: return "-U";
473+
case ChangeType::UpdateAfter: return "+U";
474+
case ChangeType::Delete: return "-D";
475+
}
476+
throw std::invalid_argument("Unknown ChangeType");
477+
}
478+
```
479+
453480
### `TypeId`
454481

455482
| Value | Description |

0 commit comments

Comments
 (0)