Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Root
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
为了安全,强烈建议开启2FA双因子认证:User Settings -> Account -> Enable two-factor authentication!!!
Show more breadcrumbs
cxwx
Root
Commits
ba457bd6
Commit
ba457bd6
authored
6 years ago
by
Jakob Blomer
Committed by
Enrico Guiraud
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[DF] Improve initialization of RSqliteDS::fValues
parent
64bf21b8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tree/dataframe/inc/ROOT/RSqliteDS.hxx
+2
-2
2 additions, 2 deletions
tree/dataframe/inc/ROOT/RSqliteDS.hxx
tree/dataframe/src/RSqliteDS.cxx
+37
-11
37 additions, 11 deletions
tree/dataframe/src/RSqliteDS.cxx
with
39 additions
and
13 deletions
tree/dataframe/inc/ROOT/RSqliteDS.hxx
+
2
−
2
View file @
ba457bd6
...
...
@@ -39,16 +39,16 @@ private:
// Can be implemented by std::variant once available
struct
Value_t
{
Value_t
()
:
fType
(
Types
::
kNull
),
fNull
(
nullptr
),
fPtr
(
nullptr
),
fIsActive
(
false
)
{}
explicit
Value_t
(
Types
type
);
Types
fType
;
bool
fIsActive
;
Long64_t
fInteger
;
double
fReal
;
std
::
string
fText
;
std
::
vector
<
unsigned
char
>
fBlob
;
void
*
fNull
;
void
*
fPtr
;
bool
fIsActive
;
};
void
SqliteError
(
int
errcode
);
...
...
This diff is collapsed.
Click to expand it.
tree/dataframe/src/RSqliteDS.cxx
+
37
−
11
View file @
ba457bd6
...
...
@@ -29,6 +29,37 @@ namespace ROOT {
namespace
RDF
{
RSqliteDS
::
Value_t
::
Value_t
(
RSqliteDS
::
Types
type
)
:
fType
(
type
)
,
fIsActive
(
false
)
,
fInteger
(
0
)
,
fReal
(
0.0
)
,
fText
()
,
fBlob
()
,
fNull
(
nullptr
)
{
switch
(
type
)
{
case
Types
::
kInteger
:
fPtr
=
&
fInteger
;
break
;
case
Types
::
kReal
:
fPtr
=
&
fReal
;
break
;
case
Types
::
kText
:
fPtr
=
&
fText
;
break
;
case
Types
::
kBlob
:
fPtr
=
&
fBlob
;
break
;
case
Types
::
kNull
:
fPtr
=
&
fNull
;
break
;
default:
throw
std
::
runtime_error
(
"Internal error"
);
}
}
RSqliteDS
::
RSqliteDS
(
std
::
string_view
fileName
,
std
::
string_view
query
)
:
fDb
(
nullptr
)
,
fQuery
(
nullptr
)
...
...
@@ -47,7 +78,7 @@ RSqliteDS::RSqliteDS(std::string_view fileName, std::string_view query)
retval
=
sqlite3_step
(
fQuery
);
if
((
retval
!=
SQLITE_ROW
)
&&
(
retval
!=
SQLITE_DONE
))
SqliteError
(
retval
);
fValues
.
res
iz
e
(
colCount
);
fValues
.
res
erv
e
(
colCount
);
for
(
int
i
=
0
;
i
<
colCount
;
++
i
)
{
fColumnNames
.
emplace_back
(
sqlite3_column_name
(
fQuery
,
i
));
int
type
=
SQLITE_NULL
;
...
...
@@ -68,29 +99,24 @@ RSqliteDS::RSqliteDS(std::string_view fileName, std::string_view query)
switch
(
type
)
{
case
SQLITE_INTEGER
:
fColumnTypes
.
push_back
(
Types
::
kInteger
);
fValues
[
i
].
fType
=
Types
::
kInteger
;
fValues
[
i
].
fPtr
=
&
fValues
[
i
].
fInteger
;
fValues
.
emplace_back
(
Types
::
kInteger
);
break
;
case
SQLITE_FLOAT
:
fColumnTypes
.
push_back
(
Types
::
kReal
);
fValues
[
i
].
fType
=
Types
::
kReal
;
fValues
[
i
].
fPtr
=
&
fValues
[
i
].
fReal
;
fValues
.
emplace_back
(
Types
::
kReal
);
break
;
case
SQLITE_TEXT
:
fColumnTypes
.
push_back
(
Types
::
kText
);
fValues
[
i
].
fType
=
Types
::
kText
;
fValues
[
i
].
fPtr
=
&
fValues
[
i
].
fText
;
fValues
.
emplace_back
(
Types
::
kText
);
break
;
case
SQLITE_BLOB
:
fColumnTypes
.
push_back
(
Types
::
kBlob
);
fValues
[
i
].
fType
=
Types
::
kBlob
;
fValues
[
i
].
fPtr
=
&
fValues
[
i
].
fBlob
;
fValues
.
emplace_back
(
Types
::
kBlob
);
break
;
case
SQLITE_NULL
:
// TODO: Null values in first rows are not well handled
fColumnTypes
.
push_back
(
Types
::
kNull
);
fValues
[
i
].
fType
=
Types
::
kNull
;
fValues
[
i
].
fPtr
=
&
fValues
[
i
].
fNull
;
fValues
.
emplace_back
(
Types
::
kNull
);
break
;
default:
throw
std
::
runtime_error
(
"Unhandled data type"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment