Changeset View
Changeset View
Standalone View
Standalone View
src/leveldb/table/table_test.cc
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | public: | ||||
virtual Status Flush() { return Status::OK(); } | virtual Status Flush() { return Status::OK(); } | ||||
virtual Status Sync() { return Status::OK(); } | virtual Status Sync() { return Status::OK(); } | ||||
virtual Status Append(const Slice& data) { | virtual Status Append(const Slice& data) { | ||||
contents_.append(data.data(), data.size()); | contents_.append(data.data(), data.size()); | ||||
return Status::OK(); | return Status::OK(); | ||||
} | } | ||||
std::string GetName() const override { return "[stringsink]"; } | |||||
private: | private: | ||||
std::string contents_; | std::string contents_; | ||||
}; | }; | ||||
class StringSource: public RandomAccessFile { | class StringSource: public RandomAccessFile { | ||||
public: | public: | ||||
StringSource(const Slice& contents) | StringSource(const Slice& contents) | ||||
Show All 12 Lines | virtual Status Read(uint64_t offset, size_t n, Slice* result, | ||||
if (offset + n > contents_.size()) { | if (offset + n > contents_.size()) { | ||||
n = contents_.size() - offset; | n = contents_.size() - offset; | ||||
} | } | ||||
memcpy(scratch, &contents_[offset], n); | memcpy(scratch, &contents_[offset], n); | ||||
*result = Slice(scratch, n); | *result = Slice(scratch, n); | ||||
return Status::OK(); | return Status::OK(); | ||||
} | } | ||||
std::string GetName() const override { return "[stringsource]"; } | |||||
private: | private: | ||||
std::string contents_; | std::string contents_; | ||||
}; | }; | ||||
typedef std::map<std::string, std::string, STLLessThan> KVMap; | typedef std::map<std::string, std::string, STLLessThan> KVMap; | ||||
// Helper class for tests to unify the interface between | // Helper class for tests to unify the interface between | ||||
// BlockBuilder/TableBuilder and Block/Table. | // BlockBuilder/TableBuilder and Block/Table. | ||||
▲ Show 20 Lines • Show All 736 Lines • Show Last 20 Lines |