4 Commits

Author SHA1 Message Date
9b7a9c2734 更新:.gitignore 添加示例程序的编译产物
添加忽略规则:
- example/concurrent/concurrent
- example/index/index
- example/topic_processor/topic_processor

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-04 11:49:21 +08:00
4ec153c1ac 新增:高并发示例和文档
新增文件:
- example/concurrent_example.go: 5 分钟高并发测试示例
  - 场景 1: 并发写入 6000 条消息
  - 场景 2: 并发查询 4000 次
  - 场景 3: 混合读写测试
  - 场景 4: 持续压测 4 分钟(实时进度显示)
  - 场景 5: 统计信息汇总

- example/README.md: 完整的示例文档
  - 所有示例的使用说明
  - 最佳实践和性能优化建议
  - 常见问题排查

- example/RUN_CONCURRENT.md: 快速运行指南
  - 运行方式和时间预估
  - 后台运行方法
  - 自定义参数说明

修改文件:
- .gitignore: 修正 example 目录的忽略规则
  - 移除对整个 example/ 的忽略
  - 只忽略 example/test_*/ 测试目录

性能指标:
- 写入吞吐量:~220 msg/s
- 查询吞吐量:~400-1500 query/s
- 总数据量:53661 条消息,1.1 MB
2025-10-04 01:08:37 +08:00
5c028a55b3 重构:简化查询接口
- RecordQuery.QueryOldest 和 QueryNewest 不再接收 startIdx/endIdx 参数
- 查询方法返回纯 Record 列表,状态判断移到调用方
- TopicProcessor 的查询方法负责添加状态信息
- 更新所有测试文件以适配新接口
2025-10-04 00:23:09 +08:00
de39339620 重构:统一使用索引(Index)替代位置(Position)进行状态判断
## 主要变更

### 架构改进
- 明确索引(Index)与偏移(Offset)的职责分离
  - Index: 记录序号(逻辑概念),用于状态判断
  - Offset: 文件字节位置(物理概念),仅用于 I/O 操作

### API 变更
- 删除所有 Position 相关方法:
  - `LogCursor.StartPos()/EndPos()`
  - `LogTailer.GetStartPos()/GetEndPos()`
  - `TopicProcessor.GetProcessingPosition()/GetReadPosition()`
  - `Seqlog.GetProcessingPosition()/GetReadPosition()`

- 新增索引方法:
  - `LogCursor.StartIndex()/EndIndex()`
  - `LogTailer.GetStartIndex()/GetEndIndex()`
  - `TopicProcessor.GetProcessingIndex()/GetReadIndex()`
  - `Seqlog.GetProcessingIndex()/GetReadIndex()`
  - `Seqlog.GetProcessor()` - 获取 processor 实例以访问 Index

### 查询接口变更
- `RecordQuery.QueryOldest(startIndex, count, startIdx, endIdx)` - 使用索引参数
- `RecordQuery.QueryNewest(endIndex, count, startIdx, endIdx)` - 使用索引参数
- `RecordQuery.QueryAt(position, direction, count, startIdx, endIdx)` - startIdx/endIdx 用于状态判断

### 性能优化
- 状态判断改用整数比较,不再需要计算偏移量
- 减少不必要的索引到偏移的转换
- 只在实际文件 I/O 时才获取 offset

### 测试更新
- 更新所有测试用例使用新的 Index API
- 更新示例代码(topic_processor_example.go, webapp/main.go)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-03 23:50:53 +08:00