suachar_t changed to int

This commit is contained in:
rjawor 2013-12-01 23:34:46 +01:00
parent 307282a760
commit 7c1ed7fb6e
8 changed files with 20 additions and 33 deletions

View File

@ -37,7 +37,7 @@ void ConcordiaIndex::generateSuffixArray() {
ios::ate|ios::binary);
/* Get the file size. */
long n = hashedIndexFile.tellg();
long n = hashedIndexFile.tellg() / sizeof(sauchar_t);
sauchar_t *T;
saidx_t *SA;

View File

@ -38,11 +38,17 @@ void IndexSearcher::loadIndex(const string & wordMapFilepath,
ifstream hashedIndexFile;
hashedIndexFile.open(hashedIndexFilepath.c_str(), ios::in
| ios::ate | ios::binary);
_n = hashedIndexFile.tellg();
_n = hashedIndexFile.tellg() / sizeof(sauchar_t);
_T = new sauchar_t[_n];
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();
_SA = new saidx_t[_n];
@ -50,11 +56,11 @@ void IndexSearcher::loadIndex(const string & wordMapFilepath,
ifstream suffixArrayFile;
suffixArrayFile.open(suffixArrayFilepath.c_str(), ios::in | ios::binary);
saidx_t buff;
int pos = 0;
saidx_t saidx_buff;
pos = 0;
while (!suffixArrayFile.eof() && pos < _n) {
suffixArrayFile.read(reinterpret_cast<char *>(&buff), sizeof(saidx_t));
_SA[pos++] = buff;
suffixArrayFile.read(reinterpret_cast<char *>(&saidx_buff), sizeof(saidx_t));
_SA[pos++] = saidx_buff;
}
suffixArrayFile.close();
}
@ -72,8 +78,7 @@ vector<saidx_t> IndexSearcher::simpleSearch(const string & pattern)
it != hash.end(); ++it) {
patternArray[i] = *it;
i++;
}
}
int size = sa_search(_T, (saidx_t) _n,
(const sauchar_t *) patternArray, patternLength,
_SA, (saidx_t) _n, &left);

View File

@ -1,10 +1,10 @@
add_library(concordia-tests
test_concordia.cpp
test_concordia_config.cpp
test_word_map.cpp
test_hash_generator.cpp
test_concordia_index.cpp
test_index_searcher.cpp
test_concordia_config.cpp
test_concordia.cpp
)
target_link_libraries(concordia-tests concordia ${LIBCONFIG_LIB} concordia-tests-common)

View File

@ -11,16 +11,8 @@ using namespace std;
BOOST_AUTO_TEST_SUITE(concordia_index)
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;
string message = "";
@ -38,7 +30,7 @@ BOOST_AUTO_TEST_CASE( ResourcesExistenceTest2 )
BOOST_CHECK_EQUAL(boost::starts_with(message, "E01"), true);
}
BOOST_AUTO_TEST_CASE( ResourcesExistenceTest3 )
BOOST_AUTO_TEST_CASE( ResourcesExistenceTest2 )
{
bool exceptionThrown = false;
string message = "";

View File

@ -56,18 +56,8 @@ endif(HAVE_INLINE)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/config.h")
## Checks for types ##
# sauchar_t (8bit)
check_type_size("uint8_t" UINT8_T)
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)
# sauchar_t (32bit)
set(SAUCHAR_TYPE "int")
# saint_t (32bit)
check_type_size("int32_t" INT32_T)
if(HAVE_INT32_T)