Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-julialib
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-julialib
Commits
d70e76f0
Verified
Commit
d70e76f0
authored
3 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: release result set
parent
ad8acfa5
No related branches found
No related tags found
1 merge request
!12
F release results
Pipeline
#13214
failed
3 years ago
Stage: info
Stage: code-style
Stage: setup
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Transaction.jl
+84
-11
84 additions, 11 deletions
src/Transaction.jl
with
84 additions
and
11 deletions
src/Transaction.jl
+
84
−
11
View file @
d70e76f0
...
...
@@ -433,6 +433,46 @@ function get_result_at(results::Ref{_ResultSet}, index::Cint)
return
entity
end
"""
function _release_result_at(results::Ref{_ResultSet}, index::Cint)
Return the entity at position `index` of the given `results`.
This function releases the entity from the result set and leaves the result set
in a corrupted state. It should only be used to release the entity from a
result set which is about to be destroyed anyway.
"""
function
_release_result_at
(
results
::
Ref
{
_ResultSet
},
index
::
Cint
)
size
=
release_result_size
(
results
)
if
index
>
size
throw
(
DomainError
(
index
,
"You tried to access the result at position
$
index but the result set only has
$
size results."
,
),
)
end
entity
=
Ref
{
CaosDB
.
Entity
.
_Entity
}(
CaosDB
.
Entity
.
_Entity
())
err_code
=
ccall
(
# TODO (fspreck) this is the only difference to get_result_at(...). Is
# there a smart way to reduce the code duplication here?
(
:
caosdb_transaction_result_set_release_at
,
CaosDB
.
library_name
),
Cint
,
(
Ref
{
_ResultSet
},
Ref
{
CaosDB
.
Entity
.
_Entity
},
Cint
),
results
,
entity
,
index
-
Cint
(
1
),
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
return
entity
end
"""
function get_result_at(results::Ref{_ResultSet}, index::Integer)
...
...
@@ -448,7 +488,7 @@ end
"""
function get_results(result_set::Ref{_ResultSet})
Return al
result
s of the given `result_set`.
Return al
l entitie
s of the given `result_set`.
"""
function
get_results
(
result_set
::
Ref
{
_ResultSet
})
...
...
@@ -469,6 +509,39 @@ function get_results(transaction::Ref{_Transaction})
return
get_results
(
result_set
)
end
"""
function _release_results(transaction::Ref{_Transaction})
Return all results fo the given `transaction`.
This function also leaves the transaction object in a corrupted state and
should only be used to release the results from a transaction which is about to
be destroyed anyway.
"""
function
_release_results
(
transaction
::
Ref
{
_Transaction
})
result_set
=
get_result_set
(
transaction
)
return
_release_results
(
result_set
)
end
"""
function _release_results(transaction::Ref{_ResultSet})
Return all entities of the given `result_set`.
This function also leaves the result_set object in a corrupted state and
should only be used to release the entities from a result_set which is about to
be destroyed anyway.
"""
function
_release_results
(
transaction
::
Ref
{
_ResultSet
})
size
=
get_result_size
(
result_set
)
return
[
_release_result_at
(
result_set
,
Cint
(
ii
))
for
ii
=
1
:
size
]
end
"""
function execute_query(
query::AbstractString,
...
...
@@ -495,7 +568,7 @@ function execute_query(query::AbstractString, name::AbstractString = "default")
execute
(
transaction
)
return
get
_results
(
transaction
)
return
_release
_results
(
transaction
)
end
"""
...
...
@@ -526,7 +599,7 @@ function execute_query(
execute
(
transaction
)
return
get
_results
(
transaction
)
return
_release
_results
(
transaction
)
end
"""
...
...
@@ -544,7 +617,7 @@ function retrieve(id::AbstractString, name::AbstractString = "default")
execute
(
transaction
)
return
get
_results
(
transaction
)[
1
]
return
_release
_results
(
transaction
)[
1
]
end
"""
...
...
@@ -561,7 +634,7 @@ function retrieve(id::AbstractString, connection::Ref{CaosDB.Connection._Connect
execute
(
transaction
)
return
get
_results
(
transaction
)[
1
]
return
_release
_results
(
transaction
)[
1
]
end
"""
...
...
@@ -585,7 +658,7 @@ function retrieve(
execute
(
transaction
)
return
get
_results
(
transaction
)
return
_release
_results
(
transaction
)
end
"""
...
...
@@ -608,7 +681,7 @@ function retrieve(
execute
(
transaction
)
return
get
_results
(
transaction
)
return
_release
_results
(
transaction
)
end
"""
function insert_entity(entity::Ref{CaosDB.Entity._Entity})
...
...
@@ -620,7 +693,7 @@ function insert_entity(entity::Ref{CaosDB.Entity._Entity})
transaction
=
create_transaction
()
add_insert_entity
(
transaction
,
entity
)
execute
(
transaction
)
return
get
_results
(
transaction
)
return
_release
_results
(
transaction
)
end
"""
function update_entity(entity::Ref{CaosDB.Entity._Entity})
...
...
@@ -632,7 +705,7 @@ function update_entity(entity::Ref{CaosDB.Entity._Entity})
transaction
=
create_transaction
()
add_update_entity
(
transaction
,
entity
)
execute
(
transaction
)
return
get
_results
(
transaction
)
return
_release
_results
(
transaction
)
end
"""
function delete_by_id(id::AbstractString)
...
...
@@ -644,7 +717,7 @@ function delete_by_id(id::AbstractString)
transaction
=
create_transaction
()
add_delete_by_id
(
transaction
,
id
)
execute
(
transaction
)
return
get
_results
(
transaction
)
return
_release
_results
(
transaction
)
end
"""
function retrieve_and_download_file_by_id(
...
...
@@ -659,7 +732,7 @@ function retrieve_and_download_file_by_id(id::AbstractString, download_path::Abs
transaction
=
create_transaction
()
add_retrieve_and_download_file_by_id
(
transaction
,
id
,
download_path
)
execute
(
transaction
)
return
get
_results
(
transaction
)
return
_release
_results
(
transaction
)
end
end
# Transaction
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