-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RNTuple] support more types in RNTuple writing (#348)
* support more types in RNTuple writing * restore test * add missing file * restructure files
- Loading branch information
Showing
6 changed files
with
116 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const RNTUPLE_WRITE_TYPE_IDX_DICT = Dict( | ||
Float64 => (0x10, sizeof(UInt64) * 8), | ||
Float32 => (0x11, sizeof(UInt32) * 8), | ||
Float16 => (0x12, sizeof(UInt16) * 8), | ||
UInt64 => (0x13, sizeof(UInt64) * 8), | ||
UInt32 => (0x14, sizeof(UInt32) * 8), | ||
UInt16 => (0x15, sizeof(UInt16) * 8), | ||
Int64 => (0x16, sizeof(Int64) * 8), | ||
Int32 => (0x17, sizeof(Int32) * 8), | ||
Int16 => (0x18, sizeof(Int16) * 8), | ||
Int8 => (0x19, sizeof(Int8) * 8), | ||
) | ||
|
||
const RNTUPLE_WRITE_TYPE_CPPNAME_DICT = Dict( | ||
Float16 => "std::float16_t", | ||
Float32 => "std::float32_t", | ||
Float64 => "std::float64_t", | ||
Int8 => "std::int8_t", | ||
Int16 => "std::int16_t", | ||
Int32 => "std::int32_t", | ||
Int64 => "std::int64_t", | ||
UInt16 => "std::uint16_t", | ||
UInt32 => "std::uint32_t", | ||
UInt64 => "std::uint64_t", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
""" | ||
rnt_ary_to_page(ary::AbstractVector) end | ||
Turns an AbstractVector into a page of an RNTuple. The element type must be primitive for this to work. | ||
""" | ||
function rnt_ary_to_page(ary::AbstractVector) end | ||
|
||
function rnt_ary_to_page(ary::AbstractVector{Float64}) | ||
Page_write(split8_encode(reinterpret(UInt8, ary))) | ||
end | ||
|
||
function rnt_ary_to_page(ary::AbstractVector{Float32}) | ||
Page_write(split4_encode(reinterpret(UInt8, ary))) | ||
end | ||
|
||
function rnt_ary_to_page(ary::AbstractVector{Float16}) | ||
Page_write(split2_encode(reinterpret(UInt8, ary))) | ||
end | ||
|
||
function rnt_ary_to_page(ary::AbstractVector{UInt64}) | ||
Page_write(split8_encode(reinterpret(UInt8, ary))) | ||
end | ||
|
||
function rnt_ary_to_page(ary::AbstractVector{UInt32}) | ||
Page_write(split4_encode(reinterpret(UInt8, ary))) | ||
end | ||
|
||
function rnt_ary_to_page(ary::AbstractVector{UInt16}) | ||
Page_write(split2_encode(reinterpret(UInt8, ary))) | ||
end | ||
|
||
function rnt_ary_to_page(ary::AbstractVector{Int64}) | ||
Page_write(reinterpret(UInt8, ary)) | ||
end | ||
|
||
function rnt_ary_to_page(ary::AbstractVector{Int32}) | ||
Page_write(reinterpret(UInt8, ary)) | ||
end | ||
|
||
function rnt_ary_to_page(ary::AbstractVector{Int16}) | ||
Page_write(reinterpret(UInt8, ary)) | ||
end | ||
|
||
function rnt_ary_to_page(ary::AbstractVector{Int8}) | ||
Page_write(reinterpret(UInt8, ary)) | ||
end | ||
|
||
function split8_encode(src::AbstractVector{UInt8}) | ||
@views [src[1:8:end-7]; src[2:8:end-6]; src[3:8:end-5]; src[4:8:end-4]; src[5:8:end-3]; src[6:8:end-2]; src[7:8:end-1]; src[8:8:end]] | ||
end | ||
function split4_encode(src::AbstractVector{UInt8}) | ||
@views [src[1:4:end-3]; src[2:4:end-2]; src[3:4:end-1]; src[4:4:end]] | ||
end | ||
function split2_encode(src::AbstractVector{UInt8}) | ||
@views [src[1:2:end-1]; src[2:2:end]] | ||
end | ||
|
||
_to_zigzag(n) = (n << 1) ⊻ (n >> (sizeof(n)*8-1)) | ||
function _to_zigzag(res::AbstractVector) | ||
out = similar(res) | ||
@simd for i in eachindex(out, res) | ||
out[i] = _to_zigzag(res[i]) | ||
end | ||
return out | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters