// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab /* * Ceph distributed storage system * * Copyright (C) 2014 Cloudwatt * * Author: Loic Dachary * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * */ #ifndef CEPH_ERASURE_CODE_H #define CEPH_ERASURE_CODE_H /*! @file ErasureCode.h @brief Base class for erasure code plugins implementors */ #include #include "ErasureCodeInterface.h" namespace ceph { class ErasureCode : public ErasureCodeInterface { public: static const unsigned SIMD_ALIGN; vector chunk_mapping; virtual ~ErasureCode() {} virtual unsigned int get_coding_chunk_count() const { return get_chunk_count() - get_data_chunk_count(); } virtual int minimum_to_decode(const set &want_to_read, const set &available_chunks, set *minimum); virtual int minimum_to_decode_with_cost(const set &want_to_read, const map &available, set *minimum); int encode_prepare(const bufferlist &raw, map &encoded) const; virtual int encode(const set &want_to_encode, const bufferlist &in, map *encoded); virtual int encode_chunks(const set &want_to_encode, map *encoded); virtual int decode(const set &want_to_read, const map &chunks, map *decoded); virtual int decode_chunks(const set &want_to_read, const map &chunks, map *decoded); virtual int parse(const map ¶meters, ostream *ss); virtual const vector &get_chunk_mapping() const; int to_mapping(const map ¶meters, ostream *ss); static int to_int(const std::string &name, const map ¶meters, int *value, int default_value, ostream *ss); static int to_bool(const std::string &name, const map ¶meters, bool *value, bool default_value, ostream *ss); virtual int decode_concat(const map &chunks, bufferlist *decoded); private: int chunk_index(unsigned int i) const; }; } #endif