range_lock_manager.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright (c) Meta Platforms, Inc. and affiliates.
  2. //
  3. // This source code is licensed under both the GPLv2 (found in the
  4. // COPYING file in the root directory) and Apache 2.0 License
  5. // (found in the LICENSE.Apache file in the root directory).
  6. //
  7. // Generic definitions for a Range-based Lock Manager
  8. //
  9. #pragma once
  10. #include "utilities/transactions/lock/lock_manager.h"
  11. namespace ROCKSDB_NAMESPACE {
  12. /*
  13. A base class for all Range-based lock managers
  14. See also class RangeLockManagerHandle in
  15. include/rocksdb/utilities/transaction_db.h
  16. */
  17. class RangeLockManagerBase : public LockManager {
  18. public:
  19. // Geting a point lock is reduced to getting a range lock on a single-point
  20. // range
  21. using LockManager::TryLock;
  22. Status TryLock(PessimisticTransaction* txn, ColumnFamilyId column_family_id,
  23. const std::string& key, Env* env, bool exclusive) override {
  24. Endpoint endp(key.data(), key.size(), false);
  25. return TryLock(txn, column_family_id, endp, endp, env, exclusive);
  26. }
  27. };
  28. } // namespace ROCKSDB_NAMESPACE