-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Node access for fm_index_cursor #2076
Conversation
28fabf7
to
01bffc8
Compare
01bffc8
to
aca183b
Compare
Codecov Report
@@ Coverage Diff @@
## master #2076 +/- ##
=======================================
Coverage 97.95% 97.96%
=======================================
Files 264 264
Lines 10045 10050 +5
=======================================
+ Hits 9840 9845 +5
Misses 205 205
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we wanted to expose the intervals; I'm not in favour for exposing the node. If we can, I would want to hide them. I'm marking this as WIP for now, because it is still not clear what the use case is.
aca183b
to
0f34bf6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks already pretty good, just one question
test/unit/search/fm_index_cursor/fm_index_cursor_collection_test_template.hpp
Outdated
Show resolved
Hide resolved
Core Meeting 2020-09-08We want a Document if half-open or not. // Using half-open interval
struct suffix_array_interval
{
size_t begin_position;
size_t end_position;
};
// Using closed interval
struct suffix_array_interval
{
size_t left_bound;
size_t right_bound;
};
We want to give half-open intervals back. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Waiting on implementing the half-open interval accessor.)
0f34bf6
to
3034c34
Compare
@marehr can you have a quick look at If it is fine, I can start adjusting all the tests and documentation |
looks fine :) Or do you think that something seems odd? |
3034c34
to
ee29592
Compare
@marehr I also added a conversion operator to tuple ... it is nice for the use case where you want to reuse variables (see snippet, structured binding works with aggregate type, but open for discussion auto [left_bound, right_bound] = cur.suffix_array_interval();
/// .. do some stuff with cursor
std::tie(left_bound, right_bound) = cur.suffix_array_interval(); |
ee29592
to
decfff9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome :)
Do we really need the tuple thingy?
Did you find any instances where the interval can be empty?
size_t end_position; | ||
|
||
//!\brief Convert to tuple. | ||
operator std::tuple<size_t &, size_t &>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
operator std::tuple<size_t &, size_t &>() | |
operator std::tuple<size_t &, size_t &>() & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, you can also do this:
struct foo
{
int a;
int b;
};
int main()
{
foo bar{1, 3};
auto & [a, b] = bar;
b = 5;
return bar.b; // has value 5
}
so we don't need a std::tie.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But what I want is
int main()
{
foo bar{1, 3};
auto & [a, b] = bar;
b = 5;
foo bar2{2, 4};
std::tie(a, b) = bar2;
return bar.b; // has value 5
}
I'm not sure if this is really, really needed, but when I wrote the snippets, I assumed that it will work just to find out that it does not. Hence, I added it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried the &
:
It doesn't work because .. ehm .. not so sure...
It would work if we the suffix_array_interval struct wasn't generated by another struct.
decfff9
to
eb2c6fb
Compare
No, the only thing that could happen is that you construct the cursor on an empty index. The most elegant solution would be to use half-open intervals in the FM-index, because then the cursor is always in a valid state (The cursor on an empty index would then use |
eb2c6fb
to
3dbcc99
Compare
size_t end_position; | ||
|
||
//!\brief Convert to tuple. | ||
operator std::tuple<size_t &, size_t &>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
operator std::tuple<size_t &, size_t &>() | |
operator std::tuple<size_t, size_t>() const noexcept |
So this wouldn't work?
Because your version should require that this is an lvalue reference as well. Then the question remains, what is with the other versions const &
should be also added. Move version are not required since we move/copy built-in types anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3dbcc99
to
8d5efe3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far. Some minor change requrests.
@@ -32,6 +32,39 @@ namespace seqan3 | |||
* \{ | |||
*/ | |||
|
|||
//!\brief The underlying suffix array intervals. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//!\brief The underlying suffix array intervals. | |
//!\brief The underlying suffix array interval. |
@@ -44,6 +43,10 @@ TYPED_TEST_P(fm_index_cursor_collection_test, ctr) | |||
// custom constructor | |||
TypeParam it0{fm}; | |||
EXPECT_EQ(it0.query_length(), 0u); | |||
if constexpr (!seqan3::bi_fm_index_specialisation<typename TypeParam::index_type>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this not be part of the test fixture?
@@ -47,6 +46,10 @@ TYPED_TEST_P(fm_index_cursor_test, ctr) | |||
// custom constructor | |||
TypeParam it0{fm}; | |||
EXPECT_EQ(it0.query_length(), 0u); | |||
if constexpr (!seqan3::bi_fm_index_specialisation<typename TypeParam::index_type>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here. So I would call:
if constexpr (!TestFixture::is_bi_fm_index)
{
...
}
8d5efe3
to
279273a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot 👍
Resolves #2061