mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Implementing DynamicIterator for TransformRepNoLock
Summary: What @haobo done with TransformRep, now in TransformRepNoLock. Similar implementation, except that I made DynamicIterator a subclass of Iterator which makes me have less iterator initializations. Test Plan: ./prefix_test. Seeing huge savings vs. TransformRep again! Reviewers: dhruba, haobo, sdong, kailiu Reviewed By: haobo CC: leveldb, haobo Differential Revision: https://reviews.facebook.net/D13953
This commit is contained in:
@@ -260,67 +260,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// NO LOCKS VERSION
|
||||
|
||||
// The same as TransformRepFactory except it doesn't use locks.
|
||||
// Experimental, will replace TransformRepFactory once we are sure
|
||||
// it performs better
|
||||
class TransformRepNoLockFactory : public MemTableRepFactory {
|
||||
public:
|
||||
explicit TransformRepNoLockFactory(const SliceTransform* transform,
|
||||
size_t bucket_count)
|
||||
: transform_(transform),
|
||||
bucket_count_(bucket_count) { }
|
||||
|
||||
virtual ~TransformRepNoLockFactory() { delete transform_; }
|
||||
|
||||
virtual std::shared_ptr<MemTableRep> CreateMemTableRep(
|
||||
MemTableRep::KeyComparator&, Arena*) override;
|
||||
|
||||
virtual const char* Name() const override {
|
||||
return "TransformRepNoLockFactory";
|
||||
}
|
||||
|
||||
const SliceTransform* GetTransform() { return transform_; }
|
||||
|
||||
protected:
|
||||
const SliceTransform* transform_;
|
||||
const size_t bucket_count_;
|
||||
};
|
||||
|
||||
// UnsortedReps bin user keys based on an identity function transform -- that
|
||||
// is, transform(key) = key. This optimizes for point look-ups.
|
||||
//
|
||||
// Parameters: See TransformRepNoLockFactory.
|
||||
class UnsortedRepNoLockFactory : public TransformRepNoLockFactory {
|
||||
public:
|
||||
explicit UnsortedRepNoLockFactory(size_t bucket_count = 1000000)
|
||||
: TransformRepNoLockFactory(NewNoopTransform(),
|
||||
bucket_count) { }
|
||||
virtual const char* Name() const override {
|
||||
return "UnsortedRepNoLockFactory";
|
||||
}
|
||||
};
|
||||
|
||||
// PrefixHashReps bin user keys based on a fixed-size prefix. This optimizes for
|
||||
// short ranged scans over a given prefix.
|
||||
//
|
||||
// Parameters: See TransformRepNoLockFactory.
|
||||
class PrefixHashRepNoLockFactory : public TransformRepNoLockFactory {
|
||||
public:
|
||||
explicit PrefixHashRepNoLockFactory(const SliceTransform* prefix_extractor,
|
||||
size_t bucket_count = 1000000)
|
||||
: TransformRepNoLockFactory(prefix_extractor, bucket_count)
|
||||
{ }
|
||||
|
||||
virtual std::shared_ptr<MemTableRep> CreateMemTableRep(
|
||||
MemTableRep::KeyComparator&, Arena*) override;
|
||||
|
||||
virtual const char* Name() const override {
|
||||
return "PrefixHashRepNoLockFactory";
|
||||
}
|
||||
};
|
||||
extern MemTableRepFactory* NewHashSkipListRepFactory(
|
||||
const SliceTransform* transform, size_t bucket_count = 1000000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user