From c667ed5d10905324751c08cc986af88aa9e0c13a Mon Sep 17 00:00:00 2001 From: Kishore Nallan Date: Mon, 25 Apr 2016 21:51:02 +0530 Subject: [PATCH] Fix static linking with libfor. --- CMakeLists.txt | 5 ++--- include/forarray.h | 3 +-- include/matchscore.h | 2 +- src/main.cpp | 7 ++++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 19ac62f6..c71afb6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,8 +4,7 @@ project(search) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++ -std=gnu++11 -O2") include_directories(include) - include_directories(external/for) -add_executable(search external/for/libfor.a src/art.cpp src/intersection.cpp src/main.cpp) -target_link_libraries(search for) +add_executable(search src/art.cpp src/intersection.cpp src/main.cpp) +target_link_libraries(search ${CMAKE_SOURCE_DIR}/external/for/libfor.a) diff --git a/include/forarray.h b/include/forarray.h index a2c5ac49..c51de6a2 100644 --- a/include/forarray.h +++ b/include/forarray.h @@ -62,8 +62,7 @@ public: } uint32_t indexOf(uint32_t value) { - uint32_t actual; - return for_binary_search(in, length); + return for_binary_search(in, length, value); } uint32_t* uncompress() { diff --git a/include/matchscore.h b/include/matchscore.h index 2a08b267..02da896f 100644 --- a/include/matchscore.h +++ b/include/matchscore.h @@ -45,7 +45,7 @@ struct MatchScore { * We use a priority queue to read the position vectors in a sorted manner, slide a window of a given size, and * compute the max_match and min_displacement of target tokens across the windows. */ -MatchScore match_score(std::vector> &word_positions) { +MatchScore match_score(std::vector> &word_positions) { std::priority_queue, WordPosition> heap; for(uint8_t word=0; word < word_positions.size(); word++) { diff --git a/src/main.cpp b/src/main.cpp index ae9d5271..d5607b50 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -118,7 +118,7 @@ void find_documents(art_tree & t, string q, size_t max_results) { //cout << "token_leaves.size(): " << token_leaves.size() << endl; - std::vector> word_positions; + std::vector> word_positions; Topster<100> topster; size_t total_results = 0; const size_t combination_limit = 10; @@ -137,7 +137,7 @@ void find_documents(art_tree & t, string q, size_t max_results) { cout << x->key << ' '; } - // sort based on matched document size to perform effective intersection + // sort ascending based on matched document size to perform effective intersection sort(u.begin(), u.end(), [](const art_leaf* left, const art_leaf* right) { return left->values->ids.getLength() < right->values->ids.getLength(); }); @@ -159,7 +159,8 @@ void find_documents(art_tree & t, string q, size_t max_results) { // go through each document and calculate match score for(auto i=0; i positions; + vector positions; + // by using the document id, locate the positions where the token occurs uint32_t doc_index = token_leaf->values->ids.indexOf(result[i]); uint32_t offset_index = token_leaf->values->offset_index.at(doc_index); uint32_t num_offsets = token_leaf->values->offsets.at(offset_index);