Verified Commit bfece2ab authored by Marc Vef's avatar Marc Vef
Browse files

Support append for Parallax

parent 8d17b247
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include <spdlog/spdlog.h>
#include <daemon/backend/exceptions.hpp>
#include <tuple>
#include <cstdio>
extern "C" {
#include <parallax.h>
}
@@ -145,12 +146,15 @@ public:
     * Updates the size on the metadata
     * Operation. E.g., called before a write() call
     * @param key
     * @param size
     * @param io_size
     * @param offset
     * @param append
     * @throws DBException on failure
     * @return offset where the write operation should start. This is only used
     * when append is set
     */
    void
    increase_size_impl(const std::string& key, size_t size, bool append);
    off_t
    increase_size_impl(const std::string& key, size_t io_size, off_t offset,
                       bool append);

    /**
     * Decreases the size on the metadata
+3 −1
Original line number Diff line number Diff line
@@ -131,8 +131,10 @@ public:
     * Operation. E.g., called before a write() call
     * @param key
     * @param io_size
     * @param offset
     * @param append
     * @throws DBException on failure
     * @return offset where the write operation should start. This is only used
     * when append is set
     */
    off_t
    increase_size_impl(const std::string& key, size_t io_size, off_t offset,
+10 −7
Original line number Diff line number Diff line
@@ -331,18 +331,21 @@ ParallaxBackend::update_impl(const std::string& old_key,
 * @param append
 * @throws DBException on failure
 */
void
ParallaxBackend::increase_size_impl(const std::string& key, size_t size,
                                    bool append) {
off_t
ParallaxBackend::increase_size_impl(const std::string& key, size_t io_size,
                                    off_t offset, bool append) {
    lock_guard<recursive_mutex> lock_guard(parallax_mutex_);

    off_t out_offset = -1;
    auto value = get(key);
    // Decompress string
    Metadata md(value);
    if(append)
        size += md.size();
    md.size(size);
    if(append) {
        out_offset = md.size();
        md.size(md.size() + io_size);
    } else
        md.size(offset + io_size);
    update(key, key, md.serialize());
    return out_offset;
}

/**
+3 −7
Original line number Diff line number Diff line
@@ -214,13 +214,9 @@ RocksDBBackend::update_impl(const std::string& old_key,
off_t
RocksDBBackend::increase_size_impl(const std::string& key, size_t io_size,
                                   off_t offset, bool append) {
    off_t res_offset = -1;
    off_t out_offset = -1;
    if(append) {
        auto merge_id = gkfs::metadata::gen_unique_id(key);
        //        GKFS_METADATA_MOD->log()->info("{}() writing to file {} with
        //        merge_id {} io_size {} offset {} append {}",
        //                                       __func__, key, merge_id,
        //                                       io_size, offset, append);
        // no offset needed because new size is current file size + io_size
        auto uop = IncreaseSizeOperand(io_size, merge_id, append);
        auto s = db_->Merge(write_opts_, key, uop.serialize());
@@ -231,7 +227,7 @@ RocksDBBackend::increase_size_impl(const std::string& key, size_t io_size,
            get_impl(key);
            try {
                // the offset was added during FullMergeV2() call
                res_offset =
                out_offset =
                        GKFS_METADATA_MOD->append_offset_reserve_get_and_erase(
                                merge_id);
            } catch(std::out_of_range& e) {
@@ -249,7 +245,7 @@ RocksDBBackend::increase_size_impl(const std::string& key, size_t io_size,
            throw_status_excpt(s);
        }
    }
    return res_offset;
    return out_offset;
}

/**