Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions runtime/vam/expr/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,7 @@ func (o *Or) eval(vecs ...vector.Any) vector.Any {
if _, ok := rhs.(*vector.Error); ok {
return o.orError(rhs, lhs)
}
blhs, brhs := toBool(lhs), toBool(rhs)
bits := bitvec.Or(blhs.Bits, brhs.Bits)
if blhs.Nulls.IsZero() && brhs.Nulls.IsZero() {
// Fast path involves no nulls.
return vector.NewBool(bits, bitvec.Zero)
}
nulls := bitvec.Or(blhs.Nulls, brhs.Nulls)
nulls = bitvec.And(bitvec.Not(bits), nulls)
return vector.NewBool(bits, nulls)
return vector.Or(toBool(lhs), toBool(rhs))
}

func (o *Or) orError(err, vec vector.Any) vector.Any {
Expand Down
12 changes: 8 additions & 4 deletions vector/bool.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ func (b *Bool) Serialize(builder *scode.Builder, slot uint32) {
}
}

// Or is a simple case of logical-or where we don't care about nulls in
// the input (presuming the corresponding bits to be false) and we return
// the or'd result as a boolean vector without nulls.
func Or(a, b *Bool) *Bool {
return NewBool(bitvec.Or(a.Bits, b.Bits), bitvec.Zero)
bits := bitvec.Or(a.Bits, b.Bits)
if a.Nulls.IsZero() && b.Nulls.IsZero() {
// Fast path involves no nulls.
return NewBool(bits, bitvec.Zero)
}
nulls := bitvec.Or(a.Nulls, b.Nulls)
nulls = bitvec.And(bitvec.Not(bits), nulls)
return NewBool(bits, nulls)
}

// BoolValue returns the value of slot in vec if the value is a Boolean. It
Expand Down