Skip to content

Commit f4524e9

Browse files
authored
[Bitshuffle] Rename BShufZ to BShufLZ (#69)
* [Bitshuffle] Rename BShufZ to BShufLZ * fix names
1 parent 7c7c2db commit f4524e9

File tree

5 files changed

+70
-70
lines changed

5 files changed

+70
-70
lines changed

Bitshuffle/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This package implements the ChunkCodec interface for the following encoders and
66
ported from the libbitshuffle C library <https://github.com/kiyo-masui/bitshuffle>
77

88
1. `BShufCodec`, `BShufEncodeOptions`, `BShufDecodeOptions`
9-
1. `BShufZCodec`, `BShufZEncodeOptions`, `BShufZDecodeOptions`
9+
1. `BShufLZCodec`, `BShufLZEncodeOptions`, `BShufLZDecodeOptions`
1010

1111
## Example
1212

Bitshuffle/src/ChunkCodecBitshuffle.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ export BShufDecodingError,
2323
BShufCodec,
2424
BShufEncodeOptions,
2525
BShufDecodeOptions,
26-
BShufZCodec,
27-
BShufZEncodeOptions,
28-
BShufZDecodeOptions
26+
BShufLZCodec,
27+
BShufLZEncodeOptions,
28+
BShufLZDecodeOptions
2929

3030
# reexport ChunkCodecCore
3131
using ChunkCodecCore: ChunkCodecCore, encode, decode

Bitshuffle/src/compress.jl

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,43 @@ The element size can be at most `fld(typemax(Int32), 8)`.
1212
"""
1313

1414
"""
15-
struct BShufZCodec{C<:Codec} <: Codec
16-
BShufZCodec(element_size::Integer, compress::Codec)
15+
struct BShufLZCodec{C<:Codec} <: Codec
16+
BShufLZCodec(element_size::Integer, compress::Codec)
1717
1818
$bitshufflecompress_docs
1919
2020
"""
21-
struct BShufZCodec{C<:Codec} <: Codec
21+
struct BShufLZCodec{C<:Codec} <: Codec
2222
element_size::Int64
2323
compress::C
24-
function BShufZCodec{C}(element_size::Integer, compress::Codec) where C<:Codec
24+
function BShufLZCodec{C}(element_size::Integer, compress::Codec) where C<:Codec
2525
check_in_range(Int64(1):fld(typemax(Int32), 8); element_size)
2626
new{C}(Int64(element_size), convert(C, compress))
2727
end
2828
end
29-
BShufZCodec(element_size::Integer, compress::Codec) = BShufZCodec{typeof(compress)}(element_size, compress)
29+
BShufLZCodec(element_size::Integer, compress::Codec) = BShufLZCodec{typeof(compress)}(element_size, compress)
3030

31-
decode_options(x::BShufZCodec) = BShufZDecodeOptions(;codec=x) # default decode options
31+
decode_options(x::BShufLZCodec) = BShufLZDecodeOptions(;codec=x) # default decode options
3232

3333
"""
34-
struct BShufZEncodeOptions <: EncodeOptions
35-
BShufZEncodeOptions(; kwargs...)
34+
struct BShufLZEncodeOptions <: EncodeOptions
35+
BShufLZEncodeOptions(; kwargs...)
3636
3737
$bitshufflecompress_docs
3838
3939
# Keyword Arguments
4040
41-
- `codec::BShufZCodec`
41+
- `codec::BShufLZCodec`
4242
- `options::EncodeOptions`: block encoding options.
4343
- `block_size::Integer=0`: Must be a multiple of 8. zero can be used for an automatic block size. This a number of elements not a number of bytes.
4444
"""
45-
struct BShufZEncodeOptions{C<:Codec, E<:EncodeOptions} <: EncodeOptions
46-
codec::BShufZCodec{C}
45+
struct BShufLZEncodeOptions{C<:Codec, E<:EncodeOptions} <: EncodeOptions
46+
codec::BShufLZCodec{C}
4747
options::E
4848
block_size::Int64
4949
end
50-
function BShufZEncodeOptions{C, E}(;
51-
codec::BShufZCodec,
50+
function BShufLZEncodeOptions{C, E}(;
51+
codec::BShufLZCodec,
5252
options::EncodeOptions,
5353
block_size::Integer=Int64(0),
5454
kwargs...
@@ -80,25 +80,25 @@ function BShufZEncodeOptions{C, E}(;
8080
if max_compressed_block_bytes > typemax(Int32)
8181
throw(ArgumentError("`options` not able to encode max block size in `typemax(Int32)` bytes."))
8282
end
83-
BShufZEncodeOptions{C, E}(codec, options, Int64(block_size))
83+
BShufLZEncodeOptions{C, E}(codec, options, Int64(block_size))
8484
end
85-
function BShufZEncodeOptions(;
86-
codec::BShufZCodec{C},
85+
function BShufLZEncodeOptions(;
86+
codec::BShufLZCodec{C},
8787
options::E,
8888
kwargs...
8989
) where {C<:Codec, E<:EncodeOptions}
90-
BShufZEncodeOptions{C, E}(; codec, options, kwargs...)
90+
BShufLZEncodeOptions{C, E}(; codec, options, kwargs...)
9191
end
9292

93-
is_thread_safe(e::BShufZEncodeOptions) = is_thread_safe(e.options)
93+
is_thread_safe(e::BShufLZEncodeOptions) = is_thread_safe(e.options)
9494

95-
is_lossless(e::BShufZEncodeOptions) = is_lossless(e.options)
95+
is_lossless(e::BShufLZEncodeOptions) = is_lossless(e.options)
9696

97-
function decoded_size_range(e::BShufZEncodeOptions)
97+
function decoded_size_range(e::BShufLZEncodeOptions)
9898
Int64(0):e.codec.element_size:typemax(Int64)-1
9999
end
100100

101-
function encode_bound(e::BShufZEncodeOptions, src_size::Int64)::Int64
101+
function encode_bound(e::BShufLZEncodeOptions, src_size::Int64)::Int64
102102
elem_size = e.codec.element_size
103103
max_block_size = if iszero(e.block_size)
104104
default_block_size(elem_size)
@@ -120,7 +120,7 @@ function encode_bound(e::BShufZEncodeOptions, src_size::Int64)::Int64
120120
bound
121121
end
122122

123-
function try_encode!(e::BShufZEncodeOptions, dst::AbstractVector{UInt8}, src::AbstractVector{UInt8}; kwargs...)::Union{Nothing, Int64}
123+
function try_encode!(e::BShufLZEncodeOptions, dst::AbstractVector{UInt8}, src::AbstractVector{UInt8}; kwargs...)::Union{Nothing, Int64}
124124
check_contiguous(dst)
125125
check_contiguous(src)
126126
src_size::Int64 = length(src)
@@ -193,41 +193,41 @@ function try_encode!(e::BShufZEncodeOptions, dst::AbstractVector{UInt8}, src::Ab
193193
end
194194

195195
"""
196-
struct BShufZDecodeOptions <: DecodeOptions
197-
BShufZDecodeOptions(; kwargs...)
196+
struct BShufLZDecodeOptions <: DecodeOptions
197+
BShufLZDecodeOptions(; kwargs...)
198198
199199
$bitshufflecompress_docs
200200
201201
# Keyword Arguments
202202
203-
- `codec::BShufZCodec`
203+
- `codec::BShufLZCodec`
204204
- `options::DecodeOptions= decode_options(codec.compress)`: block decoding options.
205205
"""
206-
struct BShufZDecodeOptions{C<:Codec, D<:DecodeOptions} <: DecodeOptions
207-
codec::BShufZCodec{C}
206+
struct BShufLZDecodeOptions{C<:Codec, D<:DecodeOptions} <: DecodeOptions
207+
codec::BShufLZCodec{C}
208208
options::D
209209
end
210-
function BShufZDecodeOptions{C, D}(;
211-
codec::BShufZCodec,
210+
function BShufLZDecodeOptions{C, D}(;
211+
codec::BShufLZCodec,
212212
options::DecodeOptions= decode_options(codec.compress),
213213
kwargs...
214214
) where {C<:Codec, D<:DecodeOptions}
215215
if !isequal(options.codec, codec.compress)
216216
throw(ArgumentError("`codec.compress` must match `options.codec`. Got\n`codec.compress` => $(codec.compress)\n`options.codec` => $(options.codec)"))
217217
end
218-
BShufZDecodeOptions{C, D}(codec, options)
218+
BShufLZDecodeOptions{C, D}(codec, options)
219219
end
220-
function BShufZDecodeOptions(;
221-
codec::BShufZCodec{C},
220+
function BShufLZDecodeOptions(;
221+
codec::BShufLZCodec{C},
222222
options::D= decode_options(codec.compress),
223223
kwargs...
224224
) where {C<:Codec, D<:DecodeOptions}
225-
BShufZDecodeOptions{C, D}(;codec, options, kwargs...)
225+
BShufLZDecodeOptions{C, D}(;codec, options, kwargs...)
226226
end
227227

228-
is_thread_safe(d::BShufZDecodeOptions) = is_thread_safe(d.options)
228+
is_thread_safe(d::BShufLZDecodeOptions) = is_thread_safe(d.options)
229229

230-
function try_find_decoded_size(d::BShufZDecodeOptions, src::AbstractVector{UInt8})::Int64
230+
function try_find_decoded_size(d::BShufLZDecodeOptions, src::AbstractVector{UInt8})::Int64
231231
if length(src) < 12
232232
throw(BShufDecodingError("unexpected end of input"))
233233
else
@@ -242,7 +242,7 @@ function try_find_decoded_size(d::BShufZDecodeOptions, src::AbstractVector{UInt8
242242
end
243243
end
244244

245-
function try_decode!(d::BShufZDecodeOptions, dst::AbstractVector{UInt8}, src::AbstractVector{UInt8}; kwargs...)::Union{Nothing, Int64}
245+
function try_decode!(d::BShufLZDecodeOptions, dst::AbstractVector{UInt8}, src::AbstractVector{UInt8}; kwargs...)::Union{Nothing, Int64}
246246
check_contiguous(dst)
247247
check_contiguous(src)
248248
decoded_size = try_find_decoded_size(d, src)

Bitshuffle/test/runtests.jl

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ using ChunkCodecBitshuffle:
66
BShufCodec,
77
BShufEncodeOptions,
88
BShufDecodeOptions,
9-
BShufZCodec,
10-
BShufZEncodeOptions,
11-
BShufZDecodeOptions
9+
BShufLZCodec,
10+
BShufLZEncodeOptions,
11+
BShufLZDecodeOptions
1212
using ChunkCodecCore:
1313
ChunkCodecCore,
1414
decode,
@@ -140,26 +140,26 @@ end
140140
for element_size in [1; 8; 256; 513;]
141141
for block_size in [0; 8; 24; 2^20;]
142142
# zero is default
143-
c = BShufZCodec(element_size, ZstdCodec())
143+
c = BShufLZCodec(element_size, ZstdCodec())
144144
# @show c
145145
test_codec(
146146
c,
147-
BShufZEncodeOptions(;codec= c, options= ZstdEncodeOptions(), block_size),
148-
BShufZDecodeOptions(;codec= c);
147+
BShufLZEncodeOptions(;codec= c, options= ZstdEncodeOptions(), block_size),
148+
BShufLZDecodeOptions(;codec= c);
149149
trials=10,
150150
)
151151
end
152152
end
153-
c = BShufZCodec(5, LZ4BlockCodec())
153+
c = BShufLZCodec(5, LZ4BlockCodec())
154154
test_codec(
155155
c,
156-
BShufZEncodeOptions(;codec= c, options= LZ4BlockEncodeOptions()),
157-
BShufZDecodeOptions(;codec= c);
156+
BShufLZEncodeOptions(;codec= c, options= LZ4BlockEncodeOptions()),
157+
BShufLZDecodeOptions(;codec= c);
158158
trials=10,
159159
)
160160
end
161161
@testset "non multiple of element size compress" begin
162-
e_opt = BShufZEncodeOptions(;codec=BShufZCodec(5, LZ4BlockCodec()), options=LZ4BlockEncodeOptions())
162+
e_opt = BShufLZEncodeOptions(;codec=BShufLZCodec(5, LZ4BlockCodec()), options=LZ4BlockEncodeOptions())
163163
# Ref https://github.com/kiyo-masui/bitshuffle/issues/3
164164
@test_throws ArgumentError encode(e_opt, zeros(UInt8, 42))
165165
# decode will copy leftover bytes at the end for future bitshuffle compatibility.
@@ -168,10 +168,10 @@ end
168168
e[8] = 42
169169
@test_throws BShufDecodingError("decoded_size isn't a multiple of element_size") decode(e_opt.codec, [e; 0x12; 0x34;]) == [ones(UInt8, 40); 0x12; 0x34;]
170170
end
171-
@testset "BShufZ constructors" begin
172-
BCC = BShufZCodec
173-
BCE = BShufZEncodeOptions
174-
BCD = BShufZDecodeOptions
171+
@testset "BShufLZ constructors" begin
172+
BCC = BShufLZCodec
173+
BCE = BShufLZEncodeOptions
174+
BCD = BShufLZDecodeOptions
175175
@test_throws ArgumentError BCC(0, LZ4BlockCodec())
176176
@test_throws ArgumentError BCC(-1, LZ4BlockCodec())
177177
@test_throws ArgumentError BCC(fld(typemax(Int32),8) + 1, LZ4BlockCodec())
@@ -224,11 +224,11 @@ end
224224
@test allunique(typeof.([b, c, d, e]))
225225
end
226226
@testset "unexpected eof" begin
227-
codec= BShufZCodec(1, ZstdCodec())
227+
codec= BShufLZCodec(1, ZstdCodec())
228228
for element_size in (1,5)
229-
codec= BShufZCodec(element_size, ZstdCodec())
229+
codec= BShufLZCodec(element_size, ZstdCodec())
230230
for block_size in (0,8,16,1000,1008,10000)
231-
e_opt = BShufZEncodeOptions(;
231+
e_opt = BShufLZEncodeOptions(;
232232
codec,
233233
options= ZstdEncodeOptions(),
234234
block_size,
@@ -244,15 +244,15 @@ end
244244
end
245245
end
246246
end
247-
@testset "BShufZ errors" begin
247+
@testset "BShufLZ errors" begin
248248
@test sprint(Base.showerror, BShufDecodingError("foo")) ==
249249
"BShufDecodingError: foo"
250-
codec=BShufZCodec(1, ZstdCodec())
251-
e = BShufZEncodeOptions(;
250+
codec=BShufLZCodec(1, ZstdCodec())
251+
e = BShufLZEncodeOptions(;
252252
codec,
253253
options= ZstdEncodeOptions(),
254254
)
255-
d = BShufZDecodeOptions(;codec)
255+
d = BShufLZDecodeOptions(;codec)
256256
# less than 12 bytes
257257
@test_throws BShufDecodingError("unexpected end of input") try_find_decoded_size(d, UInt8[])
258258
@test_throws BShufDecodingError("decoded size is negative") try_find_decoded_size(d, fill(0xFF,12))
@@ -313,13 +313,13 @@ end
313313
])
314314
end
315315
@testset "encoding without enough space" begin
316-
codec=BShufZCodec(1, ZstdCodec())
317-
e = BShufZEncodeOptions(;
316+
codec=BShufLZCodec(1, ZstdCodec())
317+
e = BShufLZEncodeOptions(;
318318
codec,
319319
options= ZstdEncodeOptions(),
320320
block_size= 32,
321321
)
322-
d = BShufZDecodeOptions(;codec)
322+
d = BShufLZDecodeOptions(;codec)
323323
u = rand(UInt8, 1024)
324324
c = encode(e, u)
325325
@test decode(d, c) == u

test/hdf5-compat.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ do_hdf5_test(
7474
100,
7575
) for element_size in [1:5; 1023;], block_size in [0, 8, 2^10]]
7676
[do_hdf5_test(
77-
BShufZEncodeOptions(;
78-
codec= BShufZCodec(element_size, LZ4BlockCodec()),
77+
BShufLZEncodeOptions(;
78+
codec= BShufLZCodec(element_size, LZ4BlockCodec()),
7979
options= LZ4BlockEncodeOptions(),
8080
block_size,
8181
),
8282
[UInt16(32008)], [[UInt32(0), UInt32(4), UInt32(element_size), UInt32(block_size), UInt32(2)]],
8383
100,
8484
) for element_size in [1:5; 1023;], block_size in [0, 8, 2^10]]
8585
[do_hdf5_test(
86-
BShufZEncodeOptions(;
87-
codec= BShufZCodec(element_size, ZstdCodec()),
86+
BShufLZEncodeOptions(;
87+
codec= BShufLZCodec(element_size, ZstdCodec()),
8888
options= ZstdEncodeOptions(),
8989
block_size,
9090
),
@@ -135,9 +135,9 @@ function decode_h5_chunk(chunk::AbstractVector{UInt8}, id::Integer, client_data)
135135
if compress == 0
136136
ChunkCodecBitshuffle.BShufCodec(element_size, block_size)
137137
elseif compress == 2
138-
ChunkCodecBitshuffle.BShufZCodec(element_size, ChunkCodecLibLz4.LZ4BlockCodec())
138+
ChunkCodecBitshuffle.BShufLZCodec(element_size, ChunkCodecLibLz4.LZ4BlockCodec())
139139
elseif compress == 3
140-
ChunkCodecBitshuffle.BShufZCodec(element_size, ChunkCodecLibZstd.ZstdCodec())
140+
ChunkCodecBitshuffle.BShufLZCodec(element_size, ChunkCodecLibZstd.ZstdCodec())
141141
end,
142142
chunk,
143143
)

0 commit comments

Comments
 (0)