Skip to content

Commit

Permalink
fixed #72
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaodaigh committed Nov 7, 2021
1 parent 428456b commit 244a8a7
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name = "JDF"
uuid = "babc3d20-cd49-4f60-a736-a8f9c08892d3"
authors = ["Dai ZJ <zhuojia.dai@gmail.com>"]
version = "0.4.4"
version = "0.4.5"

[deps]
Blosc = "a74b3585-a348-5f62-a45c-50e91977d574"
BufferedStreams = "e1450e63-4bb3-523b-b2a4-4ffa8c0fd77d"
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Missings = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
PooledArrays = "2dfb63ee-cc39-5dd5-95bd-886bf059d720"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Expand Down
1 change: 1 addition & 0 deletions src/JDF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export IsBitsType, eachcol, some_elm, getindex, istable
include("JDFFile.jl")
include("type-writer-loader/Bool.jl")
include("type-writer-loader/Char.jl")
include("type-writer-loader/DateTime.jl")
include("type-writer-loader/categorical-arrays.jl")
include("type-writer-loader/pooled-arrays.jl")
include("type-writer-loader/Missing.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/savejdf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function save(outdir::AbstractString, df; verbose = false)

fnl_metadata = (
names = Tables.columnnames(df),
rows = size(df, 1),
rows = length(Tables.columns(df)[1]),
metadatas = metadatas,
version = v"0.2",
)
Expand Down
4 changes: 2 additions & 2 deletions src/type-writer-loader/DateTime.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
# column_loader(DateTime, io, metadata)
# end
#
some_elm(::Type{DateTime}) = DateTime(1)
some_elm(::Type{DateTime}) = DateTime(2000,1,1,1,1,1)

# turns out DateTime is BLosc Compressable
# turns out DateTime is BLosc Compressable; no need to do anything
4 changes: 1 addition & 3 deletions src/type-writer-loader/Missing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ using Missings: allowmissing

some_elm(::Type{Missing}) = missing


# the dispatch for Union{T, Missing}
# 1. compress the missing
# 2. and also load the missing
compress_then_write(b::Vector{Union{T,Missing}}, io) where {T} = begin
S = nonmissingtype(eltype(b))
b_S = coalesce.(b, some_elm(S))
b_S = coalesce.(b, some_elm(T))

metadata = compress_then_write(b_S, io)

Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ include("test-jdf-str.jl")
include("test-eachcol.jl")
include("test-ZonedDateTime.jl")
include("test-substring.jl")
include("test-date-w-missing.jl")

@testset "JDF.jl parallel" begin
df = DataFrame([collect(1:100) for i = 1:3000], :auto)
Expand Down
15 changes: 15 additions & 0 deletions test/test-date-w-missing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ using JDF
using Dates
col = [Date(1999,1,1), missing]
df = (d = col, a = [1, missing])

using Tables

JDF.save("plsdel-date-w-missing.jdf", df)
DataFrame(JDF.load("plsdel-date-w-missing.jdf"))
rm("plsdel-date-w-missing.jdf", recursive=true)

# Guard aginst github #72
using DataFrames
using Dates

df = DataFrame()
df[!, :test] = [Dates.DateTime(2000,1,1,1,1,1), missing]
df
using JDF
JDF.savejdf("plsdel-datetime-w-missing.jdf", df)
DataFrame(JDF.load("plsdel-datetime-w-missing.jdf"))
rm("plsdel-datetime-w-missing.jdf", recursive=true)

6 comments on commit 244a8a7

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An unexpected error occurred during registration.

@xiaodaigh
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiaodaigh
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An unexpected error occurred during registration.

@xiaodaigh
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/48330

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.5 -m "<description of version>" 244a8a745d156f94b73177d2ba93f00c2b507d1d
git push origin v0.4.5

Please sign in to comment.