GeCondition.go 627 B

123456789101112131415161718192021222324252627282930
  1. package core
  2. import "TsDB2/DB/core/types"
  3. type GeCondition struct {
  4. Field string
  5. Value interface{}
  6. Type types.FieldType
  7. }
  8. func Ge(field string, value interface{}, typ types.FieldType) Condition {
  9. return GeCondition{Field: field, Value: value, Type: typ}
  10. }
  11. func (c GeCondition) Fields() []string {
  12. return []string{c.Field}
  13. }
  14. func (c GeCondition) 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.compareGreaterOrEqual(row, offset, c.Type, c.Value)
  24. }