mirror of
https://github.com/typesense/typesense.git
synced 2025-05-20 21:52:23 +08:00
Fix static linking with libfor.
This commit is contained in:
parent
f0f57f2e2d
commit
c667ed5d10
@ -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)
|
||||
|
@ -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() {
|
||||
|
@ -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<std::vector<uint32_t>> &word_positions) {
|
||||
MatchScore match_score(std::vector<std::vector<uint16_t>> &word_positions) {
|
||||
std::priority_queue<WordPosition, std::vector<WordPosition>, WordPosition> heap;
|
||||
|
||||
for(uint8_t word=0; word < word_positions.size(); word++) {
|
||||
|
@ -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<std::vector<uint32_t>> word_positions;
|
||||
std::vector<std::vector<uint16_t>> 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<result_size; i++) {
|
||||
for (art_leaf *token_leaf : u) {
|
||||
vector<uint32_t> positions;
|
||||
vector<uint16_t> 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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user