@@ -14,6 +14,33 @@ Base.getproperty(c::ColumnsRow, ::Type{T}, col::Int, nm::Symbol) where {T} = get
14
14
Base. getproperty (c:: ColumnsRow , nm:: Symbol ) = getproperty (getfield (c, 1 ), nm)[getfield (c, 2 )]
15
15
Base. propertynames (c:: ColumnsRow ) = propertynames (getfield (c, 1 ))
16
16
17
+ @generated function Base. isless (c:: ColumnsRow{T} , d:: ColumnsRow{T} ) where {T <: NamedTuple{names} } where names
18
+ exprs = Expr[]
19
+ for n in names
20
+ var1 = Expr (:., :c , QuoteNode (n))
21
+ var2 = Expr (:., :d , QuoteNode (n))
22
+ bl = quote
23
+ a, b = $ var1, $ var2
24
+ isless (a, b) && return true
25
+ isequal (a, b) || return false
26
+ end
27
+ push! (exprs, bl)
28
+ end
29
+ push! (exprs, :(return false ))
30
+ Expr (:block , exprs... )
31
+ end
32
+
33
+ @generated function Base. isequal (c:: ColumnsRow{T} , d:: ColumnsRow{T} ) where {T <: NamedTuple{names} } where names
34
+ exprs = Expr[]
35
+ for n in names
36
+ var1 = Expr (:., :c , QuoteNode (n))
37
+ var2 = Expr (:., :d , QuoteNode (n))
38
+ push! (exprs, :(isequal ($ var1, $ var2) || return false ))
39
+ end
40
+ push! (exprs, :(return true ))
41
+ Expr (:block , exprs... )
42
+ end
43
+
17
44
struct RowIterator{T}
18
45
columns:: T
19
46
len:: Int
@@ -41,7 +68,7 @@ haslength(L) = L isa Union{Base.HasShape, Base.HasLength}
41
68
42
69
"""
43
70
Tables.allocatecolumn(::Type{T}, len) => returns a column type (usually AbstractVector) w/ size to hold `len` elements
44
-
71
+
45
72
Custom column types can override with an appropriate "scalar" element type that should dispatch to their column allocator.
46
73
"""
47
74
allocatecolumn (T, len) = Vector {T} (undef, len)
0 commit comments