diff --git a/Project.toml b/Project.toml index 25f40af..a45bce4 100644 --- a/Project.toml +++ b/Project.toml @@ -4,9 +4,7 @@ version = "0.1.9" authors = ["Beforerr and contributors"] [deps] -CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" -Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4" DiskArrays = "3c3547ce-8d99-4f5e-a174-61eb10b00ae3" LibDeflate = "9255714d-24a7-4b30-8ea3-d46a97f7e13b" Mmap = "a63ad114-7e13-5084-954f-fe012c677804" @@ -20,10 +18,8 @@ CommonDataModel = "1fbeeb36-5f17-413c-809b-666fb144f157" CommonDataFormatCommonDataModelExt = ["CommonDataModel"] [compat] -CodecZlib = "0.7" CommonDataModel = "0.4" Dates = "1" -Dictionaries = "0.4" DiskArrays = "0.4" LibDeflate = "0.4.3" Mmap = "1" diff --git a/README.md b/README.md index 0e39125..ea98487 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # CommonDataFormat.jl [![DOI](https://zenodo.org/badge/1057373325.svg)](https://doi.org/10.5281/zenodo.17517061) +[![version](https://juliahub.com/docs/General/CDAWeb/stable/version.svg)](https://juliahub.com/ui/Packages/General/CDAWeb) [![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) [![Coverage](https://codecov.io/gh/JuliaSpacePhysics/CommonDataFormat.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/JuliaSpacePhysics/CommonDataFormat.jl) diff --git a/docs/src/index.md b/docs/src/index.md index 08df990..e780862 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -5,6 +5,7 @@ CurrentModule = CommonDataFormat # CommonDataFormat.jl [![DOI](https://zenodo.org/badge/1057373325.svg)](https://doi.org/10.5281/zenodo.17517061) +[![version](https://juliahub.com/docs/General/CDAWeb/stable/version.svg)](https://juliahub.com/ui/Packages/General/CDAWeb) 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. diff --git a/src/CommonDataFormat.jl b/src/CommonDataFormat.jl index 2e45784..1c30a6c 100644 --- a/src/CommonDataFormat.jl +++ b/src/CommonDataFormat.jl @@ -2,11 +2,9 @@ module CommonDataFormat using Dates using Mmap -using Dictionaries: Dictionary using ResumableFunctions using DiskArrays using Base.Threads -using CodecZlib: GzipDecompressor, transcode using LibDeflate using LibDeflate: GzipDecompressResult using PrecompileTools @@ -32,4 +30,4 @@ include("loading/attribute.jl") include("loading/variable.jl") include("precompile.jl") -end \ No newline at end of file +end diff --git a/src/decompress.jl b/src/decompress.jl index 588a334..cee4d9d 100644 --- a/src/decompress.jl +++ b/src/decompress.jl @@ -24,7 +24,13 @@ function decompress_bytes(data, compression::CompressionType; expected_bytes::Un compression == NoCompression && return data @assert compression in (GzipCompression, RLECompression) result = if compression == GzipCompression - transcode(GzipDecompressor, Vector{UInt8}(data)) + decompressor = Decompressor() + input = convert(Vector{UInt8}, data) + max_size = isnothing(expected_bytes) ? length(input) * 10 : expected_bytes + output = Vector{UInt8}(undef, max_size) + decomp_result = gzip_decompress!(decompressor, output, input) + resize!(output, decomp_result.len) + output else isnothing(expected_bytes) && throw(ArgumentError("RLE decompression requires expected size")) _rle_decompress(data, expected_bytes) diff --git a/src/loading/attribute.jl b/src/loading/attribute.jl index 5fbf663..c72230d 100644 --- a/src/loading/attribute.jl +++ b/src/loading/attribute.jl @@ -31,7 +31,7 @@ function attrib(cdf::CDFDataset; predicate = is_global) aedrs = map(adrs) do adr load_attribute_entries(buffer, adr, RecordSizeType, cdf_encoding) end - return Dictionary(names, aedrs) + return Dict(zip(names, aedrs)) end """