Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce precompilation work in the function Buffer #377

Closed
wants to merge 3 commits into from
Closed
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
31 changes: 18 additions & 13 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,33 +116,38 @@ mutable struct Buffer

# for data fetching
function Buffer(ctype::API.SQLSMALLINT, columnsize, rows, nullable)
if ctype == API.SQL_C_DOUBLE
return new(newarray(Float64, nullable, rows))
T = if ctype == API.SQL_C_DOUBLE
Float64
elseif ctype == API.SQL_C_FLOAT
return new(newarray(Float32, nullable, rows))
Float32
elseif ctype == API.SQL_C_STINYINT
return new(newarray(Int8, nullable, rows))
Int8
elseif ctype == API.SQL_C_SSHORT
return new(newarray(Int16, nullable, rows))
Int16
elseif ctype == API.SQL_C_SLONG
return new(newarray(Int32, nullable, rows))
Int32
elseif ctype == API.SQL_C_SBIGINT
return new(newarray(Int64, nullable, rows))
Int64
elseif ctype == API.SQL_C_BIT
return new(newarray(Bool, nullable, rows))
Bool
elseif ctype == API.SQL_C_TYPE_DATE
return new(newarray(API.SQLDate, nullable, rows))
API.SQLDate
elseif ctype == API.SQL_C_TYPE_TIMESTAMP
return new(newarray(API.SQLTimestamp, nullable, rows))
API.SQLTimestamp
elseif ctype == API.SQL_C_TYPE_TIME
return new(newarray(API.SQLTime, nullable, rows))
API.SQLTime
elseif ctype == API.SQL_C_GUID
return new(newarray(UUID, nullable, rows))
UUID
else
nothing
end

if T === nothing
return new(Vector{UInt8}(undef, columnsize * rows))
end
end

return new(newarray(T, nullable, rows))
end
end

Base.pointer(b::Buffer) = specialize(pointer, b.buffer)
Expand Down