Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ version = "0.1.9"
authors = ["Beforerr <zzj956959688@gmail.com> 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"
Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
1 change: 1 addition & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 1 addition & 3 deletions src/CommonDataFormat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,4 +30,4 @@ include("loading/attribute.jl")
include("loading/variable.jl")
include("precompile.jl")

end
end
8 changes: 7 additions & 1 deletion src/decompress.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/loading/attribute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

"""
Expand Down
Loading