Skip to content
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

Feat/cognitarium construct #396

Merged
merged 3 commits into from
Oct 18, 2023
Merged

Feat/cognitarium construct #396

merged 3 commits into from
Oct 18, 2023

Conversation

ccamel
Copy link
Member

@ccamel ccamel commented Oct 17, 2023

Finalize #327 by implementing the CONSTRUCT query over the triple store in the cognitarium smart contract, allowing to retrieve a set of triples serialized in a specific format (turtle, rdf/xml, ...).

Summary by CodeRabbit

  • Refactor: The code handling data queries has been streamlined, improving the efficiency and reliability of data retrieval. This should result in faster response times when interacting with the system.
  • New Feature: A new 'Construct' query function has been added, enhancing the system's ability to build and execute complex data plans. This will allow for more sophisticated data manipulation and retrieval.
  • Refactor: Utility functions have been reorganized into a new 'util' module for better code management, which will help maintain the system's performance and reliability over time.

@ccamel ccamel self-assigned this Oct 17, 2023
@bot-anik
Copy link
Member

size-limit report 📦

Path Size
target/wasm32-unknown-unknown/release/okp4_objectarium.wasm 430.56 KB (0%)
target/wasm32-unknown-unknown/release/okp4_law_stone.wasm 644.19 KB (0%)
target/wasm32-unknown-unknown/release/okp4_cognitarium.wasm 809.05 KB (+0.74% 🔺)

@codecov
Copy link

codecov bot commented Oct 17, 2023

Codecov Report

Merging #396 (67f6754) into main (33ba939) will decrease coverage by 0.02%.
Report is 12 commits behind head on main.
The diff coverage is 97.14%.

@@            Coverage Diff             @@
##             main     #396      +/-   ##
==========================================
- Coverage   97.77%   97.76%   -0.02%     
==========================================
  Files          42       42              
  Lines       10163    10243      +80     
==========================================
+ Hits         9937    10014      +77     
- Misses        226      229       +3     
Files Coverage Δ
contracts/okp4-cognitarium/src/contract.rs 99.38% <97.14%> (-0.21%) ⬇️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ccamel ccamel marked this pull request as ready for review October 17, 2023 15:24
@coderabbitai
Copy link

coderabbitai bot commented Oct 17, 2023

Walkthrough

The changes primarily focus on refactoring the execute and query modules in the contract.rs file. The execute module now utilizes a utility function for converting WhereCondition to TriplePattern and extracting variables. The query module introduces a new function construct to handle Construct queries. Utility functions have been moved to a new util module for better organization.

Changes

File Path Summary
contracts/.../src/contract.rs Refactored execute module to use utility functions for conversion and extraction. Added construct function in query module to handle Construct queries. Moved utility functions to a new util module for better organization.

🐇

"In the land of code, where logic intertwines,

Changes are made, as the moon aligns.

Refactoring here, adding there,

A construct function, crafted with care.

Utility functions, in their new den,

Ready for use, again and again.

Celebrate these changes, for they shine bright,

In the world of code, they're a delightful sight." 🌙✨


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • Mention @coderabbitai in any review comment for bot assistance.
  • Note: Review comments are made on code diffs or files, not on the PR overview.

Pause Incremental Reviews

  • Insert @coderabbitai: ignore in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
  • Additionally, enter @coderabbitai pause to halt the bot's ongoing reviews as any issue or review comment. To
    resume reviews, enter @coderabbitai resume as any issue or review comment.

Copy link

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 27cd6e0 and 67f6754.
Files selected for processing (1)
  • contracts/okp4-cognitarium/src/contract.rs (8 hunks)
Additional comments (Suppressed): 7
contracts/okp4-cognitarium/src/contract.rs (7)
  • 49-59: The import list in the execute module has been updated. The SelectItem, SimpleWhereCondition, WhereCondition, and HashSet are no longer imported, while DataFormat, Prefix, TriplePattern, WhereClause, PrefixMap, TripleReader, HasCachedNamespaces, and StoreEngine are newly imported. Ensure these changes are intentional and do not affect other parts of the code.

  • 92-102: The logic for creating patterns and variables has been refactored to use utility functions as_triple_patterns and as_select_veriables from the util module. This improves code readability and maintainability.

  • 106-113: The logic for creating atoms has been refactored to use the utility function as_atoms_result from the util module. This improves code readability and maintainability.

  • 139-147: The import list in the query module has been updated. The ConstructQuery, DescribeQuery, DescribeResponse, Node, SelectItem, SelectQuery, SelectResponse, SimpleWhereCondition, StoreResponse, TriplePattern, Value, VarOrNamedNode, VarOrNode, VarOrNodeOrLiteral, WhereCondition, PlanBuilder, QueryEngine, rdf, Atom, PrefixMap, and TripleWriter are newly imported. Ensure these changes are intentional and do not affect other parts of the code.

  • 284-336: A new function construct has been added to handle the Construct query. This function builds a plan, executes it, and writes the results to a TripleWriter. The logic for creating patterns, variables, and atoms has been refactored to use utility functions from the util module. This improves code readability and maintainability.

  • 339-385: A new util module has been added to house utility functions as_select_veriables, as_triple_patterns, and as_atoms_result. This improves code modularity and maintainability.

  • 1894-1953: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [1894-1988]

The test proper_construct has been updated to reflect the changes in the construct function. Ensure the test cases cover all possible scenarios and edge cases.

@ccamel ccamel requested a review from amimart October 17, 2023 15:45
@ccamel
Copy link
Member Author

ccamel commented Oct 17, 2023

@amimart I've done the minimum required for the implementation of the feature. The test coverage has decreased due to an error case not tested but difficult to test. I believe we can accept this state.

Copy link
Member

@amimart amimart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good thx :)

@ccamel ccamel merged commit 2dffa60 into main Oct 18, 2023
16 of 18 checks passed
@ccamel ccamel deleted the feat/cognitarium-construct branch October 18, 2023 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants