Fix default implementaton of close() function for Directory/FSDirecto… (#10123)

Summary:
As pointed by anand1976 in his [comment](https://github.com/facebook/rocksdb/pull/10049#pullrequestreview-994255819), previous implementation (adding Close() function in Directory/FSDirectory class) is not backward-compatible. And we mistakenly added the default implementation `return Status::NotSupported("Close")` or `return IOStatus::NotSupported("Close")` in WritableFile class in this [pull request](https://github.com/facebook/rocksdb/pull/10101). This pull request fixes the above issue.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10123

Reviewed By: ajkr

Differential Revision: D36943661

Pulled By: littlepig2013

fbshipit-source-id: 9dc45f4d2ab3a9d51c30bdfde679f1d13c4d5509
main
zczhu 3 years ago committed by Facebook GitHub Bot
parent 2af132c341
commit 9f244b2119
  1. 4
      include/rocksdb/env.h
  2. 10
      include/rocksdb/file_system.h

@ -936,7 +936,7 @@ class WritableFile {
// size due to whole pages writes. The behavior is undefined if called // size due to whole pages writes. The behavior is undefined if called
// with other writes to follow. // with other writes to follow.
virtual Status Truncate(uint64_t /*size*/) { return Status::OK(); } virtual Status Truncate(uint64_t /*size*/) { return Status::OK(); }
virtual Status Close() { return Status::NotSupported("Close"); } virtual Status Close() = 0;
virtual Status Flush() = 0; virtual Status Flush() = 0;
virtual Status Sync() = 0; // sync data virtual Status Sync() = 0; // sync data
@ -1149,7 +1149,7 @@ class Directory {
// Fsync directory. Can be called concurrently from multiple threads. // Fsync directory. Can be called concurrently from multiple threads.
virtual Status Fsync() = 0; virtual Status Fsync() = 0;
// Close directory. // Close directory.
virtual Status Close() = 0; virtual Status Close() { return Status::NotSupported("Close"); }
virtual size_t GetUniqueId(char* /*id*/, size_t /*max_size*/) const { virtual size_t GetUniqueId(char* /*id*/, size_t /*max_size*/) const {
return 0; return 0;

@ -1022,9 +1022,8 @@ class FSWritableFile {
return IOStatus::OK(); return IOStatus::OK();
} }
virtual IOStatus Close(const IOOptions& /*options*/, virtual IOStatus Close(const IOOptions& /*options*/,
IODebugContext* /*dbg*/) { IODebugContext* /*dbg*/) = 0;
return IOStatus::NotSupported("Close");
}
virtual IOStatus Flush(const IOOptions& options, IODebugContext* dbg) = 0; virtual IOStatus Flush(const IOOptions& options, IODebugContext* dbg) = 0;
virtual IOStatus Sync(const IOOptions& options, virtual IOStatus Sync(const IOOptions& options,
IODebugContext* dbg) = 0; // sync data IODebugContext* dbg) = 0; // sync data
@ -1271,7 +1270,10 @@ class FSDirectory {
} }
// Close directory // Close directory
virtual IOStatus Close(const IOOptions& options, IODebugContext* dbg) = 0; virtual IOStatus Close(const IOOptions& /*options*/,
IODebugContext* /*dbg*/) {
return IOStatus::NotSupported("Close");
}
virtual size_t GetUniqueId(char* /*id*/, size_t /*max_size*/) const { virtual size_t GetUniqueId(char* /*id*/, size_t /*max_size*/) const {
return 0; return 0;

Loading…
Cancel
Save