Skip to content

Commit c0bd453

Browse files
authored
refactor: remove CodecZlib and Dictionaries dependencies, use LibDeflate and Dict instead (#34)
1 parent c300a57 commit c0bd453

File tree

6 files changed

+11
-9
lines changed

6 files changed

+11
-9
lines changed

Project.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ version = "0.1.9"
44
authors = ["Beforerr <zzj956959688@gmail.com> and contributors"]
55

66
[deps]
7-
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
87
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
9-
Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4"
108
DiskArrays = "3c3547ce-8d99-4f5e-a174-61eb10b00ae3"
119
LibDeflate = "9255714d-24a7-4b30-8ea3-d46a97f7e13b"
1210
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
@@ -20,10 +18,8 @@ CommonDataModel = "1fbeeb36-5f17-413c-809b-666fb144f157"
2018
CommonDataFormatCommonDataModelExt = ["CommonDataModel"]
2119

2220
[compat]
23-
CodecZlib = "0.7"
2421
CommonDataModel = "0.4"
2522
Dates = "1"
26-
Dictionaries = "0.4"
2723
DiskArrays = "0.4"
2824
LibDeflate = "0.4.3"
2925
Mmap = "1"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# CommonDataFormat.jl
22

33
[![DOI](https://zenodo.org/badge/1057373325.svg)](https://doi.org/10.5281/zenodo.17517061)
4+
[![version](https://juliahub.com/docs/General/CDAWeb/stable/version.svg)](https://juliahub.com/ui/Packages/General/CDAWeb)
45

56
[![Build Status](https://github.com/JuliaSpacePhysics/CommonDataFormat.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/JuliaSpacePhysics/CommonDataFormat.jl/actions/workflows/CI.yml?query=branch%3Amain)
67
[![Coverage](https://codecov.io/gh/JuliaSpacePhysics/CommonDataFormat.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/JuliaSpacePhysics/CommonDataFormat.jl)

docs/src/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CurrentModule = CommonDataFormat
55
# CommonDataFormat.jl
66

77
[![DOI](https://zenodo.org/badge/1057373325.svg)](https://doi.org/10.5281/zenodo.17517061)
8+
[![version](https://juliahub.com/docs/General/CDAWeb/stable/version.svg)](https://juliahub.com/ui/Packages/General/CDAWeb)
89

910
A Julia package for reading [Common Data Format (CDF)](https://cdf.gsfc.nasa.gov/) files, widely used in space physics for storing multidimensional data arrays and metadata. See [CDFDatasets.jl](https://github.com/JuliaSpacePhysics/CDFDatasets.jl) for a high-level interface.
1011

src/CommonDataFormat.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ module CommonDataFormat
22

33
using Dates
44
using Mmap
5-
using Dictionaries: Dictionary
65
using ResumableFunctions
76
using DiskArrays
87
using Base.Threads
9-
using CodecZlib: GzipDecompressor, transcode
108
using LibDeflate
119
using LibDeflate: GzipDecompressResult
1210
using PrecompileTools
@@ -32,4 +30,4 @@ include("loading/attribute.jl")
3230
include("loading/variable.jl")
3331
include("precompile.jl")
3432

35-
end
33+
end

src/decompress.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ function decompress_bytes(data, compression::CompressionType; expected_bytes::Un
2424
compression == NoCompression && return data
2525
@assert compression in (GzipCompression, RLECompression)
2626
result = if compression == GzipCompression
27-
transcode(GzipDecompressor, Vector{UInt8}(data))
27+
decompressor = Decompressor()
28+
input = convert(Vector{UInt8}, data)
29+
max_size = isnothing(expected_bytes) ? length(input) * 10 : expected_bytes
30+
output = Vector{UInt8}(undef, max_size)
31+
decomp_result = gzip_decompress!(decompressor, output, input)
32+
resize!(output, decomp_result.len)
33+
output
2834
else
2935
isnothing(expected_bytes) && throw(ArgumentError("RLE decompression requires expected size"))
3036
_rle_decompress(data, expected_bytes)

src/loading/attribute.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function attrib(cdf::CDFDataset; predicate = is_global)
3131
aedrs = map(adrs) do adr
3232
load_attribute_entries(buffer, adr, RecordSizeType, cdf_encoding)
3333
end
34-
return Dictionary(names, aedrs)
34+
return Dict(zip(names, aedrs))
3535
end
3636

3737
"""

0 commit comments

Comments
 (0)