# Error deserializing type with parallel macro

**URL:** <https://discourse.julialang.org/t/error-deserializing-type-with-parallel-macro/11387>\
**Category:** General Usage\
**Created:** [June 3, 2018, 2:10pm UTC](https://discourse.julialang.org/t/error-deserializing-type-with-parallel-macro/11387 "2018-06-03T14:10:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![acunningham](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@acunningham](https://discourse.julialang.org/u/acunningham)\
**Post date:** [June 3, 2018, 2:10pm UTC](https://discourse.julialang.org/t/error-deserializing-type-with-parallel-macro/11387/1 "2018-06-03T14:10:05Z")

</div>

Hi,

I’ve got a problem when trying to aggregate using the @parallel macro, looks like an issue deserializing a dictionary datatype:

LoadError: On worker 2:  
TypeError: Array: in parameter, expected Type{T}, got Dict{Array{Any,N},Int64}  
in deserialize\_datatype at .\serialize.jl:830  
in handle\_deserialize at .\serialize.jl:571  
in collect at .\array.jl:307  
in deserialize at .\serialize.jl:588  
in handle\_deserialize at .\serialize.jl:581  
in deserialize at .\serialize.jl:541  
in deserialize\_datatype at .\serialize.jl:829  
in handle\_deserialize at .\serialize.jl:571  
in deserialize at .\serialize.jl:881  
in deserialize\_datatype at .\serialize.jl:835  
in handle\_deserialize at .\serialize.jl:571  
in deserialize\_array at .\serialize.jl:709  
in handle\_deserialize at .\serialize.jl:569  
in deserialize at .\serialize.jl:541  
in ntuple at .\tuple.jl:65  
in handle\_deserialize at .\serialize.jl:562  
in deserialize\_msg at .\multi.jl:120  
in message\_handler\_loop at .\multi.jl:1317  
in process\_tcp\_streams at .\multi.jl:1276  
in #620 at .\event.jl:68  
while loading In[9], in expression starting on line 2

in yieldto(::Task, ::ANY) at .\event.jl:136  
in wait() at .\event.jl:169  
in wait(::Condition) at .\event.jl:27  
in wait(::Task) at .\task.jl:132  
in collect(::Base.Generator{Array{Task,1},Base.#wait}) at .\array.jl:307  
in preduce(::Function, ::Function, ::Array{BuLossVector,2}) at .\multi.jl:2002  
in (::##21#23)(::Array{BuLossVector,2}) at .\multi.jl:2011

Sample types and functions:

```julia
addprocs(1)
@everywhere begin
   
    type BuLossVector
        ba_yelt::Dict{Array{Any}, Int64}
    end

    function BuLossVector()
        return BuLossVector(Dict{Array{Any}, Int64}())
    end

    import Base.+
    function +(x::BuLossVector, y::BuLossVector)

        z = BuLossVector()
        z.ba_yelt = merge_sum(x.ba_yelt, y.ba_yelt)
        return z
    end

    function merge_sum(d::Associative, others::Associative...)

        result_dict = copy(d)
        for other in others
            for (k,v) in other
                result_dict[k] = haskey(result_dict, k) ? d[k] + v : v
            end
        end
        return result_dict
    end
end

```

code to run test

```julia
a = BuLossVector()
b = BuLossVector()
c = BuLossVector()
d = BuLossVector()

a.ba_yelt[[16 1]] = 2
a.ba_yelt[[16 2]] = 4
b.ba_yelt[[16 1]] = 10
b.ba_yelt[[16 2]] = 40

c.ba_yelt[[16 1]] = 2
c.ba_yelt[[16 2]] = 4
d.ba_yelt[[16 1]] = 10
d.ba_yelt[[16 2]] = 40

bu_vecs = [a b c d]

```

the following code fails with the error outlined above.

```julia
result = @parallel (+) for bu_vec in bu_vecs 
    println(bu_vec)    
end

```

Regards,  
Adrian.
