SIS
Symmetric Index Structures
|
00001 #ifndef INENAGACDAWGADAPTER_CPP 00002 #define INENAGACDAWGADAPTER_CPP 00003 00004 #include "InenagaCDAWGAdapter.hpp" 00005 00006 namespace lmu { namespace cis { namespace sis { 00007 00008 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00009 UINT InenagaCDAWGAdapter::Add( const VoidSequence * documentDollar ) { 00010 if (DEBUG_LEVEL > 5) std::cerr << "inline void InenagaCDAWGAdapter::Add( const VoidSequence * documentDollar )" << std::endl; 00011 00012 assert(ManagedAutomatonStage_ < CLOSED); 00013 00014 return CDAWGAdd( C_CDAWGBuildHelp, documentDollar ); 00015 } 00016 00017 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00018 void InenagaCDAWGAdapter::DumpGV( const S8 * fn, UINT encoding ) const { 00019 if (DEBUG_LEVEL > 5) std::cerr << "virtual inline void InenagaCDAWGAdapter::DumpGV( FILE * fp, void (*DumpLabel)(const SCDAWG *, FILE *, UINT, boolean, UINT), UINT encoding ) const" << std::endl; 00020 00021 assert(ManagedAutomatonStage_ >= SORTED); 00022 00023 FILE * fpOut = Fopen(fn, "wb"); 00024 CompressedAutomatonDumpGV( automaton(), fpOut, DumpLabel, encoding ); 00025 Fclose(fpOut); 00026 } 00027 00028 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00029 void InenagaCDAWGAdapter::Close() { 00030 if (DEBUG_LEVEL > 5) std::cerr << "void InenagaCDAWGAdapter::Close()" << std::endl; 00031 00032 assert( ManagedAutomatonStage_ < CLOSED ); 00033 00034 if ( ManagedAutomatonStage_ < SORTED ) { 00035 SortTransitions(); 00036 } 00037 CDAWGBuildHelpFree(C_CDAWGBuildHelp); 00038 ManagedAutomatonStage_ = CLOSED; 00039 } 00040 00041 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00042 void InenagaCDAWGAdapter::SortTransitions() { 00043 if (DEBUG_LEVEL > 5) std::cerr << "virtual inline void InenagaCDAWGAdapter::SortTransitions()" << std::endl; 00044 00045 assert( ManagedAutomatonStage_ < CLOSED ); 00046 00047 if ( ManagedAutomatonStage_ < SORTED ) { 00048 SortTransitions( C_CDAWGBuildHelp->transitionsFrom ); 00049 } 00050 ManagedAutomatonStage_ = SORTED; 00051 00052 } 00053 00054 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00055 void InenagaCDAWGAdapter::SortTransitions( UINTSequence * _transitionsFrom ) { 00056 if (DEBUG_LEVEL > 5) std::cerr << "virtual inline void InenagaCDAWGAdapter::SortTransitions( UINTSequence * _transitionsFrom )" << std::endl; 00057 if ( ManagedAutomatonStage_ < SORTED ) { 00058 CompressedAutomatonSortTransitions( automaton(), _transitionsFrom ); 00059 } 00060 ManagedAutomatonStage_ = SORTED; 00061 } 00062 00063 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00064 std::string InenagaCDAWGAdapter::DumpStat() const { 00065 00066 assert (ManagedAutomatonStage_ >= SORTED); 00067 00068 double size; 00069 std::unique_ptr<char> fp(new char[10000]); 00070 00071 if( automaton()->data != NULL ){ 00072 sprintf( fp.get(), "number of data symbols: %llu\n", (U64)(automaton()->data->seqStored) ); 00073 sprintf( fp.get(), "symbol size: %llu\n", (U64)(automaton()->data->elementSize) ); 00074 size = automaton()->data->seqStored; 00075 size *= automaton()->data->elementSize; 00076 size /= 1024.0; 00077 size /= 1024.0; 00078 sprintf( fp.get(), "data size: %.2f MB\n", size ); 00079 } 00080 00081 sprintf( fp.get(), "number of states: %llu\n", (U64)number_of_states() ); 00082 sprintf( fp.get(), "number of transitions: %llu\n", (U64)number_of_transitions() ); 00083 std::string output(fp.get()); 00084 00085 return output; 00086 } 00087 00088 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00089 void InenagaCDAWGAdapter::DumpStat(const S8* outfile) const { 00090 00091 assert (ManagedAutomatonStage_ >= SORTED); 00092 00093 FILE* out = Fopen(outfile, "wb"); 00094 CompressedAutomatonDumpStat(automaton(), out); 00095 Fclose(out); 00096 } 00097 00098 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00099 CompressedAutomaton* InenagaCDAWGAdapter::automaton() const { 00100 if (DEBUG_LEVEL > 5) std::cerr << "virtual inline CompressedAutomaton* InenagaCDAWGAdapter::automaton() const override " << std::endl; 00101 return C_CompressedAutomaton; 00102 } 00103 00104 }}} /* End of namespace lmu::cis::sis */ 00105 00106 #endif /* end of include guard: INENAGACDAWGADAPTER_CPP */