@@ -17,6 +17,14 @@ trait can be evaluated directly at any table implementing the
17
17
"""
18
18
abstract type Transform end
19
19
20
+ """
21
+ transform(table)
22
+
23
+ Automatically generated functor interface that calls [`apply`](@ref)
24
+ with `transform` and `table`. New types don't need to implement this.
25
+ """
26
+ (transform:: Transform )(table) = apply (transform, table) |> first
27
+
20
28
"""
21
29
isrevertible(transform)
22
30
@@ -39,7 +47,7 @@ function apply end
39
47
40
48
Revert the `transform` on the `newtable` using the `cache` from the
41
49
corresponding [`apply`](@ref) call and return the original `table`.
42
- Only defined when the transform [`isrevertible`](@ref).
50
+ Only defined when the ` transform` [`isrevertible`](@ref).
43
51
"""
44
52
function revert end
45
53
@@ -62,12 +70,38 @@ that was created with a previous [`apply`](@ref) call.
62
70
reapply (transform:: Stateless , table, cache) = apply (transform, table)
63
71
64
72
"""
65
- transform(table)
73
+ Colwise
66
74
67
- Automatically generated functor interface that calls [`apply`](@ref)
68
- with `transform` and `table`.
75
+ A transform that is applied column-by-column. In this case, the new type
76
+ only needs to implement [`colapply`](@ref), [`colrevert`](@ref) and
77
+ [`colcache`](@ref). Efficient fallbacks are provided that execute these
78
+ functions in parallel for all columns with multiple threads.
69
79
"""
70
- (transform:: Transform )(table) = apply (transform, table) |> first
80
+ abstract type Colwise <: Transform end
81
+
82
+ """
83
+ y = colapply(transform, x, c)
84
+
85
+ Apply `transform` to column `x` with cache `c` and return new column `y`.
86
+ """
87
+ function colapply end
88
+
89
+ """
90
+ x = colrevert(transform, y, c)
91
+
92
+ Revert `transform` starting from column `y` with cache `c` and return
93
+ original column `x`. Only defined when the `transform` [`isrevertible`](@ref).
94
+ """
95
+ function colrevert end
96
+
97
+ """
98
+ c = colcache(transform, x)
99
+
100
+ Produce cache `c` necessary to [`colapply`](@ref) the `transform` on `x`.
101
+ If the `transform` [`isrevertible`](@ref) then the cache `c` can also be
102
+ used in [`colrevert`](@ref).
103
+ """
104
+ function colcache end
71
105
72
106
# ----------------
73
107
# IMPLEMENTATIONS
0 commit comments