Skip to content

Commit

Permalink
Find record ID from pattern directly (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
eaasna authored Sep 8, 2023
1 parent e886796 commit c897ab5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
7 changes: 0 additions & 7 deletions include/stellar/query_id_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ namespace stellar
template <typename TAlphabet, typename TId = CharString>
struct QueryIDMap
{
size_t recordID(StellarSwiftPattern<TAlphabet> const & pattern) const
{
StellarQuerySegment<TAlphabet> querySegment
= StellarQuerySegment<TAlphabet>::fromPatternMatch(pattern);
return recordID(querySegment.underlyingQuery());
}

size_t recordID(String<TAlphabet> const & query) const
{
String<TAlphabet> const * begin = &queries[0];
Expand Down
18 changes: 14 additions & 4 deletions include/stellar/stellar_index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ struct StellarIndex
: StellarIndex{convertImplStringSet(queries), options}
{}

StellarIndex(StringSet<TInfixSegment> const & queries, IndexOptions const & options)
: StellarIndex{convertSegmentStringSet(queries), options}
{}

StellarIndex(std::span<TInfixSegment> const & queries, IndexOptions const & options)
: StellarIndex{convertImplSpan(queries), options}
{}
Expand Down Expand Up @@ -106,18 +110,24 @@ struct StellarIndex
}

template <typename TSpec>
static StellarQGramStringSet<TAlphabet> convertImplStringSet(StringSet<TSequence, TSpec> const & queries)
static TQGramStringSet convertImplStringSet(StringSet<TSequence, TSpec> const & queries)
{
StellarQGramStringSet<TAlphabet> dependentQueries;
TQGramStringSet dependentQueries;
for (TSequence const & query: queries)
seqan2::appendValue(dependentQueries, seqan2::infix(query, 0, seqan2::length(query)));

return dependentQueries;
}

static StellarQGramStringSet<TAlphabet> convertImplSpan(std::span<TInfixSegment> const & queries)
static TQGramStringSet convertSegmentStringSet(StringSet<TInfixSegment> const & queries)
{
TQGramStringSet dependentQueries = queries;
return dependentQueries;
}

static TQGramStringSet convertImplSpan(std::span<TInfixSegment> const & queries)
{
StellarQGramStringSet<TAlphabet> dependentQueries;
TQGramStringSet dependentQueries;
for (TInfixSegment const & query: queries)
seqan2::appendValue(dependentQueries, query);

Expand Down
10 changes: 2 additions & 8 deletions include/stellar/stellar_launcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,7 @@ struct StellarLauncher

auto getQueryMatches = [&](auto const & pattern) -> QueryMatches<StellarMatch<TSequence const, TId> > &
{
// Note: Index is normally build over all queries [query0, query1, query2, ...],
// but in LocalQueryPrefilter case it can just be build over [query0].
// We need to translate that position to a "record" ID
//!TODO: this shouldn't be necessary
// each Stellar instance should be given a set of bin query, all of which should be indexed
size_t const queryRecordID = queryIDMap.recordID(pattern);
return value(localMatches, queryRecordID);
return value(localMatches, pattern.curSeqNo);
};

auto isPatternDisabled = [&](StellarSwiftPattern<TAlphabet> & pattern) -> bool {
Expand All @@ -97,7 +91,7 @@ struct StellarLauncher
localOptions.disableThresh,
// compactThresh is basically an output-parameter; will be updated in kernel and propagated back
// outside of this function, the reason why StellarOptions can't be passed as const to this function.
// TODO: We might want to make this tied to the QueryMatches itself, as it should know then to consolidate
//!TODO: We might want to make this tied to the QueryMatches itself, as it should know then to consolidate
// the matches
localOptions.compactThresh,
localOptions.numMatches
Expand Down

0 comments on commit c897ab5

Please sign in to comment.