Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
dcdb
dcdb
Commits
c3bd09b2
Commit
c3bd09b2
authored
Dec 28, 2018
by
Micha Mueller
Browse files
WIP: Fill new C-API functions with live (not yet tested)
parent
a60c8812
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/include/dcdb/c_api.h
View file @
c3bd09b2
...
...
@@ -174,7 +174,7 @@ DCDB_C_RESULT dcdbQuerySumMultipleThreaded(
/*****************************************************************************/
/**
* @brief Construct a new DCDB::Connection object.
* @brief Construct a new DCDB::Connection object
and connect it to database
.
*
* @param hostname Hostname of database node
* @param port TCP port to use for connecting to the database node
...
...
@@ -207,10 +207,11 @@ DCDB_C_RESULT disconnectFromDatabase(DCDB::Connection* conn);
*
* @param conn Database connection, required to access the database.
*
* @return Pointer to the new JobDataStore object.
* @return Pointer to the new JobDataStore object, or NULL if an error
* occurred.
*
* @details
* Construct a new JobDataStore object via < b>new< \b>.
Always succeeds.
The
* Construct a new JobDataStore object via < b>new< \b>. The
* given Connection object must already be connected to the database,
* otherwise later JobDataStore operations will fail.
*/
...
...
lib/src/c_api.cpp
View file @
c3bd09b2
...
...
@@ -436,14 +436,30 @@ DCDB_C_RESULT dcdbQuerySumMultipleThreaded(
}
Connection
*
connectToDatabase
(
const
char
*
hostname
,
uint16_t
port
)
{
return
NULL
;
Connection
*
conn
=
new
Connection
(
hostname
,
port
);
if
(
!
conn
->
connect
())
{
delete
conn
;
return
NULL
;
}
//dcdbConn->initSchema();
return
conn
;
}
DCDB_C_RESULT
disconnectFromDatabase
(
Connection
*
conn
)
{
if
(
conn
)
{
conn
->
disconnect
();
delete
conn
;
}
return
DCDB_C_OK
;
}
JobDataStore
*
constructJobDataStore
(
Connection
*
conn
)
{
if
(
conn
)
{
return
new
JobDataStore
(
conn
);
}
return
NULL
;
}
...
...
@@ -451,9 +467,28 @@ DCDB_C_RESULT insertJobIntoDatabase(JobDataStore* jds, JobId jid,
UserId
uid
,
uint64_t
startTs
,
uint64_t
endTs
,
const
char
**
nodes
,
unsigned
nodeSize
)
{
JobData
jdata
;
jdata
.
jobId
=
jid
;
jdata
.
userId
=
uid
;
jdata
.
startTime
=
startTs
;
jdata
.
endTime
=
endTs
;
for
(
unsigned
i
=
0
;
i
<
nodeSize
;
i
++
)
{
jdata
.
nodes
.
push_back
(
nodes
[
i
]);
}
JDError
ret
=
jds
->
insertJob
(
jdata
);
if
(
ret
==
JD_OK
)
{
return
DCDB_C_OK
;
}
else
if
(
ret
==
JD_BADPARAMS
)
{
return
DCDB_C_BADPARAMS
;
}
return
DCDB_C_UNKNOWN
;
}
DCDB_C_RESULT
destructJobDataStore
(
JobDataStore
*
jds
)
{
if
(
jds
)
{
delete
jds
;
}
return
DCDB_C_OK
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment