| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package core
- import "git.ycl.pub/yl32940/TsDB2/DB/core/types"
- type EqCondition struct {
- Field string
- Value interface{}
- // Deprecated: 已不参与比较 —— 行级过滤与索引路径都按【列的实际存储类型】编字节
- // (见 Table.compareColTypeFor)。它只剩"值怎么从 interface{} 取出"的提示作用,
- // 传任何值结果都一样; 保留仅为兼容既有调用方, 新代码传 0 即可。
- Type types.FieldType
- }
- // Eq 构造 "field = value" 条件。
- //
- // 第三个参数 typ 已废弃: 比较一律按列的实际存储类型进行 (见 Table.compareColTypeFor),
- // 它取任何值结果都一样, 传 types.FieldType(0) 即可。
- // 上面刻意不写成 "Deprecated:" 段落 —— Go 只能标记整个标识符废弃, 写了会把本函数
- // 一起判为废弃, 而本函数还要继续用。
- func Eq(field string, value interface{}, typ types.FieldType) Condition {
- return EqCondition{Field: field, Value: value, Type: typ}
- }
- func (c EqCondition) Fields() []string {
- return []string{c.Field}
- }
- func (c EqCondition) Match(row []byte, table *Table) bool {
- fieldIdx := table.findFieldIndex(c.Field)
- if fieldIdx < 0 {
- return false
- }
- // 比较类型与列级参数一律取列的实际定义 (声明类型已废弃), 与索引路径编键同源。
- ct := table.compareColTypeFor(fieldIdx)
- // 定位列并把行内【实际长度】的字节补齐到档位宽度 (v9 行是变长的, 条件值仍按档位编码)。
- seg, ok := table.rowFieldForCompare(row, fieldIdx, ct)
- if !ok {
- return false
- }
- return table.compareValue(seg, ct, c.Value)
- }
|