RelationalAI-oss/Blobs.jl

Better support for mutating Tuples

Closed this issue · 1 comments

This code works:

using Blobs

struct Foo
    x::Int64
    y::Float32
end

bbv = Blobs.malloc_and_init(BlobVector{Foo}, 3)
@show bbv[][1]
bbv[1].x[] = 1
bbv[1].y[] = 2.1
@show bbv[][1]

But, the same code does not work if you replace Foo with Tuple:

using Blobs

bbv = Blobs.malloc_and_init(BlobVector{Tuple{Int, Float32}}, 3)
@show bbv[][1]
bbv[1][1][] = 1
bbv[1][2][] = 2.1
@show bbv[][1]

Here is the error:

ERROR: MethodError: no method matching getindex(::Blob{Tuple{Int64,Float32}}, ::Int64)
Closest candidates are:
  getindex(::Blob{T}) where T at /Users/dashti/.julia/packages/Blobs/bMFUi/src/blob.jl:45
  getindex(::Blob{T}, ::Type{Val{field}}) where {T, field} at /Users/dashti/.julia/packages/Blobs/bMFUi/src/blob.jl:83
Stacktrace:
 [1] top-level scope at none:0

Closed because of #23