suachar_t changed to int
This commit is contained in:
parent
307282a760
commit
7c1ed7fb6e
@ -37,7 +37,7 @@ void ConcordiaIndex::generateSuffixArray() {
|
|||||||
ios::ate|ios::binary);
|
ios::ate|ios::binary);
|
||||||
|
|
||||||
/* Get the file size. */
|
/* Get the file size. */
|
||||||
long n = hashedIndexFile.tellg();
|
long n = hashedIndexFile.tellg() / sizeof(sauchar_t);
|
||||||
|
|
||||||
sauchar_t *T;
|
sauchar_t *T;
|
||||||
saidx_t *SA;
|
saidx_t *SA;
|
||||||
|
@ -38,11 +38,17 @@ void IndexSearcher::loadIndex(const string & wordMapFilepath,
|
|||||||
ifstream hashedIndexFile;
|
ifstream hashedIndexFile;
|
||||||
hashedIndexFile.open(hashedIndexFilepath.c_str(), ios::in
|
hashedIndexFile.open(hashedIndexFilepath.c_str(), ios::in
|
||||||
| ios::ate | ios::binary);
|
| ios::ate | ios::binary);
|
||||||
_n = hashedIndexFile.tellg();
|
_n = hashedIndexFile.tellg() / sizeof(sauchar_t);
|
||||||
_T = new sauchar_t[_n];
|
_T = new sauchar_t[_n];
|
||||||
|
|
||||||
hashedIndexFile.seekg(0, ios::beg);
|
hashedIndexFile.seekg(0, ios::beg);
|
||||||
hashedIndexFile.read(reinterpret_cast<char*> (_T), _n);
|
sauchar_t sauchar_buff;
|
||||||
|
int pos = 0;
|
||||||
|
while (!hashedIndexFile.eof()) {
|
||||||
|
hashedIndexFile.read(reinterpret_cast<char *>(&sauchar_buff),
|
||||||
|
sizeof(sauchar_t));
|
||||||
|
_T[pos++] = sauchar_buff;
|
||||||
|
}
|
||||||
hashedIndexFile.close();
|
hashedIndexFile.close();
|
||||||
|
|
||||||
_SA = new saidx_t[_n];
|
_SA = new saidx_t[_n];
|
||||||
@ -50,11 +56,11 @@ void IndexSearcher::loadIndex(const string & wordMapFilepath,
|
|||||||
ifstream suffixArrayFile;
|
ifstream suffixArrayFile;
|
||||||
suffixArrayFile.open(suffixArrayFilepath.c_str(), ios::in | ios::binary);
|
suffixArrayFile.open(suffixArrayFilepath.c_str(), ios::in | ios::binary);
|
||||||
|
|
||||||
saidx_t buff;
|
saidx_t saidx_buff;
|
||||||
int pos = 0;
|
pos = 0;
|
||||||
while (!suffixArrayFile.eof() && pos < _n) {
|
while (!suffixArrayFile.eof() && pos < _n) {
|
||||||
suffixArrayFile.read(reinterpret_cast<char *>(&buff), sizeof(saidx_t));
|
suffixArrayFile.read(reinterpret_cast<char *>(&saidx_buff), sizeof(saidx_t));
|
||||||
_SA[pos++] = buff;
|
_SA[pos++] = saidx_buff;
|
||||||
}
|
}
|
||||||
suffixArrayFile.close();
|
suffixArrayFile.close();
|
||||||
}
|
}
|
||||||
@ -73,7 +79,6 @@ vector<saidx_t> IndexSearcher::simpleSearch(const string & pattern)
|
|||||||
patternArray[i] = *it;
|
patternArray[i] = *it;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int size = sa_search(_T, (saidx_t) _n,
|
int size = sa_search(_T, (saidx_t) _n,
|
||||||
(const sauchar_t *) patternArray, patternLength,
|
(const sauchar_t *) patternArray, patternLength,
|
||||||
_SA, (saidx_t) _n, &left);
|
_SA, (saidx_t) _n, &left);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
add_library(concordia-tests
|
add_library(concordia-tests
|
||||||
test_concordia.cpp
|
|
||||||
test_concordia_config.cpp
|
|
||||||
test_word_map.cpp
|
test_word_map.cpp
|
||||||
test_hash_generator.cpp
|
test_hash_generator.cpp
|
||||||
test_concordia_index.cpp
|
test_concordia_index.cpp
|
||||||
test_index_searcher.cpp
|
test_index_searcher.cpp
|
||||||
|
test_concordia_config.cpp
|
||||||
|
test_concordia.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(concordia-tests concordia ${LIBCONFIG_LIB} concordia-tests-common)
|
target_link_libraries(concordia-tests concordia ${LIBCONFIG_LIB} concordia-tests-common)
|
||||||
|
@ -11,16 +11,8 @@ using namespace std;
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(concordia_index)
|
BOOST_AUTO_TEST_SUITE(concordia_index)
|
||||||
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( ResourcesExistenceTest1 )
|
BOOST_AUTO_TEST_CASE( ResourcesExistenceTest1 )
|
||||||
{
|
|
||||||
ConcordiaIndex index(TestResourcesManager::getTestFilePath("concordia-index","mock_word_map.bin"),
|
|
||||||
TestResourcesManager::getTestFilePath("concordia-index","mock_hash_index.bin"),
|
|
||||||
TestResourcesManager::getTestFilePath("concordia-index","test_SA.bin"));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( ResourcesExistenceTest2 )
|
|
||||||
{
|
{
|
||||||
bool exceptionThrown = false;
|
bool exceptionThrown = false;
|
||||||
string message = "";
|
string message = "";
|
||||||
@ -38,7 +30,7 @@ BOOST_AUTO_TEST_CASE( ResourcesExistenceTest2 )
|
|||||||
BOOST_CHECK_EQUAL(boost::starts_with(message, "E01"), true);
|
BOOST_CHECK_EQUAL(boost::starts_with(message, "E01"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( ResourcesExistenceTest3 )
|
BOOST_AUTO_TEST_CASE( ResourcesExistenceTest2 )
|
||||||
{
|
{
|
||||||
bool exceptionThrown = false;
|
bool exceptionThrown = false;
|
||||||
string message = "";
|
string message = "";
|
||||||
|
@ -56,18 +56,8 @@ endif(HAVE_INLINE)
|
|||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/config.h")
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/config.h")
|
||||||
|
|
||||||
## Checks for types ##
|
## Checks for types ##
|
||||||
# sauchar_t (8bit)
|
# sauchar_t (32bit)
|
||||||
check_type_size("uint8_t" UINT8_T)
|
set(SAUCHAR_TYPE "int")
|
||||||
if(HAVE_UINT8_T)
|
|
||||||
set(SAUCHAR_TYPE "uint8_t")
|
|
||||||
else(HAVE_UINT8_T)
|
|
||||||
check_type_size("unsigned char" SIZEOF_UNSIGNED_CHAR)
|
|
||||||
if("${SIZEOF_UNSIGNED_CHAR}" STREQUAL "1")
|
|
||||||
set(SAUCHAR_TYPE "unsigned char")
|
|
||||||
else("${SIZEOF_UNSIGNED_CHAR}" STREQUAL "1")
|
|
||||||
message(FATAL_ERROR "Cannot find unsigned 8-bit integer type")
|
|
||||||
endif("${SIZEOF_UNSIGNED_CHAR}" STREQUAL "1")
|
|
||||||
endif(HAVE_UINT8_T)
|
|
||||||
# saint_t (32bit)
|
# saint_t (32bit)
|
||||||
check_type_size("int32_t" INT32_T)
|
check_type_size("int32_t" INT32_T)
|
||||||
if(HAVE_INT32_T)
|
if(HAVE_INT32_T)
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user