Skip to content

Commit

Permalink
Use cross-platform glob library to better support globbing on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminwinger authored and acquamarin committed May 25, 2023
1 parent 122d68f commit 83092a5
Show file tree
Hide file tree
Showing 7 changed files with 468 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ add_library(kuzu_common
utils.cpp
string_utils.cpp)

target_link_libraries(kuzu_common Glob)

set(ALL_OBJECT_FILES
${ALL_OBJECT_FILES} $<TARGET_OBJECTS:kuzu_common>
PARENT_SCOPE)
8 changes: 3 additions & 5 deletions src/common/file_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "common/exception.h"
#include "common/string_utils.h"
#include "glob/glob.hpp"

namespace kuzu {
namespace common {
Expand Down Expand Up @@ -118,12 +119,9 @@ void FileUtils::removeFileIfExists(const std::string& path) {

std::vector<std::string> FileUtils::globFilePath(const std::string& path) {
std::vector<std::string> result;
glob_t globResult;
glob(path.c_str(), GLOB_TILDE, nullptr, &globResult);
for (auto i = 0u; i < globResult.gl_pathc; ++i) {
result.emplace_back(globResult.gl_pathv[i]);
for (auto& resultPath : glob::glob(path)) {
result.emplace_back(resultPath.string());
}
globfree(&globResult);
return result;
}

Expand Down
1 change: 0 additions & 1 deletion src/include/common/file_utils.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <fcntl.h>
#include <glob.h>
#include <sys/stat.h>
#include <unistd.h>

Expand Down
20 changes: 10 additions & 10 deletions test/test_files/copy/parquet/copy_node.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
-CASE CopyNodeTest

-NAME SubsetTest
-QUERY MATCH (row:tableOfTypes) WHERE row.id >= 20 AND row.id <= 24 RETURN *;
-QUERY MATCH (row:tableOfTypes) WHERE row.id >= 20 AND row.id <= 24 RETURN row.id, row.int64Column, row.doubleColumn, row.booleanColumn, row.dateColumn, row.timestampColumn, row.stringColumn;
---- 5
(label:tableOfTypes, 0:20, {id:20, int64Column:0, doubleColumn:57.579280, booleanColumn:True, dateColumn:1731-09-26, timestampColumn:1731-09-26 03:30:08, stringColumn:OdM})
(label:tableOfTypes, 0:21, {id:21, int64Column:7, doubleColumn:64.630960, booleanColumn:False, dateColumn:1307-01-26, timestampColumn:1307-01-26 03:31:08, stringColumn:AjbxHQThEtDDlOjbzMjCQSXlvGQEjcFLykESrnFHwPKX})
(label:tableOfTypes, 0:22, {id:22, int64Column:71, doubleColumn:37.963386, booleanColumn:True, dateColumn:1455-07-26, timestampColumn:1455-07-26 03:07:03, stringColumn:dRvHHdyNXYfSUcicaxBoQEKQUfgex})
(label:tableOfTypes, 0:23, {id:23, int64Column:58, doubleColumn:42.774957, booleanColumn:False, dateColumn:1181-10-16, timestampColumn:1181-10-16 18:19:43, stringColumn:ISImRVpUjynGMFRQyYmeIUVjM})
(label:tableOfTypes, 0:24, {id:24, int64Column:75, doubleColumn:53.813224, booleanColumn:False, dateColumn:1942-10-24, timestampColumn:1942-10-24 09:30:16, stringColumn:naDlQ})
20|0|57.579280|True|1731-09-26|1731-09-26 03:30:08|OdM
21|7|64.630960|False|1307-01-26|1307-01-26 03:31:08|AjbxHQThEtDDlOjbzMjCQSXlvGQEjcFLykESrnFHwPKX
22|71|37.963386|True|1455-07-26|1455-07-26 03:07:03|dRvHHdyNXYfSUcicaxBoQEKQUfgex
23|58|42.774957|False|1181-10-16|1181-10-16 18:19:43|ISImRVpUjynGMFRQyYmeIUVjM
24|75|53.813224|False|1942-10-24|1942-10-24 09:30:16|naDlQ

-NAME CheckNumLinesTest
-QUERY MATCH (row:tableOfTypes) RETURN count(*)
Expand All @@ -35,19 +35,19 @@
1249925001|2500180|2504542.349696

-NAME EmptyStringTest
-QUERY MATCH (row:tableOfTypes) WHERE row.id = 49992 RETURN *;
-QUERY MATCH (row:tableOfTypes) WHERE row.id = 49992 RETURN row.id, row.int64Column, row.doubleColumn, row.booleanColumn, row.dateColumn, row.timestampColumn, row.stringColumn;
---- 1
(label:tableOfTypes, 0:49992, {id:49992, int64Column:50, doubleColumn:31.582059, booleanColumn:False, dateColumn:1551-07-19, timestampColumn:1551-07-19 16:28:31, stringColumn:})
49992|50|31.582059|False|1551-07-19|1551-07-19 16:28:31|

-NAME FloatTest
-QUERY MATCH (row:tableOfTypes) WHERE row.doubleColumn = 68.73718401556897 RETURN row.dateColumn;
---- 1
1042-06-05

-NAME DateTest
-QUERY MATCH (row:tableOfTypes) WHERE row.id = 25531 RETURN *;
-QUERY MATCH (row:tableOfTypes) WHERE row.id = 25531 RETURN row.id, row.int64Column, row.doubleColumn, row.booleanColumn, row.dateColumn, row.timestampColumn, row.stringColumn;
---- 1
(label:tableOfTypes, 0:25531, {id:25531, int64Column:77, doubleColumn:28.417543, booleanColumn:False, dateColumn:1895-03-13, timestampColumn:1895-03-13 04:31:22, stringColumn:XB})
25531|77|28.417543|False|1895-03-13|1895-03-13 04:31:22|XB

-NAME IntervalTest
-QUERY MATCH (row:tableOfTypes) WHERE 0 <= row.doubleColumn AND row.doubleColumn <= 10 AND 0 <= row.int64Column AND row.int64Column <= 10 RETURN count(*);
Expand Down
1 change: 1 addition & 0 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ add_subdirectory(antlr4_cypher)
add_subdirectory(utf8proc)
add_subdirectory(pybind11)
add_subdirectory(re2)
add_subdirectory(glob)
3 changes: 3 additions & 0 deletions third_party/glob/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_library(Glob INTERFACE glob/glob.hpp)

target_include_directories(Glob INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
Loading

0 comments on commit 83092a5

Please sign in to comment.