| 1234567891011121314151617181920212223242526272829303132333435 |
- package core
- import "TsDB2/DB/core/types"
- type InCondition struct {
- Field string
- Values []interface{}
- Type types.FieldType
- }
- func In(field string, values []interface{}, typ types.FieldType) Condition {
- return InCondition{Field: field, Values: values, Type: typ}
- }
- func (c InCondition) Fields() []string {
- return []string{c.Field}
- }
- func (c InCondition) Match(row []byte, table *Table) bool {
- fieldIdx := table.findFieldIndex(c.Field)
- if fieldIdx < 0 {
- return false
- }
- offset, ok := table.getVersionedOffset(row, fieldIdx)
- if !ok {
- return false
- }
- for _, value := range c.Values {
- if table.compareValue(row, offset, c.Type, value) {
- return true
- }
- }
- return false
- }
|