2013-11-14 20:36:34 +01:00
|
|
|
#ifndef CONCORDIA_INDEX_HDR
|
|
|
|
#define CONCORDIA_INDEX_HDR
|
|
|
|
|
|
|
|
#include <boost/shared_ptr.hpp>
|
2013-11-20 17:43:29 +01:00
|
|
|
#include <fstream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
2015-04-15 10:55:26 +02:00
|
|
|
#include <vector>
|
2013-11-20 17:43:29 +01:00
|
|
|
|
2014-02-20 10:49:17 +01:00
|
|
|
#include "concordia/common/config.hpp"
|
|
|
|
#include "concordia/example.hpp"
|
2013-11-14 20:36:34 +01:00
|
|
|
#include "concordia/hash_generator.hpp"
|
|
|
|
#include "concordia/concordia_exception.hpp"
|
2014-04-29 14:46:04 +02:00
|
|
|
#include <divsufsort.h>
|
2013-11-14 20:36:34 +01:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Class for creating and maintaining the index.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
class ConcordiaIndex {
|
|
|
|
public:
|
2015-04-15 14:14:10 +02:00
|
|
|
explicit ConcordiaIndex(const std::string & hashedIndexFilePath,
|
|
|
|
const std::string & markersFilePath)
|
2013-11-14 20:36:34 +01:00
|
|
|
throw(ConcordiaException);
|
|
|
|
|
|
|
|
/*! Destructor.
|
|
|
|
*/
|
|
|
|
virtual ~ConcordiaIndex();
|
|
|
|
|
2014-02-20 10:49:17 +01:00
|
|
|
void addExample(
|
2013-12-14 15:23:17 +01:00
|
|
|
boost::shared_ptr<HashGenerator> hashGenerator,
|
2015-04-15 14:14:10 +02:00
|
|
|
boost::shared_ptr<std::vector<sauchar_t> > T,
|
|
|
|
boost::shared_ptr<std::vector<SUFFIX_MARKER_TYPE> > markers,
|
2014-02-20 10:49:17 +01:00
|
|
|
const Example & example);
|
2013-11-14 20:36:34 +01:00
|
|
|
|
2014-02-20 10:49:17 +01:00
|
|
|
void addAllExamples(
|
2013-12-14 15:23:17 +01:00
|
|
|
boost::shared_ptr<HashGenerator> hashGenerator,
|
2015-04-15 14:14:10 +02:00
|
|
|
boost::shared_ptr<std::vector<sauchar_t> > T,
|
|
|
|
boost::shared_ptr<std::vector<SUFFIX_MARKER_TYPE> > markers,
|
|
|
|
const std::vector<Example> & examples);
|
2013-11-14 20:36:34 +01:00
|
|
|
|
2015-04-15 14:14:10 +02:00
|
|
|
boost::shared_ptr<std::vector<saidx_t> > generateSuffixArray(
|
|
|
|
boost::shared_ptr<std::vector<sauchar_t> > T);
|
2013-11-14 20:36:34 +01:00
|
|
|
|
|
|
|
private:
|
2014-02-20 10:49:17 +01:00
|
|
|
// Add example to disk index and update RAM index.
|
2015-04-15 14:14:10 +02:00
|
|
|
void _addSingleExample(std::ofstream & hashedIndexFile,
|
|
|
|
std::ofstream & markersFile,
|
|
|
|
boost::shared_ptr<HashGenerator> hashGenerator,
|
|
|
|
boost::shared_ptr<std::vector<sauchar_t> > T,
|
|
|
|
boost::shared_ptr<std::vector<SUFFIX_MARKER_TYPE> > markers,
|
|
|
|
const Example & example);
|
2013-11-20 17:43:29 +01:00
|
|
|
|
2015-04-15 14:14:10 +02:00
|
|
|
std::string _hashedIndexFilePath;
|
2014-02-20 10:49:17 +01:00
|
|
|
|
2015-04-15 14:14:10 +02:00
|
|
|
std::string _markersFilePath;
|
2013-11-14 20:36:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|