-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vam: type value comparisons #5495
Conversation
runtime/vam/expr/gencomparefuncs.go
Outdated
if !(op == "==" || op == "!=") && typ == "TypeValue" { | ||
s += "return vector.NewConst(super.False, lhs.Len(), nil)\n}\n" | ||
return s | ||
} | ||
s += genVarInit("l", typ, lhs) | ||
s += genVarInit("r", typ, rhs) | ||
lexpr := genExpr("l", lhs) | ||
rexpr := genExpr("r", rhs) | ||
if typ == "Bytes" { | ||
if typ == "Bytes" || typ == "TypeValue" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should match what happens on the other side of the fence.
super/runtime/sam/expr/sort.go
Lines 205 to 211 in 3d706f2
case aid == super.IDType: | |
zctx := super.NewContext() // XXX This is expensive. | |
// XXX This isn't cheap eventually we should add | |
// super.CompareTypeValues(a, b zcode.Bytes). | |
av, _ := zctx.DecodeTypeValue(a.Bytes()) | |
bv, _ := zctx.DecodeTypeValue(b.Bytes()) | |
return super.CompareTypes(av, bv) |
And since performance on type comparisons doesn't matter much, I don't think it's worth generating code and suggest we just handle it with a loop over in compare.go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are referencing sort, for equality comparisons on type values we just compare bytes:
super/runtime/sam/expr/coerce/coerce.go
Lines 18 to 20 in 98f94ff
switch aid, bid := a.Type().ID(), b.Type().ID(); { | |
case !super.IsNumber(aid) || !super.IsNumber(bid): | |
return aid == bid && bytes.Equal(a.Bytes(), b.Bytes()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, boy. We do different things depending on whether the right-hand side of the comparison is constant.
$ echo '{i32:<int32>,i64:<int64>}' | super -c 'yield i32 < i64, i32 < <int64>' -
op <
false
true
We should fix that but obviously not here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mccanne has proposed dropping the comparison constant optimization for sam which I'm beginning to agree with.
a04cccd
to
e090566
Compare
e090566
to
a9ec142
Compare
No description provided.