#include "CDC.h"
#include "FastCDC.h"
+#include "FixedCDC.h"
#include "rabin.h"
std::unique_ptr<CDC> CDC::create(
if (type == "fastcdc") {
return std::unique_ptr<CDC>(new FastCDC(bits, windowbits));
}
+ if (type == "fixed") {
+ return std::unique_ptr<CDC>(new FixedCDC(bits, windowbits));
+ }
return nullptr;
}
DecayCounter.cc
FastCDC.cc
Finisher.cc
+ FixedCDC.cc
Formatter.cc
Graylog.cc
HTMLFormatter.cc
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#pragma
+
+#include "FixedCDC.h"
+
+void FixedCDC::calc_chunks(
+ bufferlist& bl,
+ std::vector<std::pair<uint64_t, uint64_t>> *chunks)
+{
+ size_t len = bl.length();
+ if (!len) {
+ return;
+ }
+ for (size_t pos = 0; pos < len; pos += chunk_size) {
+ chunks->push_back(std::pair<uint64_t,uint64_t>(pos, std::min(chunk_size,
+ len - pos)));
+ }
+}
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#pragma once
+
+#include "CDC.h"
+
+class FixedCDC : public CDC {
+private:
+ size_t chunk_size;
+
+public:
+ FixedCDC(int target = 18, int window_bits = 0) {
+ set_target_bits(target, window_bits);
+ };
+
+ void set_target_bits(int target, int window_bits) override {
+ chunk_size = 1ul << target;
+ }
+ void calc_chunks(
+ bufferlist& bl,
+ std::vector<std::pair<uint64_t, uint64_t>> *chunks) override;
+};
TEST_P(CDCTest, insert_front)
{
+ if (GetParam() == "fixed"s) return;
for (int frontlen = 1; frontlen < 163840; frontlen *= 3) {
bufferlist bl1, bl2;
generate_buffer(4*1024*1024, &bl1);
TEST_P(CDCTest, insert_middle)
{
+ if (GetParam() == "fixed"s) return;
for (int frontlen = 1; frontlen < 163840; frontlen *= 3) {
bufferlist bl1, bl2;
generate_buffer(4*1024*1024, &bl1);
CDC,
CDCTest,
::testing::Values(
+ "fixed", // note: we skip most tests bc this is not content-based
"fastcdc"
+ //, "rabin" // rabin fails insert_{front,middle}
));