Skip to content

Commit

Permalink
Checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
xichen2020 committed Jan 1, 2019
1 parent 11f1567 commit ba96aca
Show file tree
Hide file tree
Showing 7 changed files with 275 additions and 106 deletions.
17 changes: 17 additions & 0 deletions event/field/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package field

import (
"fmt"

"github.com/xichen2020/eventdb/event/field"
)

// ValueType is the type of a field value.
Expand Down Expand Up @@ -46,6 +48,21 @@ func (t ValueType) ConvertibleFrom() ([]ValueType, error) {
return nil, fmt.Errorf("unknown value type %v does not have comparable types", t)
}

// ValueTypeSet is a set of value types.
type ValueTypeSet map[field.ValueType]struct{}

// Clone clones a value type set.
func (m ValueTypeSet) Clone() ValueTypeSet {
if len(m) == 0 {
return nil
}
cloned := make(field.ValueTypeSet, len(m))
for k := range m {
cloned[k] = struct{}{}
}
return cloned
}

// ValueUnion is a value union.
type ValueUnion struct {
Type ValueType
Expand Down
2 changes: 2 additions & 0 deletions filter/bool_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ type BoolFilter interface {
Match(v bool) bool
}

type boolToBoolFilterFn func(bool) boolFilterFn

type boolFilterFn func(v bool) bool

func (fn boolFilterFn) Match(v bool) bool { return fn(v) }
Expand Down
13 changes: 8 additions & 5 deletions filter/double_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ import (
"math"
)

const (
// doubleEps is used to determine whether two floating point numbers are considered equal.
doubleEps = 1e-10
)

// DoubleFilter matches against double values.
type DoubleFilter interface {
// Match returns true if the given value is considered a match.
Match(v float64) bool
}

const (
// doubleEps is used to determine whether two floating point numbers are considered equal.
doubleEps = 1e-10
)

type doubleToDoubleFilterFn func(float64) doubleFilterFn
type intToDoubleFilterFn func(int) doubleFilterFn

type doubleFilterFn func(v float64) bool

func (fn doubleFilterFn) Match(v float64) bool { return fn(v) }
Expand Down
Loading

0 comments on commit ba96aca

Please sign in to comment.