-
Notifications
You must be signed in to change notification settings - Fork 1
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: UsingSpecificKeyList method #67
Conversation
# ANALYSIS_METHOD and ANALYSIS_METHOD_USING_SPECIFIC_KEY_LIST_FILEPATH
WalkthroughThe project has undergone significant changes, including the addition of error checks in Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #67 +/- ##
==========================================
- Coverage 80.29% 72.65% -7.64%
==========================================
Files 16 19 +3
Lines 203 267 +64
Branches 24 35 +11
==========================================
+ Hits 163 194 +31
- Misses 40 73 +33 ☔ View full report in Codecov by Sentry. |
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to path filters (1)
src/main/resources/using_key_list_file.json
is excluded by:!**/*.json
Files selected for processing (15)
- build.sbt (2 hunks)
- src/main/resources/application.conf (1 hunks)
- src/main/scala/Main.scala (3 hunks)
- src/main/scala/domain/graph/GraphVertex.scala (2 hunks)
- src/main/scala/infrastructure/EdgeQuery.scala (3 hunks)
- src/main/scala/infrastructure/VertexQuery.scala (2 hunks)
- src/main/scala/usecase/ByExhaustiveSearch.scala (2 hunks)
- src/main/scala/usecase/UsecaseBase.scala (1 hunks)
- src/main/scala/usecase/UsingSpecificKeyList.scala (1 hunks)
- src/main/scala/utils/FileUtility.scala (1 hunks)
- src/main/scala/utils/JsonUtility.scala (1 hunks)
- src/test/scala/infrastructure/EdgeQuerySpec.scala (3 hunks)
- src/test/scala/infrastructure/VertexQuerySpec.scala (1 hunks)
- src/test/scala/usecase/ByExhaustiveSearchSpec.scala (4 hunks)
- src/test/scala/usecase/UsingSpecificKeyListSpec.scala (1 hunks)
Additional comments: 18
src/main/scala/usecase/UsecaseBase.scala (1)
- 10-26: The
UsecaseBase
trait provides a common structure for use cases with a protected graph traversal source and a method for exception handling. This is a good use of trait to share common functionality across different use cases.src/main/scala/utils/FileUtility.scala (1)
- 11-15: The
readJson
method inFileUtility
correctly uses Scala'sUsing
construct to ensure that the file is closed after reading, which is a good practice for resource management.build.sbt (2)
18-24: The addition of
Wart.OptionPartial
,Wart.PlatformDefault
, andWart.SeqApply
towartremoverErrors
is a good practice to catch potential issues related to these warts at compile time.41-43: The inclusion of Circe library dependencies (
circe-core
,circe-generic
,circe-parser
) is aligned with the need for JSON processing within the application.src/main/resources/application.conf (1)
- 2-5: The configuration settings for
analysis_method
andanalysis_method_using_specific_key_list_filepath
are set with default values and can be overridden by environment variables, which provides flexibility for different deployment environments.src/main/scala/utils/JsonUtility.scala (1)
- 14-46: The
parseForUsingSpecificKeyListRequest
method inJsonUtility
uses Circe's decoding functionality with custom decoders to handle different JSON types, which is a robust way to parse JSON into domain-specific objects.src/main/scala/infrastructure/EdgeQuery.scala (2)
27-29: The
getInEdgeList
method inEdgeQuery
correctly retrieves incoming edges for a given vertex and maps them to theGraphEdge
domain model.63-65: Similarly, the
getOutEdgeList
method retrieves outgoing edges for a given vertex, which is consistent with the functionality required for the new analysis method.src/main/scala/domain/graph/GraphVertex.scala (1)
- 20-20: The addition of the
id
field in theGraphVertex
case class is a necessary change to align with the domain model's requirement to have an identifier for graph operations.src/main/scala/infrastructure/VertexQuery.scala (1)
- 56-68: The
getListByPropertyKey
method inVertexQuery
is a valuable addition that allows retrieving vertices based on a property key and value, which is essential for the new analysis method.src/test/scala/infrastructure/EdgeQuerySpec.scala (2)
18-28: The new test cases for
getInEdgeList
inEdgeQuerySpec
are well-constructed and ensure that the method's functionality is verified correctly.59-69: Similarly, the test cases for
getOutEdgeList
provide good coverage and validation for the method's expected behavior.src/main/scala/usecase/ByExhaustiveSearch.scala (1)
- 18-22: The
ByExhaustiveSearch
class now extendsUsecaseBase
, which is a good refactor to leverage shared functionality such as logging and exception handling.src/test/scala/infrastructure/VertexQuerySpec.scala (1)
- 46-71: The new test suite for
getListByPropertyKey
inVertexQuerySpec
is comprehensive, testing for both edge cases (empty label and key) and the method's successful execution.src/main/scala/usecase/UsingSpecificKeyList.scala (1)
- 30-104: The
UsingSpecificKeyList
class is well-structured, extendingUsecaseBase
for shared functionality and providing a clear implementation for executing the analysis based on a specific key list.src/main/scala/Main.scala (1)
- 34-77: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [23-69]
The refactoring of the
main
method to include a command pattern for selecting analysis methods is a good design choice that enhances the maintainability and scalability of the code.src/test/scala/usecase/UsingSpecificKeyListSpec.scala (1)
- 18-109: The
UsingSpecificKeyListSpec
test suite provides thorough testing for theUsingSpecificKeyList
use case, ensuring that the new functionality works as expected.src/test/scala/usecase/ByExhaustiveSearchSpec.scala (1)
- 27-95: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [30-109]
The updates to the
ByExhaustiveSearchSpec
test suite align with the changes made to theByExhaustiveSearch
use case, ensuring that the tests remain valid and effective.
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- src/main/scala/infrastructure/EdgeQuery.scala (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/main/scala/infrastructure/EdgeQuery.scala
…GraphDB2RDB into feature/add_analysis_method
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- src/main/scala/Main.scala (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/main/scala/Main.scala
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.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files ignored due to path filters (2)
src/main/resources/using_key_list_file.json
is excluded by:!**/*.json
src/main/resources/using_key_list_file_schema.json
is excluded by:!**/*.json
Files selected for processing (1)
- README.md (1 hunks)
Additional comments: 2
README.md (2)
54-61: The Usage section has been updated to include the new analysis method 'using_specific_key_list'. It's important to ensure that the environment variable
ANALYSIS_METHOD
is documented correctly and that the instructions are clear for users to follow.72-108: The section 'How to change analysis method' has been added, providing instructions on how to switch between the 'by_exhaustive_search' and 'using_specific_key_list' methods. It is crucial to verify that the links to the JSON files and schema are correct and accessible.
Verification successful
The output from the shell scripts indicates that both the JSON file and schema are accessible, as they both returned an HTTP 200 status code, which means OK. Therefore, the links to the JSON files and schema in the README.md are correct and accessible.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the JSON file and schema are accessible curl -o /dev/null -s -w "%{http_code}\n" https://github.com/kazumatsudo/GraphDB2RDB/blob/e163bdcfb7a50d5275eecfb722ac172214dd8a98/src/main/resources/using_key_list_file.json curl -o /dev/null -s -w "%{http_code}\n" https://github.com/kazumatsudo/GraphDB2RDB/blob/e163bdcfb7a50d5275eecfb722ac172214dd8a98/src/main/resources/using_key_list_file_schema.jsonLength of output: 366
2. select analysis method | ||
choose analysis method to search Vertex/Edge algorithm. | ||
- "by_exhaustive_search" (default) | ||
- "using_specific_key_list" | ||
please see following passage if you want to change method. | ||
```shell | ||
% ANALYSIS_METHOD="by_exhaustive_search" | ||
``` | ||
3. execute the script by sbt | ||
```shell | ||
sbt run | ||
``` | ||
3. generate SQL files | ||
4. generate SQL files | ||
- sql/ddl_edge.sql | ||
- sql/ddl_vertex.sql | ||
- sql/insert_edge.sql | ||
- sql/insert_vertex.sql | ||
|
||
### How to change analysis method | ||
|
||
#### by_exhaustive_search | ||
|
||
##### overview | ||
|
||
analyze all Vertices and Edges. | ||
|
||
- pros | ||
- no advance preparation required | ||
- cons | ||
- inefficient (execute full search all vertices and edges count times) | ||
|
||
##### how to choose | ||
|
||
no advance preparation required because it's selected by default. | ||
|
||
#### using_specific_key_list | ||
|
||
##### overview | ||
|
||
analyze specific vertices searched by keys | ||
|
||
- pros | ||
- faster than [[ByExhaustiveSearch]] (enable to search by index) | ||
- cons | ||
- required to prepare search condition | ||
|
||
##### how to choose | ||
|
||
1. set environment variable "ANALYSIS_METHOD" to "using_specific_key_list" | ||
```shell | ||
% ANALYSIS_METHOD="using_specific_key_list" | ||
``` | ||
2. set target vertex label, property key, and its values in [using_key_list_file.json](https://github.com/kazumatsudo/GraphDB2RDB/blob/e163bdcfb7a50d5275eecfb722ac172214dd8a98/src/main/resources/using_key_list_file.json) | ||
- json schema: [using_key_list_file_schema.json](https://github.com/kazumatsudo/GraphDB2RDB/blob/e163bdcfb7a50d5275eecfb722ac172214dd8a98/src/main/resources/using_key_list_file_schema.json) | ||
|
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.
Ensure that the documentation for setting the analysis method is clear and that the environment variable ANALYSIS_METHOD
is used consistently throughout the project. It might be helpful to provide an example of how to export this variable for clarity.
- % ANALYSIS_METHOD="using_specific_key_list"
+ export ANALYSIS_METHOD="using_specific_key_list"
Committable suggestion
❗ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
2. select analysis method | |
choose analysis method to search Vertex/Edge algorithm. | |
- "by_exhaustive_search" (default) | |
- "using_specific_key_list" | |
please see following passage if you want to change method. | |
```shell | |
% ANALYSIS_METHOD="by_exhaustive_search" | |
``` | |
3. execute the script by sbt | |
```shell | |
sbt run | |
``` | |
3. generate SQL files | |
4. generate SQL files | |
- sql/ddl_edge.sql | |
- sql/ddl_vertex.sql | |
- sql/insert_edge.sql | |
- sql/insert_vertex.sql | |
### How to change analysis method | |
#### by_exhaustive_search | |
##### overview | |
analyze all Vertices and Edges. | |
- pros | |
- no advance preparation required | |
- cons | |
- inefficient (execute full search all vertices and edges count times) | |
##### how to choose | |
no advance preparation required because it's selected by default. | |
#### using_specific_key_list | |
##### overview | |
analyze specific vertices searched by keys | |
- pros | |
- faster than [[ByExhaustiveSearch]] (enable to search by index) | |
- cons | |
- required to prepare search condition | |
##### how to choose | |
1. set environment variable "ANALYSIS_METHOD" to "using_specific_key_list" | |
```shell | |
% ANALYSIS_METHOD="using_specific_key_list" | |
``` | |
2. set target vertex label, property key, and its values in [using_key_list_file.json](https://github.com/kazumatsudo/GraphDB2RDB/blob/e163bdcfb7a50d5275eecfb722ac172214dd8a98/src/main/resources/using_key_list_file.json) | |
- json schema: [using_key_list_file_schema.json](https://github.com/kazumatsudo/GraphDB2RDB/blob/e163bdcfb7a50d5275eecfb722ac172214dd8a98/src/main/resources/using_key_list_file_schema.json) | |
2. select analysis method | |
choose analysis method to search Vertex/Edge algorithm. | |
- "by_exhaustive_search" (default) | |
- "using_specific_key_list" | |
please see following passage if you want to change method. | |
```shell | |
% ANALYSIS_METHOD="by_exhaustive_search" | |
``` | |
3. execute the script by sbt | |
```shell | |
sbt run | |
``` | |
4. generate SQL files | |
- sql/ddl_edge.sql | |
- sql/ddl_vertex.sql | |
- sql/insert_edge.sql | |
- sql/insert_vertex.sql | |
### How to change analysis method | |
#### by_exhaustive_search | |
##### overview | |
analyze all Vertices and Edges. | |
- pros | |
- no advance preparation required | |
- cons | |
- inefficient (execute full search all vertices and edges count times) | |
##### how to choose | |
no advance preparation required because it's selected by default. | |
#### using_specific_key_list | |
##### overview | |
analyze specific vertices searched by keys | |
- pros | |
- faster than [[ByExhaustiveSearch]] (enable to search by index) | |
- cons | |
- required to prepare search condition | |
##### how to choose | |
1. set environment variable "ANALYSIS_METHOD" to "using_specific_key_list" | |
```shell | |
export ANALYSIS_METHOD="using_specific_key_list" | |
``` | |
2. set target vertex label, property key, and its values in [using_key_list_file.json](https://github.com/kazumatsudo/GraphDB2RDB/blob/e163bdcfb7a50d5275eecfb722ac172214dd8a98/src/main/resources/using_key_list_file.json) | |
- json schema: [using_key_list_file_schema.json](https://github.com/kazumatsudo/GraphDB2RDB/blob/e163bdcfb7a50d5275eecfb722ac172214dd8a98/src/main/resources/using_key_list_file_schema.json) | |
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Tests