EqCondition.go 617 B

1234567891011121314151617181920212223242526272829
  1. package core
  2. import "TsDB2/DB/core/types"
  3. type EqCondition struct {
  4. Field string
  5. Value interface{}
  6. Type types.FieldType
  7. }
  8. func Eq(field string, value interface{}, typ types.FieldType) Condition {
  9. return EqCondition{Field: field, Value: value, Type: typ}
  10. }
  11. func (c EqCondition) Fields() []string {
  12. return []string{c.Field}
  13. }
  14. func (c EqCondition) Match(row []byte, table *Table) bool {
  15. fieldIdx := table.findFieldIndex(c.Field)
  16. if fieldIdx < 0 {
  17. return false
  18. }
  19. offset, ok := table.getVersionedOffset(row, fieldIdx)
  20. if !ok {
  21. return false
  22. }
  23. return table.compareValue(row, offset, c.Type, c.Value)
  24. }