-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Windows Support #1573
Add Windows Support #1573
Conversation
@@ -6,7 +6,39 @@ | |||
namespace kuzu { | |||
namespace function { | |||
|
|||
class VectorBooleanOperations : public VectorOperations { | |||
template<typename FUNC> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can u try to put these back into VectorBooleanOperations
. This probably won't cause compilation problem in MSVC.
*params[0], *params[1], result); | ||
} | ||
|
||
template<typename A_TYPE, typename B_TYPE, typename C_TYPE, typename RESULT_TYPE, typename FUNC> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto. try put back into VectorListOperations
@@ -6,7 +6,23 @@ | |||
namespace kuzu { | |||
namespace function { | |||
|
|||
class VectorNullOperations : public VectorOperations { | |||
template<typename FUNC> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto try put back into VectorNullOperations
@@ -97,15 +97,6 @@ TEST_F(DemoDBTest, DeleteRelTest) { | |||
ASSERT_EQ(TestHelper::convertResultToString(*result), groundTruth); | |||
} | |||
|
|||
TEST_F(DemoDBTest, DeleteWithExceptionTest) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, that was something @acquamarin did in this commit. @acquamarin?
result += "\t" + tableIDSchema.second->tableName + "\n"; | ||
relTableNames.push_back(tableIDSchema.second->tableName); | ||
} | ||
std::sort(relTableNames.begin(), relTableNames.end()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@@ -9,6 +9,13 @@ | |||
namespace kuzu { | |||
namespace processor { | |||
|
|||
template<typename type> | |||
bool compareEntryWithKeys(const uint8_t* keyValue, const uint8_t* entry) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto try put back. We have many places that are written in a similar way. I don't know why some of them can be compiled while others we need to change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you give an example of another place which didn't require changing? That might provide some insight into other ways the issue can be worked around.
It's worth noting that it seems to work fine as long as the function pointer isn't returned from another function (that's the point where the function resolution fails).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. This is a good point. Then I wonder if we also pass functor reference rather than return a functor. Because expose static function in header files is not a good coding style
For example in vector_boolean_operation
we can do
void VectorBooleanOperations::bindExecFunction(
ExpressionType expressionType, const binder::expression_vector& children, scalar_exec_func& func) {
if (isExpressionBinary(expressionType)) {
func = bindBinaryExecFunction(expressionType, children);
} else {
assert(isExpressionUnary(expressionType));
func = bindUnaryExecFunction(expressionType, children);
}
}
I think @acquamarin, @ray6080 and @benjaminwinger should all comment on this. If so, @benjaminwinger you can ignore my other comment and do this in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems like a reasonable solution to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. This is a good point. Then I wonder if we also pass functor reference rather than return a functor. Because expose static function in header files is not a good coding style
For example in
vector_boolean_operation
we can dovoid VectorBooleanOperations::bindExecFunction( ExpressionType expressionType, const binder::expression_vector& children, scalar_exec_func& func) { if (isExpressionBinary(expressionType)) { func = bindBinaryExecFunction(expressionType, children); } else { assert(isExpressionUnary(expressionType)); func = bindUnaryExecFunction(expressionType, children); } }
I think @acquamarin, @ray6080 and @benjaminwinger should all comment on this. If so, @benjaminwinger you can ignore my other comment and do this in a separate PR.
Sounds good to me.
@@ -138,5 +133,9 @@ class OrderByKeyEncoder { | |||
std::vector<encode_function_t> encodeFunctions; | |||
}; | |||
|
|||
template<typename type> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
} | ||
}; | ||
|
||
// Note: Previously part of a VectorOperations class, but MSVC is unable to resolve references to the function within subclasses. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would still try to wrap them in a class. It's not a good idea to expose static function directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some comments. But I kind of want to take a look after rebase
with master. As for now, it is not very clear some changes are already in master or made in this PR.
@@ -2,13 +2,19 @@ include(ExternalProject) | |||
|
|||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | |||
|
|||
if(WIN32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can always keep arrow build type same as cmake build type regardless platforms here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, though it would trigger an unnecessary rebuild of arrow when switching on other platforms, and building arrow isn't very fast.
@@ -26,6 +26,13 @@ void NodeTable::initializeData(NodeTableSchema* nodeTableSchema) { | |||
} | |||
} | |||
|
|||
void NodeTable::resetColumns(catalog::NodeTableSchema* nodeTableSchema) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is used to close the files for nodeTable, if we don't close the files, we can't do the rename
@@ -91,6 +91,7 @@ void TransactionManager::stopNewTransactionsAndWaitUntilAllReadTransactionsLeave | |||
numTimesWaited++; | |||
if (numTimesWaited * THREAD_SLEEP_TIME_WHEN_WAITING_IN_MICROS > | |||
checkPointWaitTimeoutForTransactionsToLeaveInMicros) { | |||
mtxForStartingNewTransactions.unlock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this a bug?
@@ -73,6 +73,21 @@ void DirectedRelTableData::initializeLists(RelTableSchema* tableSchema, WAL* wal | |||
} | |||
} | |||
|
|||
void DirectedRelTableData::resetColumnsAndLists( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto here. Is this introduced in this PR?
src/main/database.cpp
Outdated
status.dwLength = sizeof(status); | ||
GlobalMemoryStatusEx(&status); | ||
auto systemMemSize = (std::uint64_t)status.ullTotalPhys; | ||
bufferPoolSize = (uint64_t)(BufferPoolConstants::DEFAULT_PHY_MEM_SIZE_RATIO_FOR_BM * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this line bufferPoolSize = (uint64_t)...
out of the #if #else
?
0637b5c
to
cbac99a
Compare
src/common/file_utils.cpp
Outdated
std::unique_ptr<FileInfo> FileUtils::openFile(const std::string& path, int flags) { | ||
#if defined(_WIN32) | ||
// Not providing GENERIC_READ seems to cause problems. | ||
int dwDesiredAccess = GENERIC_READ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our convension is to use auto instead of the actual type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't seem to be mentioned in the style guide. Is the style guide out of date?
src/common/file_utils.cpp
Outdated
int dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; | ||
int dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL; | ||
if (flags & O_CREAT) | ||
dwCreationDisposition = OPEN_ALWAYS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can rewrite this as auto dwCreationDisposition = (flags & O_CREAT) ? OPEN_ALWAYS : OPEN_EXISTING
src/common/file_utils.cpp
Outdated
int dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL; | ||
if (flags & O_CREAT) | ||
dwCreationDisposition = OPEN_ALWAYS; | ||
if (flags & (O_CREAT | O_WRONLY | O_RDWR)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our convension is to always add brackets to if statements
src/common/file_utils.cpp
Outdated
@@ -125,5 +211,32 @@ std::vector<std::string> FileUtils::globFilePath(const std::string& path) { | |||
return result; | |||
} | |||
|
|||
void FileUtils::truncateFileToSize(FileInfo* fileInfo, uint64_t size) { | |||
#if defined(_WIN32) | |||
long offsetHigh = size >> 32; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the size of long is dependent on the platform. Better to use auto offsetHigh = (uint32_t)(size >> 32)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is platform-specific code though. I was following the API for SetFilePointer, which says the arguments are a LONG
, which according to this is just typedef long LONG;
.
But I'll still change it; it's unintuitive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though that actually would require casting the pointer back to a long*
/LONG*
when passing the argument to SetFilePointer
, which seems a little redundant. Maybe it's better to just actually use LONG
to indicate it's a microsoft-specified type for a microsoft-specified interface.
@@ -26,6 +26,13 @@ void NodeTable::initializeData(NodeTableSchema* nodeTableSchema) { | |||
} | |||
} | |||
|
|||
void NodeTable::resetColumns(catalog::NodeTableSchema* nodeTableSchema) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is used to close the files for nodeTable, if we don't close the files, we can't do the rename
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #1573 +/- ##
==========================================
- Coverage 91.95% 91.95% -0.01%
==========================================
Files 701 701
Lines 25207 25322 +115
==========================================
+ Hits 23179 23284 +105
- Misses 2028 2038 +10
☔ View full report in Codecov by Sentry. |
|
||
int64_t FileInfo::getFileSize() { | ||
#ifdef _WIN32 | ||
return GetFileSize((HANDLE)handle, nullptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use GetFileSizeEx
? GetFileSize
seems only return 4 bytes as the result, which is not large enough.
std::unique_ptr<FileInfo> FileUtils::openFile(const std::string& path, int flags) { | ||
#if defined(_WIN32) | ||
// Not providing GENERIC_READ seems to cause problems. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this? Can you take a look at this implementation? https://github.com/duckdb/duckdb/blob/09486d2b9d93270aa05920c6e7e54af00ce9d296/src/common/local_file_system.cpp#L524
@@ -9,6 +9,13 @@ | |||
namespace kuzu { | |||
namespace processor { | |||
|
|||
template<typename type> | |||
bool compareEntryWithKeys(const uint8_t* keyValue, const uint8_t* entry) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. This is a good point. Then I wonder if we also pass functor reference rather than return a functor. Because expose static function in header files is not a good coding style
For example in
vector_boolean_operation
we can dovoid VectorBooleanOperations::bindExecFunction( ExpressionType expressionType, const binder::expression_vector& children, scalar_exec_func& func) { if (isExpressionBinary(expressionType)) { func = bindBinaryExecFunction(expressionType, children); } else { assert(isExpressionUnary(expressionType)); func = bindUnaryExecFunction(expressionType, children); } }
I think @acquamarin, @ray6080 and @benjaminwinger should all comment on this. If so, @benjaminwinger you can ignore my other comment and do this in a separate PR.
Sounds good to me.
A few tests seem to have regressed with the most recent changes from master. I haven't gotten around to looking into those yet, but I thought I should get this PR open for review in the meantime.
Mostly fixes #1504 (note omissions below) and supersedes #1544.
Notable changes
I added a
KUZU_
prefix to the type enum in the C API. Unfortunately, windows headers pollute the import namespace making some of the more common names (e.g.BOOL
) ambiguous.I removed the
VectorOperations
class and moved{Unary,Binary,Ternary,Const}ExecFunction
into the enclosingkuzu::function
namespace (they could get their own child namespace if that's preferable). MSVC doesn't appear to allow function pointers to templated member functions (see this minimal example).Omissions
ARROW_INSTALL
option which can point to the installed arrow prefix and can be used to switch between versions of arrow manually. Setting something up in the Makefile to do it automatically should be possible, but would probably be messy.Also note that performance is rather poor. It seems to largely be related to file i/o.