Changeset View
Changeset View
Standalone View
Standalone View
src/leveldb/include/leveldb/env.h
Show First 20 Lines • Show All 185 Lines • ▼ Show 20 Lines | public: | ||||
// slower that reading the same data, but may be faster. | // slower that reading the same data, but may be faster. | ||||
// | // | ||||
// If end of file is reached, skipping will stop at the end of the | // If end of file is reached, skipping will stop at the end of the | ||||
// file, and Skip will return OK. | // file, and Skip will return OK. | ||||
// | // | ||||
// REQUIRES: External synchronization | // REQUIRES: External synchronization | ||||
virtual Status Skip(uint64_t n) = 0; | virtual Status Skip(uint64_t n) = 0; | ||||
// Get a name for the file, only for error reporting | |||||
virtual std::string GetName() const = 0; | |||||
private: | private: | ||||
// No copying allowed | // No copying allowed | ||||
SequentialFile(const SequentialFile&); | SequentialFile(const SequentialFile&); | ||||
void operator=(const SequentialFile&); | void operator=(const SequentialFile&); | ||||
}; | }; | ||||
// A file abstraction for randomly reading the contents of a file. | // A file abstraction for randomly reading the contents of a file. | ||||
class RandomAccessFile { | class RandomAccessFile { | ||||
public: | public: | ||||
RandomAccessFile() { } | RandomAccessFile() { } | ||||
virtual ~RandomAccessFile(); | virtual ~RandomAccessFile(); | ||||
// Read up to "n" bytes from the file starting at "offset". | // Read up to "n" bytes from the file starting at "offset". | ||||
// "scratch[0..n-1]" may be written by this routine. Sets "*result" | // "scratch[0..n-1]" may be written by this routine. Sets "*result" | ||||
// to the data that was read (including if fewer than "n" bytes were | // to the data that was read (including if fewer than "n" bytes were | ||||
// successfully read). May set "*result" to point at data in | // successfully read). May set "*result" to point at data in | ||||
// "scratch[0..n-1]", so "scratch[0..n-1]" must be live when | // "scratch[0..n-1]", so "scratch[0..n-1]" must be live when | ||||
// "*result" is used. If an error was encountered, returns a non-OK | // "*result" is used. If an error was encountered, returns a non-OK | ||||
// status. | // status. | ||||
// | // | ||||
// Safe for concurrent use by multiple threads. | // Safe for concurrent use by multiple threads. | ||||
virtual Status Read(uint64_t offset, size_t n, Slice* result, | virtual Status Read(uint64_t offset, size_t n, Slice* result, | ||||
char* scratch) const = 0; | char* scratch) const = 0; | ||||
// Get a name for the file, only for error reporting | |||||
virtual std::string GetName() const = 0; | |||||
private: | private: | ||||
// No copying allowed | // No copying allowed | ||||
RandomAccessFile(const RandomAccessFile&); | RandomAccessFile(const RandomAccessFile&); | ||||
void operator=(const RandomAccessFile&); | void operator=(const RandomAccessFile&); | ||||
}; | }; | ||||
// A file abstraction for sequential writing. The implementation | // A file abstraction for sequential writing. The implementation | ||||
// must provide buffering since callers may append small fragments | // must provide buffering since callers may append small fragments | ||||
// at a time to the file. | // at a time to the file. | ||||
class WritableFile { | class WritableFile { | ||||
public: | public: | ||||
WritableFile() { } | WritableFile() { } | ||||
virtual ~WritableFile(); | virtual ~WritableFile(); | ||||
virtual Status Append(const Slice& data) = 0; | virtual Status Append(const Slice& data) = 0; | ||||
virtual Status Close() = 0; | virtual Status Close() = 0; | ||||
virtual Status Flush() = 0; | virtual Status Flush() = 0; | ||||
virtual Status Sync() = 0; | virtual Status Sync() = 0; | ||||
// Get a name for the file, only for error reporting | |||||
virtual std::string GetName() const = 0; | |||||
private: | private: | ||||
// No copying allowed | // No copying allowed | ||||
WritableFile(const WritableFile&); | WritableFile(const WritableFile&); | ||||
void operator=(const WritableFile&); | void operator=(const WritableFile&); | ||||
}; | }; | ||||
// An interface for writing log messages. | // An interface for writing log messages. | ||||
class Logger { | class Logger { | ||||
▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines |