Remove entry from rocksdb and art when required.

This commit is contained in:
Kishore Nallan 2016-10-05 21:24:00 +05:30
parent ef105dcbd9
commit 596430c036
5 changed files with 25 additions and 7 deletions

View File

@ -11,12 +11,14 @@
- Facets
- Filters
- Support search operators like +, - etc.
- ~~Delete should remove from RocksDB~~
- Speed up UUID generation
**API**
- Support the following operations:
- create a new index
- index a single document
- ~~index a single document~~
- bulk insert multiple documents
- fetch a document by ID
- delete a document by ID
@ -33,4 +35,4 @@
**Tech debt**
- Use GLOB file pattern for CMake (better IDE refactoring support)
- ~~Use GLOB file pattern for CMake (better IDE refactoring support)~~

View File

@ -47,4 +47,9 @@ public:
rocksdb::Status status = db->Get(rocksdb::ReadOptions(), key, &value);
return status.ok();
}
bool remove(const std::string& key) {
rocksdb::Status status = db->Delete(rocksdb::WriteOptions(), key);
return status.ok();
}
};

View File

@ -6,26 +6,27 @@ struct StringUtils {
template<class ContainerT>
static void tokenize(const std::string &str, ContainerT &tokens,
const std::string &delimiters = " ", bool trimEmpty = false) {
const std::string &delimiters = " ", bool trimEmpty = true, unsigned long maxTokenLength = 100) {
const std::string truncated_str = str.substr(0, maxTokenLength);
std::string::size_type pos, lastPos = 0;
using value_type = typename ContainerT::value_type;
using size_type = typename ContainerT::size_type;
while (true) {
pos = str.find_first_of(delimiters, lastPos);
pos = truncated_str.find_first_of(delimiters, lastPos);
if (pos == std::string::npos) {
pos = str.length();
pos = truncated_str.length();
if (pos != lastPos || !trimEmpty)
tokens.push_back(value_type(str.data() + lastPos,
tokens.push_back(value_type(truncated_str.data() + lastPos,
(size_type) pos - lastPos));
break;
}
else {
if (pos != lastPos || !trimEmpty)
tokens.push_back(value_type(str.data() + lastPos,
tokens.push_back(value_type(truncated_str.data() + lastPos,
(size_type) pos - lastPos));
}

View File

@ -796,6 +796,9 @@ static art_leaf* recursive_delete(art_node *n, art_node **ref, const unsigned ch
return NULL;
}
depth = depth + n->partial_len;
if(depth > key_len-1) {
return NULL;
}
}
// Find child node

View File

@ -331,6 +331,13 @@ void Collection::remove(std::string id) {
std::cout << "i: " << i << ", val: " << leaf->values->offset_index.at(i) << std::endl;
}
std::cout << "----" << std::endl;*/
if(leaf->values->ids.getLength() == 0) {
art_delete(&t, key, key_len);
}
}
}
store->remove(id);
store->remove(seq_id);
}