Skip to content

Commit

Permalink
Merge branch 'kuzudb:master' into sequential_read
Browse files Browse the repository at this point in the history
  • Loading branch information
rfdavid committed Mar 4, 2023
2 parents 12263d0 + c6b5317 commit ada93d6
Show file tree
Hide file tree
Showing 54 changed files with 310 additions and 680 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.11)

project(Kuzu VERSION 0.0.3 LANGUAGES CXX)
project(Kuzu VERSION 0.0.4 LANGUAGES CXX)

find_package(Threads REQUIRED)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
-COMPARE_RESULT 1
-QUERY MATCH (comment:Comment) RETURN MIN(gamma(comment.length % 2 + 2))
---- 1
1
1.000000
6 changes: 3 additions & 3 deletions dataset/copy-node-property-test/vPerson.csv
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
0,
1,"ozwhvnetnq"
2,"kuk,qg\\nrspmk"
3,"wmz,1234\lamo"
2,"kuk,qgnrspmk"
3,"wmz,1234lamo"
4,"tudoojdduf"
5,"qifidjufri"
6,"gqpnpbdmrb"
7,"dgzbiqjkaz"
8,"ebf,,uq\buqma"
8,"ebf,,uqbuqma"
9,"rwhnybogfy"
10,"enqpnymvdb"
11,"axgwwhhohf"
Expand Down
8 changes: 4 additions & 4 deletions src/binder/bind/bind_ddl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ std::vector<PropertyNameDataType> Binder::bindPropertyNameDataTypes(
for (auto& propertyNameDataType : propertyNameDataTypes) {
if (boundPropertyNames.contains(propertyNameDataType.first)) {
throw BinderException(StringUtils::string_format(
"Duplicated column name: %s, column name must be unique.",
propertyNameDataType.first.c_str()));
"Duplicated column name: {}, column name must be unique.",
propertyNameDataType.first));
} else if (TableSchema::isReservedPropertyName(propertyNameDataType.first)) {
throw BinderException(
StringUtils::string_format("PropertyName: %s is an internal reserved propertyName.",
propertyNameDataType.first.c_str()));
StringUtils::string_format("PropertyName: {} is an internal reserved propertyName.",
propertyNameDataType.first));
}
StringUtils::toUpper(propertyNameDataType.second);
auto dataType = bindDataType(propertyNameDataType.second);
Expand Down
4 changes: 2 additions & 2 deletions src/binder/binder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ void Binder::validateNodeTableHasNoEdge(const Catalog& _catalog, table_id_t tabl
for (auto& tableIDSchema : _catalog.getReadOnlyVersion()->getRelTableSchemas()) {
if (tableIDSchema.second->isSrcOrDstTable(tableID)) {
throw BinderException(StringUtils::string_format(
"Cannot delete a node table with edges. It is on the edges of rel: %s.",
tableIDSchema.second->tableName.c_str()));
"Cannot delete a node table with edges. It is on the edges of rel: {}.",
tableIDSchema.second->tableName));
}
}
}
Expand Down
15 changes: 7 additions & 8 deletions src/catalog/catalog_structs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ std::string TableSchema::getPropertyName(property_id_t propertyID) const {
return property.name;
}
}
throw common::RuntimeException(common::StringUtils::string_format(
"Table: %s doesn't have a property with propertyID=%d.", tableName.c_str(), propertyID));
throw common::RuntimeException(StringUtils::string_format(
"Table: {} doesn't have a property with propertyID={}.", tableName, propertyID));
}

property_id_t TableSchema::getPropertyID(const std::string& propertyName) const {
Expand All @@ -57,9 +57,8 @@ property_id_t TableSchema::getPropertyID(const std::string& propertyName) const
return property.propertyID;
}
}
throw common::RuntimeException(common::StringUtils::string_format(
"Table: %s doesn't have a property with propertyName=%s.", tableName.c_str(),
propertyName.c_str()));
throw common::RuntimeException(StringUtils::string_format(
"Table: {} doesn't have a property with propertyName={}.", tableName, propertyName));
}

Property TableSchema::getProperty(property_id_t propertyID) const {
Expand All @@ -68,8 +67,8 @@ Property TableSchema::getProperty(property_id_t propertyID) const {
return property;
}
}
throw common::RuntimeException(common::StringUtils::string_format(
"Table: %s doesn't have a property with propertyID=%d.", tableName.c_str(), propertyID));
throw common::RuntimeException(StringUtils::string_format(
"Table: {} doesn't have a property with propertyID={}.", tableName, propertyID));
}

void TableSchema::renameProperty(property_id_t propertyID, const std::string& newName) {
Expand All @@ -80,7 +79,7 @@ void TableSchema::renameProperty(property_id_t propertyID, const std::string& ne
}
}
throw common::InternalException(
"Property with id=" + std::to_string(propertyID) + " not found.");
StringUtils::string_format("Property with id={} not found.", propertyID));
}

} // namespace catalog
Expand Down
2 changes: 1 addition & 1 deletion src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_subdirectory(arrow)
add_subdirectory(csv_reader)
add_subdirectory(copier_config)
add_subdirectory(data_chunk)
add_subdirectory(task_system)
add_subdirectory(types)
Expand Down
2 changes: 1 addition & 1 deletion src/common/assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void kuAssertInternal(bool condition, const char* condition_name, const char* fi
return;
}
throw InternalException(StringUtils::string_format(
"Assertion triggered in file \"%s\" on line %d: %s", file, linenr, condition_name));
"Assertion triggered in file \"{}\" on line {}: {}", file, linenr, condition_name));
}

} // namespace common
Expand Down
7 changes: 7 additions & 0 deletions src/common/copier_config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
add_library(kuzu_common_copier_config
OBJECT
copier_config.cpp)

set(ALL_OBJECT_FILES
${ALL_OBJECT_FILES} $<TARGET_OBJECTS:kuzu_common_copier_config>
PARENT_SCOPE)
79 changes: 79 additions & 0 deletions src/common/copier_config/copier_config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include "common/copier_config/copier_config.h"

#include "common/constants.h"
#include "common/type_utils.h"
#include "common/utils.h"
#include "spdlog/spdlog.h"
#include "utf8proc_wrapper.h"

using namespace kuzu::utf8proc;

namespace kuzu {
namespace common {
CopyDescription::CopyDescription(const std::string& filePath, CSVReaderConfig csvReaderConfig)
: filePath{filePath}, csvReaderConfig{nullptr}, fileType{FileType::CSV} {
setFileType(filePath);
if (fileType == FileType::CSV) {
this->csvReaderConfig = std::make_unique<CSVReaderConfig>(csvReaderConfig);
}
}

CopyDescription::CopyDescription(const CopyDescription& copyDescription)
: filePath{copyDescription.filePath}, csvReaderConfig{nullptr}, fileType{
copyDescription.fileType} {
if (fileType == FileType::CSV) {
this->csvReaderConfig = std::make_unique<CSVReaderConfig>(*copyDescription.csvReaderConfig);
}
}

std::string CopyDescription::getFileTypeName(FileType fileType) {
switch (fileType) {
case FileType::CSV:
return "csv";

case FileType::ARROW:
return "arrow";

case FileType::PARQUET:
return "parquet";
}
}

std::string CopyDescription::getFileTypeSuffix(FileType fileType) {
return "." + getFileTypeName(fileType);
}

void CopyDescription::setFileType(std::string const& fileName) {
auto csvSuffix = getFileTypeSuffix(FileType::CSV);
auto arrowSuffix = getFileTypeSuffix(FileType::ARROW);
auto parquetSuffix = getFileTypeSuffix(FileType::PARQUET);

if (fileName.length() >= csvSuffix.length()) {
if (!fileName.compare(
fileName.length() - csvSuffix.length(), csvSuffix.length(), csvSuffix)) {
fileType = FileType::CSV;
return;
}
}

if (fileName.length() >= arrowSuffix.length()) {
if (!fileName.compare(
fileName.length() - arrowSuffix.length(), arrowSuffix.length(), arrowSuffix)) {
fileType = FileType::ARROW;
return;
}
}

if (fileName.length() >= parquetSuffix.length()) {
if (!fileName.compare(fileName.length() - parquetSuffix.length(), parquetSuffix.length(),
parquetSuffix)) {
fileType = FileType::PARQUET;
return;
}
}

throw CopyException("Unsupported file type: " + fileName);
}

} // namespace common
} // namespace kuzu
7 changes: 0 additions & 7 deletions src/common/csv_reader/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit ada93d6

Please sign in to comment.