Skip to content
Snippets Groups Projects
Commit 219203e5 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

fix full and linear index for trees

parent 576f5317
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -31,20 +31,20 @@ public:
* @return the index
*/
template < class SymbolType, class RankType, template < typename > class StringIndex = indexes::stringology::PositionHeap, class StringIndexConstructionAlgo = stringology::indexing::PositionHeapNaive >
static indexes::arbology::FullAndLinearIndex < SymbolType, RankType > construct ( const tree::PrefixRankedTree < SymbolType, RankType > & tree );
static indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > construct ( const tree::PrefixRankedTree < SymbolType, RankType > & tree );
 
template < class SymbolType, class RankType, template < typename > class StringIndex = indexes::stringology::PositionHeap, class StringIndexConstructionAlgo = stringology::indexing::PositionHeapNaive >
static indexes::arbology::FullAndLinearIndex < SymbolType, RankType > construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & tree );
static indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & tree );
};
 
template < class SymbolType, class RankType, template < typename > class StringIndex, class StringIndexConstructionAlgo >
indexes::arbology::FullAndLinearIndex < SymbolType, RankType > FullAndLinearIndexConstruction::construct ( const tree::PrefixRankedTree < SymbolType, RankType > & w ) {
return indexes::arbology::FullAndLinearIndex < SymbolType, RankType > ( StringIndexConstructionAlgo::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ) );
indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > FullAndLinearIndexConstruction::construct ( const tree::PrefixRankedTree < SymbolType, RankType > & w ) {
return indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > ( StringIndexConstructionAlgo::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ) );
}
 
template < class SymbolType, class RankType, template < typename > class StringIndex, class StringIndexConstructionAlgo >
indexes::arbology::FullAndLinearIndex < SymbolType, RankType > FullAndLinearIndexConstruction::construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & w ) {
return indexes::arbology::FullAndLinearIndex < SymbolType, RankType > ( StringIndexConstructionAlgo::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ) );
indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > FullAndLinearIndexConstruction::construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & w ) {
return indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > ( StringIndexConstructionAlgo::construct ( string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( w ) ), tree::properties::SubtreeJumpTable::compute ( w ) );
}
 
} /* namespace indexing */
......
......@@ -42,7 +42,7 @@ class GeneralAlphabet;
template < class SymbolType = DefaultSymbolType, class RankType = DefaultRankType, template < typename > class StringIndex = indexes::stringology::PositionHeap >
class FullAndLinearIndex final : public object::ObjectBase {
protected:
indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > m_StringIndex;
StringIndex < common::ranked_symbol < SymbolType, RankType > > m_StringIndex;
ext::vector < int > m_JumpTable;
 
public:
......@@ -56,14 +56,14 @@ public:
*/
virtual ObjectBase * plunder ( ) &&;
 
explicit FullAndLinearIndex ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex, ext::vector < int > jumpTable );
explicit FullAndLinearIndex ( StringIndex < common::ranked_symbol < SymbolType, RankType > > stringIndex, ext::vector < int > jumpTable );
 
/**
* @return Root node of the trie
*/
const indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > & getStringIndex ( ) const &;
const StringIndex < common::ranked_symbol < SymbolType, RankType > > & getStringIndex ( ) const &;
 
indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > && getStringIndex ( ) &&;
StringIndex < common::ranked_symbol < SymbolType, RankType > > && getStringIndex ( ) &&;
 
/**
* @return subtree jump table
......@@ -84,7 +84,7 @@ public:
* Sets the compressedBit vector for given symbol
* @param tree root node to set
*/
void setStringIndex ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex );
void setStringIndex ( StringIndex < common::ranked_symbol < SymbolType, RankType > > stringIndex );
 
/**
* Removes symbol from the alphabet of symbol available in the regular expression
......@@ -125,7 +125,7 @@ namespace indexes {
namespace arbology {
 
template < class SymbolType, class RankType, template < typename > class StringIndex >
FullAndLinearIndex < SymbolType, RankType, StringIndex >::FullAndLinearIndex ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex, ext::vector < int > jumpTable ) : m_StringIndex ( std::move ( stringIndex ) ), m_JumpTable ( std::move ( jumpTable ) ) {
FullAndLinearIndex < SymbolType, RankType, StringIndex >::FullAndLinearIndex ( StringIndex < common::ranked_symbol < SymbolType, RankType > > stringIndex, ext::vector < int > jumpTable ) : m_StringIndex ( std::move ( stringIndex ) ), m_JumpTable ( std::move ( jumpTable ) ) {
}
 
template < class SymbolType, class RankType, template < typename > class StringIndex >
......@@ -139,12 +139,12 @@ object::ObjectBase * FullAndLinearIndex < SymbolType, RankType, StringIndex >::p
}
 
template < class SymbolType, class RankType, template < typename > class StringIndex >
const indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > & FullAndLinearIndex < SymbolType, RankType, StringIndex >::getStringIndex ( ) const & {
const StringIndex < common::ranked_symbol < SymbolType, RankType > > & FullAndLinearIndex < SymbolType, RankType, StringIndex >::getStringIndex ( ) const & {
return m_StringIndex;
}
 
template < class SymbolType, class RankType, template < typename > class StringIndex >
indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > && FullAndLinearIndex < SymbolType, RankType, StringIndex >::getStringIndex ( ) && {
StringIndex < common::ranked_symbol < SymbolType, RankType > > && FullAndLinearIndex < SymbolType, RankType, StringIndex >::getStringIndex ( ) && {
return std::move ( m_StringIndex );
}
 
......@@ -159,7 +159,7 @@ ext::vector < int > && FullAndLinearIndex < SymbolType, RankType, StringIndex >:
}
 
template < class SymbolType, class RankType, template < typename > class StringIndex >
void FullAndLinearIndex < SymbolType, RankType, StringIndex >::setStringIndex ( indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex ) {
void FullAndLinearIndex < SymbolType, RankType, StringIndex >::setStringIndex ( StringIndex < common::ranked_symbol < SymbolType, RankType > > stringIndex ) {
this->m_StringIndex = std::move ( stringIndex );
}
 
......@@ -199,7 +199,7 @@ namespace core {
template < class SymbolType, class RankType, template < typename > class StringIndex >
struct normalize < indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex >, typename std::enable_if < ! std::is_same < indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex >, indexes::arbology::FullAndLinearIndex < > >::value >::type > {
static indexes::arbology::FullAndLinearIndex < > eval ( indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > && value ) {
indexes::stringology::PositionHeap < common::ranked_symbol < > > stringIndex = core::normalize < indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > >::eval ( std::move ( value ).getStringIndex ( ) );
StringIndex < common::ranked_symbol < > > stringIndex = core::normalize < StringIndex < common::ranked_symbol < SymbolType, RankType > > >::eval ( std::move ( value ).getStringIndex ( ) );
 
return indexes::arbology::FullAndLinearIndex < > ( std::move ( stringIndex ), std::move ( value ).getJumps ( ) );
}
......@@ -216,7 +216,7 @@ struct xmlApi < indexes::arbology::FullAndLinearIndex < SymbolType, RankType, St
template < class SymbolType, class RankType, template < typename > class StringIndex >
indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > xmlApi < indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > >::parse ( ext::deque < sax::Token >::iterator & input ) {
sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, xmlTagName ( ) );
indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > stringIndex = core::xmlApi < indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > >::parse ( input );
StringIndex < common::ranked_symbol < SymbolType, RankType > > stringIndex = core::xmlApi < StringIndex < common::ranked_symbol < SymbolType, RankType > > >::parse ( input );
ext::vector < int > jumps = core::xmlApi < ext::vector < int > >::parse ( input );
 
indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > res ( std::move ( stringIndex ), std::move ( jumps ) );
......@@ -240,7 +240,7 @@ const std::string & xmlApi < indexes::arbology::FullAndLinearIndex < SymbolType,
template < class SymbolType, class RankType, template < typename > class StringIndex >
void xmlApi < indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > >::compose ( ext::deque < sax::Token > & output, const indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > & index ) {
output.emplace_back ( xmlTagName ( ), sax::Token::TokenType::START_ELEMENT );
core::xmlApi < indexes::stringology::PositionHeap < common::ranked_symbol < SymbolType, RankType > > >::compose ( output, index.getStringIndex ( ) );
core::xmlApi < StringIndex < common::ranked_symbol < SymbolType, RankType > > >::compose ( output, index.getStringIndex ( ) );
core::xmlApi < ext::vector < int > >::compose ( output, index.getJumps ( ) );
output.emplace_back ( xmlTagName ( ), sax::Token::TokenType::END_ELEMENT );
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment