Renamed from arcdb: module path, cmd/archer, internal/archererr, docs, build scripts and ARCHER_* environment variables. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2.1 KiB
2.1 KiB
1. 依赖与压缩器
- 1.1
go get github.com/ulikunitz/xz@v0.5.17,更新go.mod/go.sum - 1.2
Compressor增加Level字段;NewCompressor(name string, level int)接受档位 - 1.3 实现档位映射:gzip 直传 1–9;zstd 按 1-2 fastest / 3-5 default / 6-8 better / 9 best;xz 按字典表 1/2/4/4/8/8/16/32/64 MiB
- 1.4 xz writer 使用
xz.WriterConfig{DictCap: ...};reader 固定DictCap 64 MiB并保留多 stream 解码
2. CLI
- 2.1
cli/config.go:CompressLevel int,默认 3 - 2.2
cli/parse.go:注册--compress-level,help 标注 1–9 - 2.3
cli/validate.go:档位必须在 1–9;--compress none且档位非 3 时报配置错误 - 2.4
cli/hash.go:仅当compress != none && level != 3时加入compress_level
3. 装配与扩展名收敛
- 3.1
app/app.go:用NewCompressor(cfg.Compress, cfg.CompressLevel)构造 - 3.2
app/dryrun.go:输出压缩档位;删除compressExt(),改用Compressor.Ext
4. 崩溃恢复
- 4.1
shard/manifest.go:shardNameRE增加\.xz,Adopt能识别 xz 分片并计入序号
5. 测试
- 5.1 档位映射边界单测(含 gzip/zstd/xz 与非法档位)
- 5.2
shard/writer_test.go的压缩往返循环加入xz - 5.3 新增:
Checkpoint()后多 stream xz 分片能被完整读回 - 5.4 新增:无 manifest 记录的
.xz分片可被Adopt补录且不影响序号 - 5.5 CLI 测试:非法档位、
none+ 非默认档位、默认档位的指纹向后兼容、非默认档位变化被拒绝 - 5.6
app/integration_test.go:压缩循环加入xz,decompressFile增加 xz 分支
6. 文档
- 6.1
README.md:压缩选项加入 xz 与--compress-level,补档位表、xz 导入示例(xz -dc)与 xz 吞吐/空间定位说明
7. 验证
- 7.1
go test ./... - 7.2
go vet ./... - 7.3
openspec validate add-compress-level-and-xz --strict - 7.4 如有 MySQL 环境,跑一次
ARCHER_TEST_DSN=... go test ./internal/app -run TestIntegration -v