-
Notifications
You must be signed in to change notification settings - Fork 24
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
refactor param to replace JsonType internal #290
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
|
||
add_subdirectory (simd) | ||
add_subdirectory (io) | ||
add_subdirectory (quantization) | ||
|
||
file (GLOB CPP_SRCS "*.cpp") | ||
file (GLOB CPP_FACTORY_SRCS "factory/*.cpp") | ||
file (GLOB CPP_CONJUGATE_GRAPH_SRCS "impl/*.cpp") | ||
file (GLOB CPP_INDEX_SRCS "index/*.cpp") | ||
file (GLOB CPP_HNSWLIB_SRCS "algorithm/hnswlib/*.cpp") | ||
file (GLOB CPP_QUANTIZATION_SRCS "quantization/*.cpp") | ||
file (GLOB CPP_DATA_CELL_SRCS "data_cell/*.cpp") | ||
file (GLOB CPP_ALGORITHM_SRCS "algorithm/*.cpp") | ||
list (FILTER CPP_SRCS EXCLUDE REGEX "_test.cpp") | ||
list (FILTER CPP_FACTORY_SRCS EXCLUDE REGEX "_test.cpp") | ||
list (FILTER CPP_CONJUGATE_GRAPH_SRCS EXCLUDE REGEX "_test.cpp") | ||
list (FILTER CPP_INDEX_SRCS EXCLUDE REGEX "_test.cpp") | ||
list (FILTER CPP_QUANTIZATION_SRCS EXCLUDE REGEX "_test.cpp") | ||
list (FILTER CPP_DATA_CELL_SRCS EXCLUDE REGEX "_test.cpp") | ||
list (FILTER CPP_ALGORITHM_SRCS EXCLUDE REGEX "_test.cpp") | ||
|
||
set (VSAG_SRCS ${CPP_SRCS} ${CPP_FACTORY_SRCS} ${CPP_INDEX_SRCS} ${CPP_CONJUGATE_GRAPH_SRCS} | ||
${CPP_HNSWLIB_SRCS} ${CPP_QUANTIZATION_SRCS} ${CPP_DATA_CELL_SRCS} ${CPP_ALGORITHM_SRCS}) | ||
${CPP_HNSWLIB_SRCS} ${CPP_DATA_CELL_SRCS} ${CPP_ALGORITHM_SRCS}) | ||
add_library (vsag SHARED ${VSAG_SRCS}) | ||
add_library (vsag_static STATIC ${VSAG_SRCS}) | ||
|
||
set (VSAG_DEP_LIBS diskann pthread m dl simd fmt::fmt-header-only nlohmann_json::nlohmann_json roaring) | ||
set (VSAG_DEP_LIBS diskann pthread m dl simd io quantizer fmt::fmt-header-only nlohmann_json::nlohmann_json roaring) | ||
target_link_libraries (vsag ${VSAG_DEP_LIBS} coverage_config) | ||
target_link_libraries (vsag_static ${VSAG_DEP_LIBS} coverage_config) | ||
|
||
maybe_add_dependencies (vsag spdlog roaring openblas boost mkl) | ||
maybe_add_dependencies (vsag_static spdlog roaring openblas boost mkl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
|
||
// Copyright 2024-present the vsag project | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "hgraph_parameter.h" | ||
|
||
#include <fmt/format-inl.h> | ||
|
||
#include "data_cell/graph_interface_parameter.h" | ||
#include "inner_string_params.h" | ||
|
||
namespace vsag { | ||
|
||
HGraphParameter::HGraphParameter(const JsonType& json) : HGraphParameter() { | ||
this->FromJson(json); | ||
} | ||
|
||
HGraphParameter::HGraphParameter() : name_(INDEX_TYPE_HGRAPH) { | ||
} | ||
|
||
void | ||
HGraphParameter::FromJson(const JsonType& json) { | ||
CHECK_ARGUMENT(json.contains(HGRAPH_USE_REORDER_KEY), | ||
fmt::format("hgraph parameters must contains {}", HGRAPH_USE_REORDER_KEY)); | ||
this->use_reorder_ = json[HGRAPH_USE_REORDER_KEY]; | ||
|
||
CHECK_ARGUMENT(json.contains(HGRAPH_BASE_CODES_KEY), | ||
fmt::format("hgraph parameters must contains {}", HGRAPH_BASE_CODES_KEY)); | ||
const auto& base_codes_json = json[HGRAPH_BASE_CODES_KEY]; | ||
this->base_codes_param_ = std::make_shared<FlattenDataCellParameter>(); | ||
this->base_codes_param_->FromJson(base_codes_json); | ||
|
||
if (use_reorder_) { | ||
CHECK_ARGUMENT(json.contains(HGRAPH_PRECISE_CODES_KEY), | ||
fmt::format("hgraph parameters must contains {}", HGRAPH_PRECISE_CODES_KEY)); | ||
const auto& precise_codes_json = json[HGRAPH_PRECISE_CODES_KEY]; | ||
this->precise_codes_param_ = std::make_shared<FlattenDataCellParameter>(); | ||
this->precise_codes_param_->FromJson(precise_codes_json); | ||
} | ||
|
||
CHECK_ARGUMENT(json.contains(HGRAPH_GRAPH_KEY), | ||
fmt::format("hgraph parameters must contains {}", HGRAPH_GRAPH_KEY)); | ||
const auto& graph_json = json[HGRAPH_GRAPH_KEY]; | ||
this->bottom_graph_param_ = GraphInterfaceParameter::GetGraphParameterByJson(graph_json); | ||
|
||
if (json.contains(BUILD_PARAMS_KEY)) { | ||
auto& build_params = json[BUILD_PARAMS_KEY]; | ||
if (build_params.contains(BUILD_EF_CONSTRUCTION)) { | ||
this->ef_construction_ = build_params[BUILD_EF_CONSTRUCTION]; | ||
} | ||
if (build_params.contains(BUILD_THREAD_COUNT)) { | ||
this->build_thread_count_ = build_params[BUILD_THREAD_COUNT]; | ||
} | ||
} | ||
} | ||
|
||
JsonType | ||
HGraphParameter::ToJson() { | ||
JsonType json; | ||
json["type"] = INDEX_TYPE_HGRAPH; | ||
|
||
json[HGRAPH_USE_REORDER_KEY] = this->use_reorder_; | ||
json[HGRAPH_BASE_CODES_KEY] = this->base_codes_param_->ToJson(); | ||
if (use_reorder_) { | ||
json[HGRAPH_PRECISE_CODES_KEY] = this->precise_codes_param_->ToJson(); | ||
} | ||
json[HGRAPH_GRAPH_KEY] = this->bottom_graph_param_->ToJson(); | ||
|
||
json[BUILD_PARAMS_KEY][BUILD_EF_CONSTRUCTION] = this->ef_construction_; | ||
json[BUILD_PARAMS_KEY][BUILD_THREAD_COUNT] = this->build_thread_count_; | ||
return json; | ||
} | ||
|
||
} // namespace vsag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
// Copyright 2024-present the vsag project | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include "data_cell/flatten_datacell_parameter.h" | ||
#include "data_cell/graph_interface_parameter.h" | ||
#include "parameter.h" | ||
|
||
namespace vsag { | ||
|
||
class HGraphParameter : public Parameter { | ||
public: | ||
explicit HGraphParameter(const JsonType& json); | ||
|
||
HGraphParameter(); | ||
|
||
void | ||
FromJson(const JsonType& json) override; | ||
|
||
JsonType | ||
ToJson() override; | ||
|
||
public: | ||
FlattenDataCellParamPtr base_codes_param_{nullptr}; | ||
FlattenDataCellParamPtr precise_codes_param_{nullptr}; | ||
GraphInterfaceParamPtr bottom_graph_param_{nullptr}; | ||
|
||
bool use_reorder_{false}; | ||
uint64_t ef_construction_{400}; | ||
uint64_t build_thread_count_{100}; | ||
|
||
std::string name_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. struct's public variables do not end with an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how to distinguish between local variables and member variables |
||
}; | ||
|
||
} // namespace vsag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
// Copyright 2024-present the vsag project | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "flatten_datacell_parameter.h" | ||
|
||
#include <fmt/format-inl.h> | ||
|
||
#include "inner_string_params.h" | ||
|
||
namespace vsag { | ||
FlattenDataCellParameter::FlattenDataCellParameter() { | ||
} | ||
|
||
void | ||
FlattenDataCellParameter::FromJson(const JsonType& json) { | ||
CHECK_ARGUMENT(json.contains(IO_PARAMS_KEY), | ||
fmt::format("flatten interface parameters must contains {}", IO_PARAMS_KEY)); | ||
this->io_parameter_ = IOParameter::GetIOParameterByJson(json[IO_PARAMS_KEY]); | ||
|
||
CHECK_ARGUMENT( | ||
json.contains(QUANTIZATION_PARAMS_KEY), | ||
fmt::format("flatten interface parameters must contains {}", QUANTIZATION_PARAMS_KEY)); | ||
this->quantizer_parameter_ = | ||
QuantizerParameter::GetQuantizerParameterByJson(json[QUANTIZATION_PARAMS_KEY]); | ||
} | ||
|
||
JsonType | ||
FlattenDataCellParameter::ToJson() { | ||
JsonType json; | ||
json[IO_PARAMS_KEY] = this->io_parameter_->ToJson(); | ||
json[QUANTIZATION_PARAMS_KEY] = this->quantizer_parameter_->ToJson(); | ||
return json; | ||
} | ||
} // namespace vsag |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Set the default value to the value in options?
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'd like to do one thing in this 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.
fine