Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-cpplib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-cpplib
Commits
d2de078d
Verified
Commit
d2de078d
authored
3 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Plain Diff
Merge branch 'f-query' of gitlab.indiscale.com:caosdb/src/caosdb-cpplib into f-query
parents
31dc1d79
6f470c60
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!7
ENH: Support FIND and COUNT queries
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/caosdb/transaction.h
+12
-0
12 additions, 0 deletions
include/caosdb/transaction.h
src/caosdb/transaction.cpp
+22
-5
22 additions, 5 deletions
src/caosdb/transaction.cpp
with
34 additions
and
5 deletions
include/caosdb/transaction.h
+
12
−
0
View file @
d2de078d
...
@@ -368,6 +368,17 @@ public:
...
@@ -368,6 +368,17 @@ public:
return
*
result_set
;
return
*
result_set
;
}
}
/**
* Return the result of a count query
*
* Only meaningful if there was exactly one COUNT query executed in
* this transaction. In all other cases, the return value will be
* -1.
*/
[[
nodiscard
]]
inline
auto
GetCountResult
()
const
->
int
{
return
query_count
;
}
/**
/**
* Return the number of sub-requests in this transaction.
* Return the number of sub-requests in this transaction.
*
*
...
@@ -394,6 +405,7 @@ private:
...
@@ -394,6 +405,7 @@ private:
MultiTransactionRequest
*
request
;
MultiTransactionRequest
*
request
;
mutable
MultiTransactionResponse
*
response
;
mutable
MultiTransactionResponse
*
response
;
std
::
string
error_message
;
std
::
string
error_message
;
mutable
long
query_count
;
};
};
template
<
class
InputIterator
>
template
<
class
InputIterator
>
...
...
This diff is collapsed.
Click to expand it.
src/caosdb/transaction.cpp
+
22
−
5
View file @
d2de078d
...
@@ -96,6 +96,8 @@ using caosdb::entity::v1alpha1::MultiTransactionRequest;
...
@@ -96,6 +96,8 @@ using caosdb::entity::v1alpha1::MultiTransactionRequest;
using
caosdb
::
entity
::
v1alpha1
::
MultiTransactionResponse
;
using
caosdb
::
entity
::
v1alpha1
::
MultiTransactionResponse
;
using
WrappedResponseCase
=
using
WrappedResponseCase
=
caosdb
::
entity
::
v1alpha1
::
TransactionResponse
::
WrappedResponseCase
;
caosdb
::
entity
::
v1alpha1
::
TransactionResponse
::
WrappedResponseCase
;
using
QueryResponseCase
=
caosdb
::
entity
::
v1alpha1
::
RetrieveResponse
::
QueryResponseCase
;
using
caosdb
::
utility
::
get_arena
;
using
caosdb
::
utility
::
get_arena
;
using
grpc
::
ClientAsyncResponseReader
;
using
grpc
::
ClientAsyncResponseReader
;
using
ProtoEntity
=
caosdb
::
entity
::
v1alpha1
::
Entity
;
using
ProtoEntity
=
caosdb
::
entity
::
v1alpha1
::
Entity
;
...
@@ -146,6 +148,7 @@ Transaction::Transaction(
...
@@ -146,6 +148,7 @@ Transaction::Transaction(
response
(
google
::
protobuf
::
Arena
::
CreateMessage
<
MultiTransactionResponse
>
(
response
(
google
::
protobuf
::
Arena
::
CreateMessage
<
MultiTransactionResponse
>
(
get_arena
()))
{
get_arena
()))
{
this
->
service_stub
=
std
::
move
(
service_stub
);
this
->
service_stub
=
std
::
move
(
service_stub
);
this
->
query_count
=
-
1
;
}
}
auto
Transaction
::
RetrieveById
(
const
std
::
string
&
id
)
noexcept
->
StatusCode
{
auto
Transaction
::
RetrieveById
(
const
std
::
string
&
id
)
noexcept
->
StatusCode
{
...
@@ -282,12 +285,26 @@ auto Transaction::WaitForIt() const noexcept -> TransactionStatus {
...
@@ -282,12 +285,26 @@ auto Transaction::WaitForIt() const noexcept -> TransactionStatus {
auto
*
responses
=
this
->
response
->
mutable_responses
(
0
);
auto
*
responses
=
this
->
response
->
mutable_responses
(
0
);
switch
(
responses
->
wrapped_response_case
())
{
switch
(
responses
->
wrapped_response_case
())
{
case
WrappedResponseCase
::
kRetrieveResponse
:
{
case
WrappedResponseCase
::
kRetrieveResponse
:
{
auto
*
entity
=
responses
->
mutable_retrieve_response
()
->
release_entity
();
auto
*
retrieve_response
=
responses
->
mutable_retrieve_response
();
if
(
!
entity
->
errors
().
empty
())
{
switch
(
retrieve_response
->
query_response_case
())
{
this
->
status
=
TransactionStatus
::
TRANSACTION_ERROR
(
case
QueryResponseCase
::
kEntity
:
{
"The request returned with errors."
);
auto
*
entity
=
retrieve_response
->
release_entity
();
if
(
!
entity
->
errors
().
empty
())
{
this
->
status
=
TransactionStatus
::
TRANSACTION_ERROR
(
"The request returned with errors."
);
}
this
->
result_set
=
std
::
make_unique
<
UniqueResult
>
(
entity
);
}
break
;
case
QueryResponseCase
::
kSelectResult
:
{
// TODO(tf) Select queries
}
break
;
case
QueryResponseCase
::
kCountResult
:
{
this
->
query_count
=
retrieve_response
->
count_result
();
}
break
;
default
:
// TODO(tf) Error
break
;
}
}
this
->
result_set
=
std
::
make_unique
<
UniqueResult
>
(
entity
);
}
break
;
}
break
;
case
WrappedResponseCase
::
kUpdateResponse
:
{
case
WrappedResponseCase
::
kUpdateResponse
:
{
auto
*
updatedIdResponse
=
responses
->
mutable_update_response
();
auto
*
updatedIdResponse
=
responses
->
mutable_update_response
();
...
...
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