Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
HEPnOS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sds
HEPnOS
Commits
112524ec
Commit
112524ec
authored
Apr 10, 2018
by
Matthieu Dorier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added possibility to find datasets
parent
f1ef1c30
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
17 deletions
+78
-17
DataSet.hpp
include/hepnos/DataSet.hpp
+3
-1
DataStore.hpp
include/hepnos/DataStore.hpp
+4
-1
DataSet.cpp
src/DataSet.cpp
+6
-1
DataStore.cpp
src/DataStore.cpp
+64
-14
example.cpp
test/example.cpp
+1
-0
No files found.
include/hepnos/DataSet.hpp
View file @
112524ec
...
...
@@ -11,9 +11,11 @@ class DataSet {
private:
DataSet
();
DataSet
(
DataStore
&
ds
,
uint8_t
level
,
const
std
::
string
&
name
);
DataStore
&
m_datastore
;
DataStore
*
m_datastore
;
uint8_t
m_level
;
std
::
string
m_name
;
};
...
...
include/hepnos/DataStore.hpp
View file @
112524ec
...
...
@@ -59,9 +59,11 @@ class DataStore::const_iterator {
protected:
DataStore
*
m_datastore
;
class
Impl
;
std
::
unique_ptr
<
Impl
>
m_impl
;
const_iterator
(
DataStore
&
ds
);
const_iterator
(
DataStore
&
ds
,
const
DataSet
&
current
);
public:
...
...
@@ -94,6 +96,7 @@ class DataStore::iterator : public DataStore::const_iterator {
private:
iterator
(
DataStore
&
ds
);
iterator
(
DataStore
&
ds
,
const
DataSet
&
current
);
public:
...
...
src/DataSet.cpp
View file @
112524ec
...
...
@@ -2,8 +2,13 @@
namespace
hepnos
{
DataSet
::
DataSet
()
:
m_datastore
(
nullptr
)
,
m_level
(
0
)
,
m_name
(
""
)
{}
DataSet
::
DataSet
(
DataStore
&
ds
,
uint8_t
level
,
const
std
::
string
&
name
)
:
m_datastore
(
ds
)
:
m_datastore
(
&
ds
)
,
m_level
(
level
)
,
m_name
(
name
)
{}
...
...
src/DataStore.cpp
View file @
112524ec
...
...
@@ -251,11 +251,32 @@ DataStore::~DataStore() {
}
DataStore
::
iterator
DataStore
::
find
(
const
std
::
string
&
datasetName
)
{
// TODO
int
ret
;
if
(
datasetName
.
find
(
'/'
)
!=
std
::
string
::
npos
)
{
throw
Exception
(
"Invalid character '/' in dataset name"
);
}
DataStoreEntryPtr
entry
=
make_datastore_entry
(
0
,
datasetName
);
// find which sdskv provider to contact
uint64_t
h
=
std
::
hash
<
std
::
string
>
()(
datasetName
);
unsigned
long
provider_idx
;
ch_placement_find_closest
(
m_impl
->
m_chi_sdskv
,
h
,
1
,
&
provider_idx
);
// find the size of the value, as a way to check if the key exists
auto
ph
=
m_impl
->
m_sdskv_ph
[
provider_idx
];
auto
db_id
=
m_impl
->
m_sdskv_db
[
provider_idx
];
hg_size_t
vsize
;
ret
=
sdskv_length
(
ph
,
db_id
,
entry
->
raw
(),
entry
->
length
(),
&
vsize
);
if
(
ret
==
SDSKV_ERR_UNKNOWN_KEY
)
{
return
end
();
}
if
(
ret
!=
SDSKV_SUCCESS
)
{
throw
Exception
(
"Error occured when calling sdskv_length"
);
}
return
iterator
(
*
this
,
DataSet
(
*
this
,
0
,
datasetName
));
}
DataStore
::
const_iterator
DataStore
::
find
(
const
std
::
string
&
datasetName
)
const
{
// TODO
DataStore
::
iterator
it
=
const_cast
<
DataStore
*>
(
this
)
->
find
(
datasetName
);
return
it
;
}
DataStore
::
iterator
DataStore
::
begin
()
{
...
...
@@ -309,9 +330,35 @@ DataSet DataStore::createDataSet(const std::string& name) {
return
DataSet
(
*
this
,
0
,
name
);
}
class
DataStore
::
const_iterator
::
Impl
{
public:
DataStore
*
m_datastore
;
DataSet
m_current_dataset
;
bool
m_is_valid
;
Impl
(
DataStore
&
ds
)
:
m_datastore
(
&
ds
)
,
m_current_dataset
()
,
m_is_valid
(
false
)
{}
Impl
(
DataStore
&
ds
,
const
DataSet
&
dataset
)
:
m_datastore
(
&
ds
)
,
m_current_dataset
(
dataset
)
,
m_is_valid
(
true
)
{}
Impl
(
const
Impl
&
other
)
:
m_datastore
(
other
.
m_datastore
)
,
m_current_dataset
(
other
.
m_current_dataset
)
,
m_is_valid
(
other
.
m_is_valid
)
{}
};
DataStore
::
const_iterator
::
const_iterator
(
DataStore
&
ds
)
:
m_datastore
(
&
ds
)
{
// TODO
:
m_impl
(
std
::
make_unique
<
Impl
>
(
ds
))
{
}
DataStore
::
const_iterator
::
const_iterator
(
DataStore
&
ds
,
const
DataSet
&
dataset
)
:
m_impl
(
std
::
make_unique
<
Impl
>
(
ds
,
dataset
))
{
}
DataStore
::
const_iterator
::~
const_iterator
()
{
...
...
@@ -319,12 +366,11 @@ DataStore::const_iterator::~const_iterator() {
}
DataStore
::
const_iterator
::
const_iterator
(
const
DataStore
::
const_iterator
&
other
)
:
m_datastore
(
other
.
m_datastore
)
{
// TODO
:
m_impl
(
std
::
make_unique
<
Impl
>
(
*
other
.
m_impl
))
{
}
DataStore
::
const_iterator
::
const_iterator
(
DataStore
::
const_iterator
&&
other
)
:
m_
datastore
(
other
.
m_datastore
)
{
:
m_
impl
(
std
::
move
(
other
.
m_impl
)
)
{
// TODO
}
...
...
@@ -360,10 +406,11 @@ bool DataStore::const_iterator::operator!=(const self_type& rhs) const {
// TODO
}
DataStore
::
iterator
::
iterator
(
DataStore
&
ds
)
:
const_iterator
(
ds
)
{
// TODO
}
DataStore
::
iterator
::
iterator
(
DataStore
&
ds
,
const
DataSet
&
current
)
:
const_iterator
(
ds
,
current
)
{}
DataStore
::
iterator
::
iterator
(
DataStore
&
ds
)
:
const_iterator
(
ds
)
{}
DataStore
::
iterator
::~
iterator
()
{
// TODO
...
...
@@ -380,12 +427,15 @@ DataStore::iterator::iterator(DataStore::iterator&& other)
}
DataStore
::
iterator
&
DataStore
::
iterator
::
operator
=
(
const
DataStore
::
iterator
&
other
)
{
m_datastore
=
other
.
m_datastore
;
// TODO
if
(
this
==
&
other
)
return
*
this
;
m_impl
=
std
::
make_unique
<
Impl
>
(
*
other
.
m_impl
);
return
*
this
;
}
DataStore
::
iterator
&
DataStore
::
iterator
::
operator
=
(
DataStore
::
iterator
&&
other
)
{
m_datastore
=
other
.
m_datastore
;
if
(
this
==
&
other
)
return
*
this
;
m_impl
=
std
::
move
(
other
.
m_impl
);
return
*
this
;
}
DataStore
::
iterator
::
reference
DataStore
::
iterator
::
operator
*
()
{
...
...
test/example.cpp
View file @
112524ec
...
...
@@ -8,6 +8,7 @@ int main(int argc, char** argv) {
DataStore
datastore
(
argv
[
1
]);
DataSet
dataset
=
datastore
.
createDataSet
(
"myproject"
);
auto
it
=
datastore
.
find
(
"myproject"
);
return
0
;
}
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