From dd8b27cc23601d4cbf73de6d8d539e0187bdb0f5 Mon Sep 17 00:00:00 2001 From: rjawor Date: Wed, 14 May 2014 16:29:44 +0200 Subject: [PATCH] anubis searcher stub Former-commit-id: fe520e255c918c889bdd421a363668b2ed76c675 --- concordia/CMakeLists.txt | 2 ++ concordia/anubis_searcher.cpp | 21 ++++++++++++++++++++ concordia/anubis_searcher.hpp | 37 +++++++++++++++++++++++++++++++++++ concordia/index_searcher.cpp | 9 ++++++--- concordia/index_searcher.hpp | 2 ++ 5 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 concordia/anubis_searcher.cpp create mode 100644 concordia/anubis_searcher.hpp diff --git a/concordia/CMakeLists.txt b/concordia/CMakeLists.txt index e054bce..15b6089 100644 --- a/concordia/CMakeLists.txt +++ b/concordia/CMakeLists.txt @@ -6,6 +6,7 @@ foreach(dir ${ALL_DIRECTORIES}) endforeach(dir) add_library(concordia SHARED + anubis_searcher.cpp regex_replacement.cpp sentence_anonymizer.cpp interval.cpp @@ -30,6 +31,7 @@ add_subdirectory(t) install(TARGETS concordia DESTINATION lib/) install(FILES + anubis_searcher.hpp regex_replacement.hpp sentence_anonymizer.hpp interval.hpp diff --git a/concordia/anubis_searcher.cpp b/concordia/anubis_searcher.cpp new file mode 100644 index 0000000..94481ee --- /dev/null +++ b/concordia/anubis_searcher.cpp @@ -0,0 +1,21 @@ +#include "concordia/anubis_searcher.hpp" + + +AnubisSearcher::AnubisSearcher() { +} + + +AnubisSearcher::~AnubisSearcher() { +} + + +boost::ptr_vector AnubisSearcher::anubisSearch( + boost::shared_ptr > T, + boost::shared_ptr > markers, + boost::shared_ptr > SA, + boost::shared_ptr >) + throw(ConcordiaException) { + + boost::ptr_vector result; + return result; +} diff --git a/concordia/anubis_searcher.hpp b/concordia/anubis_searcher.hpp new file mode 100644 index 0000000..cc4fc4c --- /dev/null +++ b/concordia/anubis_searcher.hpp @@ -0,0 +1,37 @@ +#ifndef ANUBIS_SEARCHER_HDR +#define ANUBIS_SEARCHER_HDR + +#include +#include + +#include "concordia/common/config.hpp" +#include "concordia/substring_occurence.hpp" +#include "concordia/concordia_exception.hpp" +#include "concordia/anubis_search_result.hpp" + +#include + +/*! + Class for searching using Anubis algorithm. + +*/ + +using namespace std; + +class AnubisSearcher { +public: + explicit AnubisSearcher(); + + /*! Destructor. + */ + virtual ~AnubisSearcher(); + + boost::ptr_vector anubisSearch( + boost::shared_ptr > T, + boost::shared_ptr > markers, + boost::shared_ptr > SA, + boost::shared_ptr >) throw(ConcordiaException); +private: +}; + +#endif diff --git a/concordia/index_searcher.cpp b/concordia/index_searcher.cpp index fe9bdd4..3c0df60 100644 --- a/concordia/index_searcher.cpp +++ b/concordia/index_searcher.cpp @@ -4,6 +4,8 @@ #include IndexSearcher::IndexSearcher() { + _anubisSearcher = boost::shared_ptr( + new AnubisSearcher()); } @@ -25,7 +27,7 @@ boost::ptr_vector IndexSearcher::simpleSearch( sauchar_t * patternArray = Utils::indexVectorToSaucharArray(hash); int size = sa_search(T->data(), (saidx_t) T->size(), (const sauchar_t *) patternArray, patternLength, - SA->data(), (saidx_t) T->size(), &left); + SA->data(), (saidx_t) SA->size(), &left); for (int i = 0; i < size; ++i) { saidx_t resultPos = SA->at(left + i); if (resultPos % sizeof(INDEX_CHARACTER_TYPE) == 0) { @@ -55,6 +57,7 @@ boost::ptr_vector IndexSearcher::anubisSearch( boost::shared_ptr > markers, boost::shared_ptr > SA, const string & pattern) throw(ConcordiaException) { - boost::ptr_vector result; - return result; + boost::shared_ptr > hash = + hashGenerator->generateHash(pattern); + return _anubisSearcher->anubisSearch(T, markers, SA, hash); } diff --git a/concordia/index_searcher.hpp b/concordia/index_searcher.hpp index 3b59d68..b8813a1 100644 --- a/concordia/index_searcher.hpp +++ b/concordia/index_searcher.hpp @@ -10,6 +10,7 @@ #include "concordia/substring_occurence.hpp" #include "concordia/hash_generator.hpp" #include "concordia/concordia_exception.hpp" +#include "concordia/anubis_searcher.hpp" #include "concordia/anubis_search_result.hpp" #include @@ -43,6 +44,7 @@ public: boost::shared_ptr > SA, const string & pattern) throw(ConcordiaException); private: + boost::shared_ptr _anubisSearcher; }; #endif