]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/rabin: add helper set_target_bits()
authorSage Weil <sage@newdream.net>
Tue, 12 May 2020 16:51:32 +0000 (11:51 -0500)
committerSage Weil <sage@newdream.net>
Wed, 27 May 2020 12:47:27 +0000 (07:47 -0500)
Sets key chunking parameters in one easy call.

Signed-off-by: Sage Weil <sage@newdream.net>
src/common/rabin.h

index 795d8aed7df230c3aed5931957c620d18a881e88..163610ee19761c7ffac229c94574d959b7a9b9e4 100644 (file)
@@ -75,6 +75,12 @@ public:
     num_bits = bits;
   }
 
+  // most users should use this
+  void set_target_bits(int bits, int windowbits = 2) {
+    set_numbits(bits);
+    set_min_chunk(1 << (bits - windowbits));
+    set_max_chunk(1 << (bits + windowbits));
+  }
 
 private:
   bool end_of_chunk(const uint64_t fp , int numbits);