Fix build issue. (#1123)
Implement GetUniqueIdFromFile to support new tests and the feature.
This commit is contained in:
parent
f6aedb62c0
commit
bac3be7c46
@ -183,7 +183,7 @@ set(SOURCES
|
|||||||
table/plain_table_index.cc
|
table/plain_table_index.cc
|
||||||
table/plain_table_key_coding.cc
|
table/plain_table_key_coding.cc
|
||||||
table/plain_table_reader.cc
|
table/plain_table_reader.cc
|
||||||
persistent_cache_helper.cc
|
table/persistent_cache_helper.cc
|
||||||
table/table_properties.cc
|
table/table_properties.cc
|
||||||
table/two_level_iterator.cc
|
table/two_level_iterator.cc
|
||||||
tools/sst_dump_tool.cc
|
tools/sst_dump_tool.cc
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "port/win/win_logger.h"
|
#include "port/win/win_logger.h"
|
||||||
|
|
||||||
#include "util/random.h"
|
#include "util/random.h"
|
||||||
|
#include "util/coding.h"
|
||||||
#include "util/iostats_context_imp.h"
|
#include "util/iostats_context_imp.h"
|
||||||
#include "util/rate_limiter.h"
|
#include "util/rate_limiter.h"
|
||||||
#include "util/sync_point.h"
|
#include "util/sync_point.h"
|
||||||
@ -54,14 +55,15 @@ std::string GetWindowsErrSz(DWORD err) {
|
|||||||
return Err;
|
return Err;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
const size_t c_OneMB = (1 << 20);
|
|
||||||
|
|
||||||
ThreadStatusUpdater* CreateThreadStatusUpdater() {
|
ThreadStatusUpdater* CreateThreadStatusUpdater() {
|
||||||
return new ThreadStatusUpdater();
|
return new ThreadStatusUpdater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
const size_t c_OneMB = (1 << 20);
|
||||||
|
|
||||||
inline Status IOErrorFromWindowsError(const std::string& context, DWORD err) {
|
inline Status IOErrorFromWindowsError(const std::string& context, DWORD err) {
|
||||||
return Status::IOError(context, GetWindowsErrSz(err));
|
return Status::IOError(context, GetWindowsErrSz(err));
|
||||||
}
|
}
|
||||||
@ -198,6 +200,31 @@ inline Status ftruncate(const std::string& filename, HANDLE hFile,
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t GetUniqueIdFromFile(HANDLE hFile, char* id, size_t max_size) {
|
||||||
|
|
||||||
|
if (max_size < kMaxVarint64Length * 3) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BY_HANDLE_FILE_INFORMATION FileInfo;
|
||||||
|
|
||||||
|
BOOL result = GetFileInformationByHandle(hFile, &FileInfo);
|
||||||
|
|
||||||
|
TEST_SYNC_POINT_CALLBACK("GetUniqueIdFromFile:FS_IOC_GETVERSION", &result);
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* rid = id;
|
||||||
|
rid = EncodeVarint64(rid, uint64_t(FileInfo.dwVolumeSerialNumber));
|
||||||
|
rid = EncodeVarint64(rid, uint64_t(FileInfo.nFileIndexHigh));
|
||||||
|
rid = EncodeVarint64(rid, uint64_t(FileInfo.nFileIndexLow));
|
||||||
|
|
||||||
|
assert(rid >= id);
|
||||||
|
return static_cast<size_t>(rid - id);
|
||||||
|
}
|
||||||
|
|
||||||
// mmap() based random-access
|
// mmap() based random-access
|
||||||
class WinMmapReadableFile : public RandomAccessFile {
|
class WinMmapReadableFile : public RandomAccessFile {
|
||||||
const std::string fileName_;
|
const std::string fileName_;
|
||||||
@ -246,6 +273,10 @@ class WinMmapReadableFile : public RandomAccessFile {
|
|||||||
virtual Status InvalidateCache(size_t offset, size_t length) override {
|
virtual Status InvalidateCache(size_t offset, size_t length) override {
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual size_t GetUniqueId(char* id, size_t max_size) const override {
|
||||||
|
return GetUniqueIdFromFile(hFile_, id, max_size);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// We preallocate up to an extra megabyte and use memcpy to append new
|
// We preallocate up to an extra megabyte and use memcpy to append new
|
||||||
@ -591,6 +622,10 @@ class WinMmapFile : public WritableFile {
|
|||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual size_t GetUniqueId(char* id, size_t max_size) const override {
|
||||||
|
return GetUniqueIdFromFile(hFile_, id, max_size);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class WinSequentialFile : public SequentialFile {
|
class WinSequentialFile : public SequentialFile {
|
||||||
@ -915,6 +950,10 @@ class WinRandomAccessFile : public RandomAccessFile {
|
|||||||
virtual Status InvalidateCache(size_t offset, size_t length) override {
|
virtual Status InvalidateCache(size_t offset, size_t length) override {
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual size_t GetUniqueId(char* id, size_t max_size) const override {
|
||||||
|
return GetUniqueIdFromFile(hFile_, id, max_size);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// This is a sequential write class. It has been mimicked (as others) after
|
// This is a sequential write class. It has been mimicked (as others) after
|
||||||
@ -1088,6 +1127,10 @@ class WinWritableFile : public WritableFile {
|
|||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual size_t GetUniqueId(char* id, size_t max_size) const override {
|
||||||
|
return GetUniqueIdFromFile(hFile_, id, max_size);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class WinDirectory : public Directory {
|
class WinDirectory : public Directory {
|
||||||
|
Loading…
Reference in New Issue
Block a user