You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now we switch type id all the places and code looks like
switch type.typeid {
case T_INT8: ...
case T_INT16: ...
...
case T_DECIMAL64: ...
}
Note that this has many problems.
1. If we add a type, we need to touch many many places. Missing one will cause crash/panic or worse.
2. This switch, often is in a loop. VERY SLOW.
Describe the solution you'd like
Consolidate every type switch to a "virtual function table" approach. We we create a type, then type now has a VFT
type Typ struct {
Oid T
...
vft *VFT
}
Where VFT is an array of function ptrs. Initialize this vft when we construct the type data structure.
func (t T) ToType() Type {
...
typ.vft = vft_of_t
return typ
}
All VFT of different types should be implemented in types module. Maybe even one file. At least, the vft entry for each type should intialized in one file.
Later all the switch should go away, we just call
typ.GetFunc(op_xxx)(args)
Activity
12 remaining items
tools(oidscan): report type-id switches; design doc builds on TestTyp…
refactor(colexec): resolve type dispatch once per vector in DML paths
refactor(types): read per-type facts from one table indexed by T
refactor(vector): move union, append-bytes and function-result dispat…
refactor(types): type dispatch design (#10181), oidscan, DML dispatch…
refactor(vector): dispatch vector operations through a type-ops table (…
perf(types): format dates, times and decimals without fmt (#33345)
refactor(tae): read and update TAE values through the vector type-ops…
perf(hashmap): resolve nullable key encoding once per vector (#10181 …
test(types): check decimal and temporal switches; baseline records mi…
docs(skills): type dispatch rules for general switches and vector loops
docs(skills): type dispatch rules for general switches and vector loops
fix(aggexec): append window values through the vector type-ops table (#…
fix: handle decimal256 in switches that left it out (#10181 Step 9), …