mirror of
https://github.com/typesense/typesense.git
synced 2025-05-20 13:42:26 +08:00
Release memory of value stored when art node is destroyed.
This commit is contained in:
parent
94db15b715
commit
4d2ba27cab
@ -24,6 +24,10 @@ public:
|
||||
memset(in, 0, size_bytes);
|
||||
}
|
||||
|
||||
~forarray() {
|
||||
delete in;
|
||||
}
|
||||
|
||||
static inline uint32_t required_bits(const uint32_t v) {
|
||||
return v == 0 ? 0 : 32 - __builtin_clz(v);
|
||||
}
|
||||
|
@ -96,7 +96,9 @@ static void destroy_node(art_node *n) {
|
||||
|
||||
// Special case leafs
|
||||
if (IS_LEAF(n)) {
|
||||
free(LEAF_RAW(n));
|
||||
art_leaf *leaf = (art_leaf *) LEAF_RAW(n);
|
||||
delete leaf->values;
|
||||
free(leaf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -37,11 +37,10 @@ void Collection::add(std::vector<std::string> tokens, uint16_t score) {
|
||||
|
||||
uint32_t num_hits = 0;
|
||||
|
||||
const unsigned char *key = (const unsigned char *) kv.first.c_str();
|
||||
int key_len = (int) kv.first.length() + 1; // for the terminating \0 char
|
||||
char *key = new char[key_len];
|
||||
strcpy(key, kv.first.c_str());
|
||||
|
||||
art_leaf* leaf = (art_leaf *) art_search(&t, (const unsigned char *) key, key_len);
|
||||
art_leaf* leaf = (art_leaf *) art_search(&t, key, key_len);
|
||||
if(leaf != NULL) {
|
||||
num_hits = leaf->values->ids.getLength();
|
||||
}
|
||||
|
@ -75,11 +75,11 @@ static int chunked_test(h2o_handler_t *self, h2o_req_t *req) {
|
||||
h2o_iovec_init(req->path.base + req->query_at, req->path.len - req->query_at) :
|
||||
h2o_iovec_init(H2O_STRLIT(""));
|
||||
|
||||
printf("Query: %.*s\n", (int) query.len, query.base);
|
||||
|
||||
std::string query_str(query.base, query.len);
|
||||
std::map<std::string, std::string> query_map = parse_query(query_str);
|
||||
|
||||
printf("Query: %s\n", query_map["q"].c_str());
|
||||
|
||||
auto begin = std::chrono::high_resolution_clock::now();
|
||||
collection->search(query_map["q"], 100);
|
||||
long long int timeMillis = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - begin).count();
|
||||
@ -145,8 +145,8 @@ static int create_listener(void) {
|
||||
}
|
||||
|
||||
void index_documents() {
|
||||
std::ifstream infile("/Users/kishore/others/wreally/typesense/test/documents.txt");
|
||||
//std::ifstream infile("/Users/kishore/Downloads/hnstories.tsv");
|
||||
//std::ifstream infile("/Users/kishore/others/wreally/typesense/test/documents.txt");
|
||||
std::ifstream infile("/Users/kishore/Downloads/hnstories.tsv");
|
||||
|
||||
std::string line;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user