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

Compressed bit parallel index ranked bar notation

parent 6771c3c2
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,8 @@ indexes::arbology::CompressedBitParallelTreeIndex < std::ranked_symbol < Default
 
auto compressedBitParallelIndexConstructionPrefixRankedTree = CompressedBitParallelIndexConstruction::RegistratorWrapper < indexes::arbology::CompressedBitParallelTreeIndex < std::ranked_symbol < DefaultSymbolType, DefaultRankType > >, tree::PrefixRankedTree < > > ( CompressedBitParallelIndexConstruction::construct );
 
auto compressedBitParallelIndexConstructionPrefixRankedBarTree = CompressedBitParallelIndexConstruction::RegistratorWrapper < indexes::arbology::CompressedBitParallelTreeIndex < std::ranked_symbol < DefaultSymbolType, DefaultRankType > >, tree::PrefixRankedBarTree < > > ( CompressedBitParallelIndexConstruction::construct );
} /* namespace indexing */
 
} /* namespace arbology */
......@@ -11,6 +11,7 @@
#include <indexes/arbology/CompressedBitParallelTreeIndex.h>
#include <tree/RankedTreeWrapper.h>
#include <tree/ranked/PrefixRankedTree.h>
#include <tree/ranked/PrefixRankedBarTree.h>
#include <core/multipleDispatch.hpp>
#include <exception/CommonException.h>
#include <tree/properties/SubtreeJumpTable.h>
......@@ -35,6 +36,9 @@ public:
 
template < class SymbolType, class RankType >
static indexes::arbology::CompressedBitParallelTreeIndex < std::ranked_symbol < SymbolType, RankType > > construct ( const tree::PrefixRankedTree < SymbolType, RankType > & tree );
template < class SymbolType, class RankType >
static indexes::arbology::CompressedBitParallelTreeIndex < std::ranked_symbol < SymbolType, RankType > > construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & tree );
};
 
template < class SymbolType, class RankType >
......@@ -50,6 +54,19 @@ indexes::arbology::CompressedBitParallelTreeIndex < std::ranked_symbol < SymbolT
return indexes::arbology::CompressedBitParallelTreeIndex < std::ranked_symbol < SymbolType, RankType > > ( w.getAlphabet ( ), res, tree::properties::SubtreeJumpTable::compute ( w ) );
}
 
template < class SymbolType, class RankType >
indexes::arbology::CompressedBitParallelTreeIndex < std::ranked_symbol < SymbolType, RankType > > CompressedBitParallelIndexConstruction::construct ( const tree::PrefixRankedBarTree < SymbolType, RankType > & w ) {
std::map < std::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > res;
for ( const std::ranked_symbol < SymbolType, RankType > & symbol : w.getAlphabet ( ) )
res [ symbol ].resize ( w.getContent ( ).size ( ) );
for ( unsigned i = 0; i < w.getContent ( ).size ( ); ++i )
res [ w.getContent ( ) [ i ] ] [ i ] = true;
return indexes::arbology::CompressedBitParallelTreeIndex < std::ranked_symbol < SymbolType, RankType > > ( w.getAlphabet ( ), res, tree::properties::SubtreeJumpTable::compute ( w ) );
}
} /* namespace indexing */
 
} /* namespace arbology */
......
......@@ -18,6 +18,7 @@ std::set < unsigned > CompressedBitParallelismPatterns::query ( const indexes::a
}
 
auto CompressedBitParallelismPatternsPrefixRankedPattern = CompressedBitParallelismPatterns::RegistratorWrapper < std::set < unsigned >, tree::PrefixRankedPattern < > > ( CompressedBitParallelismPatterns::query );
auto CompressedBitParallelismPatternsPrefixRankedBarPattern = CompressedBitParallelismPatterns::RegistratorWrapper < std::set < unsigned >, tree::PrefixRankedBarPattern < > > ( CompressedBitParallelismPatterns::query );
 
} /* namespace query */
 
......
......@@ -10,7 +10,8 @@
 
#include <indexes/arbology/CompressedBitParallelTreeIndex.h>
#include <tree/RankedTreeWrapper.h>
#include <tree/ranked/PrefixRankedTree.h>
#include <tree/ranked/PrefixRankedPattern.h>
#include <tree/ranked/PrefixRankedBarPattern.h>
#include <core/multipleDispatch.hpp>
#include <global/GlobalData.h>
 
......@@ -36,6 +37,9 @@ public:
 
template < class SymbolType, class RankType >
static std::set < unsigned > query ( const indexes::arbology::CompressedBitParallelTreeIndex < std::ranked_symbol < SymbolType, RankType > > & compressedBitParallelTreeIndex, const tree::PrefixRankedPattern < SymbolType, RankType > & pattern );
template < class SymbolType, class RankType >
static std::set < unsigned > query ( const indexes::arbology::CompressedBitParallelTreeIndex < std::ranked_symbol < SymbolType, RankType > > & compressedBitParallelTreeIndex, const tree::PrefixRankedBarPattern < SymbolType, RankType > & pattern );
};
 
template < class SymbolType, class RankType >
......@@ -76,6 +80,46 @@ std::set < unsigned > CompressedBitParallelismPatterns::query ( const indexes::a
return res;
}
 
template < class SymbolType, class RankType >
std::set < unsigned > CompressedBitParallelismPatterns::query ( const indexes::arbology::CompressedBitParallelTreeIndex < std::ranked_symbol < SymbolType, RankType > > & compressedBitParallelIndex, const tree::PrefixRankedBarPattern < SymbolType, RankType > & pattern ) {
auto symbolIter = pattern.getContent ( ).begin ( );
typename std::map < std::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector >::const_iterator symbolVectorIter = compressedBitParallelIndex.getData ( ).find ( * symbolIter );
if ( symbolVectorIter == compressedBitParallelIndex.getData ( ).end ( ) )
return { };
common::SparseBoolVector indexVector = symbolVectorIter->second;
for ( ++ symbolIter; symbolIter != pattern.getContent ( ).end ( ); ++ symbolIter ) {
if ( * symbolIter == pattern.getSubtreeWildcard ( ) ) {
common::SparseBoolVector newVector;
newVector.resize ( indexVector.size ( ) );
for ( unsigned i : ( indexVector << 1 ) )
newVector [ compressedBitParallelIndex.getJumps ( ) [ i ] - 1 ] = true;
indexVector = newVector;
++ symbolIter;
} else {
symbolVectorIter = compressedBitParallelIndex.getData ( ).find ( * symbolIter );
if ( symbolVectorIter == compressedBitParallelIndex.getData ( ).end ( ) )
return { };
indexVector = ( indexVector << 1 ) & symbolVectorIter->second;
}
}
std::set < unsigned > res;
for ( unsigned i : indexVector )
res.insert ( i + 1 );
return res;
}
} /* namespace query */
 
} /* namespace arbology */
......
......@@ -412,6 +412,8 @@ function runTestNonlinearPatternEnds {
 
runTestPattern "Exact Pattern Matching Using Full And Linear Index (PrefixRanked)" "./aarbology2 -a fullAndLinearIndex -s <(./acast2 -t PrefixRankedTree -i \"\$SUBJECT_FILE\" ) | ./aquery2 -q fullAndLinearIndexPatterns -i - -p <( ./acast2 -t PrefixRankedPattern -i \"\$PATTERN_FILE\" ) | ./astat2 -p size"
 
runTestPattern "Exact Pattern Matching Using Compressed Bit Vectors (PrefixRankedBar)" "./aarbology2 -a compressedBitParallelIndex -s <(./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" ) | ./aquery2 -q compressedBitParallelismPatterns -i - -p <( ./acast2 -t PrefixRankedBarPattern -i \"\$PATTERN_FILE\" ) | ./astat2 -p size"
runTestPatternEnds "Exact Pattern Matching Using Compressed Bit Vectors (PrefixRanked)" "./aarbology2 -a compressedBitParallelIndex -s <(./acast2 -t PrefixRankedTree -i \"\$SUBJECT_FILE\" ) | ./aquery2 -q compressedBitParallelismPatterns -i - -p <( ./acast2 -t PrefixRankedPattern -i \"\$PATTERN_FILE\" ) | ./astat2 -p size"
 
runTestPatternEnds "Exact Pattern Matching Automaton (PrefixRanked)" "./aarbology2 -a exactPatternMatchingAutomaton -p <(./acast2 -t PrefixRankedPattern -i <(./aaccess2 --tree alphabet -o add -i \"\$PATTERN_FILE\" -a <( ./aaccess2 --tree alphabet -o get -i \"\$SUBJECT_FILE\" ) ) ) | ./adeterminize2 | ./arun2 -t occurrences -a - -i <( ./acast2 -t PrefixRankedTree -i \"\$SUBJECT_FILE\" | ./acast2 -t LinearString ) | ./astat2 -p size"
......
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