feat: 更新 sstable 并新增 examples/complex 示例
This commit is contained in:
28
sstable.go
28
sstable.go
@@ -770,6 +770,13 @@ func readFieldBinaryValue(buf *bytes.Reader, typ FieldType, keep bool) (any, err
|
||||
if err := binary.Read(buf, binary.LittleEndian, &length); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if length == 0 {
|
||||
// 空字符串,直接返回
|
||||
if keep {
|
||||
return "", nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
str := make([]byte, length)
|
||||
if _, err := buf.Read(str); err != nil {
|
||||
return nil, err
|
||||
@@ -796,6 +803,13 @@ func readFieldBinaryValue(buf *bytes.Reader, typ FieldType, keep bool) (any, err
|
||||
if err := binary.Read(buf, binary.LittleEndian, &length); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if length == 0 {
|
||||
// 零值 Decimal
|
||||
if keep {
|
||||
return decimal.Zero, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
data := make([]byte, length)
|
||||
if _, err := buf.Read(data); err != nil {
|
||||
return nil, err
|
||||
@@ -839,6 +853,13 @@ func readFieldBinaryValue(buf *bytes.Reader, typ FieldType, keep bool) (any, err
|
||||
if err := binary.Read(buf, binary.LittleEndian, &length); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if length == 0 {
|
||||
// 空对象
|
||||
if keep {
|
||||
return map[string]any{}, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
data := make([]byte, length)
|
||||
if _, err := buf.Read(data); err != nil {
|
||||
return nil, err
|
||||
@@ -858,6 +879,13 @@ func readFieldBinaryValue(buf *bytes.Reader, typ FieldType, keep bool) (any, err
|
||||
if err := binary.Read(buf, binary.LittleEndian, &length); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if length == 0 {
|
||||
// 空数组
|
||||
if keep {
|
||||
return []any{}, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
data := make([]byte, length)
|
||||
if _, err := buf.Read(data); err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user