Commit 9e1fda7e authored by Ramon Nou's avatar Ramon Nou
Browse files

Parallax - exp

parent 69db0dcd
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ clonedeps=(
    ["syscall_intercept"]="2c8765fa292bc9c28a22624c528580d54658813d"
    ["date"]="e7e1482087f58913b80a20b04d5c58d9d6d90155"
    ["agios"]="c26a6544200f823ebb8f890dd94e653d148bf226@development"
    ["parallax-exp"]="e08b56c155617eb5e82a52f85ae46ad158575045"
    ["parallax-exp"]="e08b56c155617eb5e82a52f85ae46ad158575045@tebis_kv_format"
)

# Extra arguments for git clone
+48 −23
Original line number Diff line number Diff line
@@ -51,7 +51,12 @@ namespace gkfs::metadata {
 * TODO: Insert option
 */
ParallaxBackend::~ParallaxBackend() {
    par_close(par_db_);
    auto ret = par_close(par_db_);
    if (ret) {
        std::runtime_error(fmt::format(
                    "Failed to close parallax {}", ret));
        
    }
}

/**
@@ -123,9 +128,13 @@ ParallaxBackend::ParallaxBackend(const std::string& path)
    par_options_.db_name = "test";
    par_options_.volume_name = (char*) malloc(par_path_.size() + 1);
    strcpy(par_options_.volume_name, par_path_.c_str());
    par_options_.volume_start = 0;
    par_options_.volume_size = 0;
    par_db_ = par_open(&par_options_);
    const char *error = NULL;
    par_options_.options = par_get_default_options();
    par_db_ = par_open(&par_options_, &error);
    if (par_db_ == nullptr) {
        throw std::runtime_error(fmt::format("Failed to open database: err {}", *error));
    }
    free((void*)error);
}


@@ -180,10 +189,11 @@ ParallaxBackend::get_impl(const std::string& key) const {
    struct par_value V;
    V.val_buffer = NULL;
    str2par(key, K);

    par_ret_code ret = par_get(par_db_, &K, &V);
    if(ret != PAR_SUCCESS) {
    const char *error;
    par_get(par_db_, &K, &V, &error);
    if(V.val_buffer == NULL) {
        throw_status_excpt("Not Found");
        free((void *)error);
    } else {
        val = V.val_buffer;
        free(V.val_buffer);
@@ -204,9 +214,10 @@ ParallaxBackend::put_impl(const std::string& key, const std::string& val) {

    str2par(key, key_value.k);
    str2par(val, key_value.v);
    par_ret_code ret = par_put(par_db_, &key_value);
    if(ret != PAR_SUCCESS) {
        throw_status_excpt("Not Found");
    const char *error;
    par_put(par_db_, &key_value, &error);
    if (error) {
        free ((void *)  error);
    }
}

@@ -227,7 +238,11 @@ ParallaxBackend::put_no_exist_impl(const std::string& key,

    par_ret_code ret = par_exists(par_db_, &key_value.k);
    if(ret == PAR_KEY_NOT_FOUND) {
        par_put(par_db_, &key_value);
        const char *error;
        par_put(par_db_, &key_value, &error);
        if (!error) {
            free ((void*)error);
        }
    } else
        throw ExistsException(key);
}
@@ -243,9 +258,11 @@ ParallaxBackend::remove_impl(const std::string& key) {
    struct par_key k;

    str2par(key, k);
    par_ret_code ret = par_delete(par_db_, &k);
    const char * error;
    par_delete(par_db_, &k, &error);

    if(ret != PAR_SUCCESS) {
    if(error) {
        free((void *) error);
        throw_status_excpt("Not Found");
    }
}
@@ -292,10 +309,11 @@ ParallaxBackend::update_impl(const std::string& old_key,
    str2par(val, n_key_value.v);

    str2par(old_key, o_key);
    par_delete(par_db_, &o_key);
    par_ret_code ret = par_put(par_db_, &n_key_value);
    if(ret != PAR_SUCCESS) {
        throw_status_excpt("Not Found");
    const char * error;
    par_put(par_db_, &n_key_value, &error);
    if(error) {
        free((void*) error);
        throw_status_excpt("update error");
    }
}

@@ -352,9 +370,12 @@ ParallaxBackend::get_dirents_impl(const std::string& dir) const {
    struct par_key K;

    str2par(root_path, K);

    par_scanner S = par_init_scanner(par_db_, &K, PAR_GREATER_OR_EQUAL);

    const char* error;
    par_scanner S = par_init_scanner(par_db_, &K, PAR_GREATER_OR_EQUAL, &error);
    if (error) {
        free((void*) error);
        throw_status_excpt("Scan error");
    }
    std::vector<std::pair<std::string, bool>> entries;

    while(par_is_valid(S)) {
@@ -420,8 +441,12 @@ ParallaxBackend::get_dirents_extended_impl(const std::string& dir) const {
    struct par_key K;

    str2par(root_path, K);

    par_scanner S = par_init_scanner(par_db_, &K, PAR_GREATER_OR_EQUAL);
    const char* error;
    par_scanner S = par_init_scanner(par_db_, &K, PAR_GREATER_OR_EQUAL, &error);
    if (error) {
        free((void*) error);
        throw_status_excpt("Scan error");
    }
    
    std::vector<std::tuple<std::string, bool, size_t, time_t>> entries;