GeCondition.go 580 B

123456789101112131415161718192021222324252627
  1. package DB
  2. import "TsDB2/DB/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 := table.calcFieldOffset(fieldIdx)
  20. return table.compareGreaterOrEqual(row, offset, c.Type, c.Value)
  21. }