Hi everyone, I have question. Maybe someone has encountered this before and can help me out.
I would like to do the following:
v is a memory mapped vector on disk.
ntoh.() would load the whole vector and perform the bitflip and then pass it to
Is there a way to broadcast a function on an array so that it is executed only if an element of said array needs to be accessed?I want
ntoh(v[k]) to be performed when I ask to get
v[k] , only then
This should apply the function lazily, only when needed:
searchsorted(mapview(ntoh, v), x)
mapview(f, A) is like regular
map(f, A), but presents a view of the original array instead of materializing the result.
I also found GitHub - JuliaArrays/MappedArrays.jl: Lazy in-place transformations of arrays
searchsorted(mappedarray(ntoh, v), x) do anythin different as far as you know (meaning is it at the same cost)?
I think for simple cases (arrays, read-only view) all these implementations should behave the same. As yet another alternative, there’s
I believe that all you need for this specific case is
searshsortedfirst(v, hton(x); by=ntoh). In more general cases, you can try some of the lazy evaluation techniques proposed by others.
It was necessary to apply
by applies to both the search value and the target array. See the docs for
Base.Order.ord for more on sorting options.