功能:增强 Schema 系统和添加新示例

- 扩展 Schema 支持更多数据类型(Duration、URL、JSON 等)
- 优化 SSTable 编码解码性能
- 添加多个新示例程序:
  - all_types: 展示所有支持的数据类型
  - new_types: 演示新增类型的使用
  - struct_tags: 展示结构体标签功能
  - time_duration: 时间和持续时间处理示例
- 完善测试用例和文档
- 优化代码结构和错误处理
This commit is contained in:
2025-10-10 00:20:45 +08:00
parent 6d04487789
commit 77087d36c6
41 changed files with 3008 additions and 452 deletions

View File

@@ -24,20 +24,20 @@ func StartWebUI(dbPath string, addr string) {
// 创建示例 Schema
userSchema, err := srdb.NewSchema("users", []srdb.Field{
{Name: "name", Type: srdb.FieldTypeString, Indexed: true, Comment: "User name"},
{Name: "email", Type: srdb.FieldTypeString, Indexed: false, Comment: "Email address"},
{Name: "age", Type: srdb.FieldTypeInt64, Indexed: false, Comment: "Age"},
{Name: "city", Type: srdb.FieldTypeString, Indexed: false, Comment: "City"},
{Name: "name", Type: srdb.String, Indexed: true, Comment: "User name"},
{Name: "email", Type: srdb.String, Indexed: false, Comment: "Email address"},
{Name: "age", Type: srdb.Int64, Indexed: false, Comment: "Age"},
{Name: "city", Type: srdb.String, Indexed: false, Comment: "City"},
})
if err != nil {
log.Fatal(err)
}
productSchema, err := srdb.NewSchema("products", []srdb.Field{
{Name: "product_name", Type: srdb.FieldTypeString, Indexed: true, Comment: "Product name"},
{Name: "price", Type: srdb.FieldTypeFloat, Indexed: false, Comment: "Price"},
{Name: "quantity", Type: srdb.FieldTypeInt64, Indexed: false, Comment: "Quantity"},
{Name: "category", Type: srdb.FieldTypeString, Indexed: false, Comment: "Category"},
{Name: "product_name", Type: srdb.String, Indexed: true, Comment: "Product name"},
{Name: "price", Type: srdb.Float64, Indexed: false, Comment: "Price"},
{Name: "quantity", Type: srdb.Int64, Indexed: false, Comment: "Quantity"},
{Name: "category", Type: srdb.String, Indexed: false, Comment: "Category"},
})
if err != nil {
log.Fatal(err)
@@ -140,10 +140,10 @@ func autoInsertData(db *srdb.Database) {
if !hasLogs {
logsSchema, err := srdb.NewSchema("logs", []srdb.Field{
{Name: "group", Type: srdb.FieldTypeString, Indexed: true, Comment: "Log group (A-E)"},
{Name: "timestamp", Type: srdb.FieldTypeString, Indexed: false, Comment: "Timestamp"},
{Name: "data", Type: srdb.FieldTypeString, Indexed: false, Comment: "Random data"},
{Name: "size_bytes", Type: srdb.FieldTypeInt64, Indexed: false, Comment: "Data size in bytes"},
{Name: "group", Type: srdb.String, Indexed: true, Comment: "Log group (A-E)"},
{Name: "timestamp", Type: srdb.String, Indexed: false, Comment: "Timestamp"},
{Name: "data", Type: srdb.String, Indexed: false, Comment: "Random data"},
{Name: "size_bytes", Type: srdb.Int64, Indexed: false, Comment: "Data size in bytes"},
})
if err != nil {
log.Fatal(err)