Skip to content

Commit e3bd3d1

Browse files
committed
docstrings
1 parent 5c774ea commit e3bd3d1

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/serialization.jl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ function serialize_sizehint(A::GBVecOrMat)
3838
return sz[]
3939
end
4040

41+
"""
42+
gbwrite(filename::AbstractString, A::GBVecOrMat)
43+
gbwrite(io::IO, A::GBVecOrMat)
44+
45+
Write `A` as a `GrB_Matrix` to a file or IO object. This function uses the
46+
`GrB_Matrix_serialize` routine from the C GraphBLAS library, and *does not* serialize
47+
the full Julia object. To read this serialized matrix you must use [`gbread`](@ref) with
48+
a type or [`gbread_matrix`](@ref) / [`gbread_vector`](@ref) to use serialized element type.
49+
"""
4150
gbwrite(filename::AbstractString, A::GBVecOrMat) = open(io->gbwrite(io, A), filename, "w")
4251

4352
function gbwrite(io::IO, A::GBVecOrMat)
@@ -49,6 +58,14 @@ function gbwrite(io::IO, A::GBVecOrMat)
4958
write(io, v)
5059
end
5160

61+
"""
62+
gbread(filename::AbstractString, ::Type{GBMatrix{T, Tf}}; fill)
63+
gbread(io::IO, ::Type{GBMatrix{T, Tf}}; fill)
64+
65+
Read a `GrB_Matrix` from a file or IO object. This function uses the
66+
`GrB_Matrix_deserialize` routine from the C GraphBLAS library directly, and constructs the
67+
passed in type. It does not use Julia's Serialization standard library.
68+
"""
5269
gbread(filename::AbstractString, ::Type{T}; fill = defaultfill(Tf)) where {Te, Tf, T<:GBVecOrMat{Te, Tf}} =
5370
open(io->gbread(io, T; fill), filename, "r")
5471

@@ -64,6 +81,15 @@ function gbread(io::IO, ::Type{GBVector{T, Tf}}; fill = defaultfill(Tf)) where {
6481
GBVector{T, Tf}(gb, fill)
6582
end
6683

84+
"""
85+
gbread_matrix(filename::AbstractString; fill)
86+
gbread_matrix(io::IO; fill)
87+
88+
Read a `GrB_Matrix` from a file or IO object. This function uses the
89+
`GrB_Matrix_deserialize` routine from the C GraphBLAS library directly, and constructs
90+
a [`GBMatrix`](@ref) using the deserialized element type. The default fill for the deserialized
91+
element type is used unless one is passed in as the keyword argument `fill`.
92+
"""
6793
gbread_matrix(filename::AbstractString; fill = Nothing) =
6894
open(io->gbread_matrix(io; fill), filename, "r")
6995

@@ -76,6 +102,17 @@ function gbread_matrix(io::IO; fill = Nothing)
76102
fill = fill === Nothing ? defaultfill(T) : fill
77103
return GBMatrix{T}(gb; fill)
78104
end
105+
"""
106+
gbread_matrix(filename::AbstractString; fill)
107+
gbread_matrix(io::IO; fill)
108+
109+
Read a `GrB_Matrix` from a file or IO object. This function uses the
110+
`GrB_Matrix_deserialize` routine from the C GraphBLAS library directly, and constructs
111+
a [`GBMatrix`](@ref) using the deserialized element type. The default fill for the deserialized
112+
element type is used unless one is passed in as the keyword argument `fill`.
113+
"""
114+
gbread_vector(filename::AbstractString; fill = Nothing) =
115+
open(io->gbread_vector(io; fill), filename, "r")
79116
function gbread_vector(io::IO; fill = Nothing)
80117
v = read(io)
81118
gb = _gbdeserialize_matrix(v, Nothing) # we don't know the eltype pass nothing

0 commit comments

Comments
 (0)