Closed evomimic closed 2 days ago
@evomimic if there are not relationships for the given name, should get_related_holons just return an empty RelationshipMap, or should it be an Option or HolonError ?
@evomimic if there are not relationships for the given name, should get_related_holons just return an empty RelationshipMap, or should it be an Option or HolonError ?
Empty RelationshipMap
get_related_holons
looks goodget_related_holons
look good, although a few comments in the code about the strategy behind that implementation might be nice._In smartreference.rs:
get_rc_holon(&self, context)->Result<Rc<RefCell<Holon>>, HolonError>
methodget_key_from_link
method (it doesn't seem to be used -- and this is not the right place to be mucking around with link internals anyway).get_property_value()
-- if it can't get the property value out of smart_values, it should use get_rc_holon
to get the rc_holon and then delegate the get_property_value
call to the rc_holon.-- use
get_rc_holonto get the rc_holon and then delegate the
get_related_holons` call to the rc_holon.get_key
-- should first attempt to get the key from its smart_property_values and, failing that, use get_rc_holon
to get the rc_holon and then delegate the get_key
call to the rc_holon.The get_property_map
and get_relationship_map
methods should just be deleted, but this has ripple effects to other files, so I've pushed those changes off to a separate issue #118.
There are also several issues in the holon.rs file: <I'll fill these in shortly>
get_related_holons
is incorrect. It should be calling load_relationship_map
. impl Holon
block instead of a separate impl HolonGettable for Holon
block.My review also revealed a problem with the load_relationship_map
implementation. One of the central tenets of the Shared Objects Layer is at-most-once semantics. Specifically:
holon_node
should be retrieved at-most-once from the persistence tier and then cached andat-most-once
from the persistence tier. In the current implementation, (1) is enforced by HolonCache, but (2) should be enforced by load_relationship_map
, but it isn't.
_In smartreference.rs:
The get_property_map
and get_relationship_map
methods should just be deleted, but this has ripple effects to other files, so I've pushed those changes off to a separate issue #118.
There are also several issues in the holon.rs
file:
get_holon(id
) method (and delete the call to it from holon_api.rs
)._context
as a parameter to match the Trait signature.get_relationship_links
function to smartlink.rs
and change its signature and implementation so that it returns a Result<Vec<SmartLink>, HolonError>
-- As a general rule, there should be no visibility or use of holochain LinkTypes outside of the smartlinks.rs
file.load_relationship_map
function to only invoke get_relationship_links
once per relationship
load_relationship_map
a method on Holon that takes &mut self instead of holon_id get_relationship_links
for a relationship_name, we should first check the relationship_map
to see if it already has an entry for that relationship. If so, simply return that entry.
get_relationship_links
and add an entry in the RelationshipMap for that relationship_name
-- even if no links for found for that relationship. This keeps us from calling get_relationship_links
again for that relationship (honoring at-most-once semantics).Steps for completing the carryover from Issue #79 . These steps are being deferred to a later issue.
abandon_staged_changes
test chase:After the commit step, we need to add a query_relationship_test_step
. This step requires a NodeCollection containing the source nodes for the query and a QueryExpression containing the relationship_ name of the relationships we want to query.
Add a match_db_content_step that matches the Book holon to the retrieved Book holon
attempts to get_related_holons for an abandoned holon fail
Summary
This enhancement completes the work begun under issue #84 and delivers the "_get_related_holons_" dance to the Uniform API. This dance is a QueryMethod that retrieves references to existing or staged holons that are related to the source holon via a specified
relationship_name
(if such a name is supplied) or via ANY relationship if arelationship_name
is not supplied. If the source holon is an existing (vs. a staged) holon, then a side-effect of this dance may be to retrieve SmartLinks from the persistent store in order to update the RelationshipTarget(s) within the source holon's RelationshipMap.Current State of Native Functionality:
get_related_holons
method does not currently exist.Dependencies
Proposal
Enhance Native Functionality
Define and Implement
get_related_holons
method to theHolonGettable
TraitIn this method,
&self
is a either a HolonReference, StagedReference, SmartReference or Holon that represent the source holon whose related holons are being requestedrelationship_name
, if provided, indicates the name of the relationship being navigated. In the future, this parameter will be replaced with an optional reference to theRelationshipDescriptor
for this relationship. If None, then all holons related to the source holon across all of its relationships are retrieved.This method populates the cached source holon's RelationshipTarget for the specified relationship if one is provided. If relationship_name is
None
, the source holon's RelationshipTargets are populated for all relationships that have related holons.In the holon.rs file
get_related_holons
method for Holon_In the holonreference.rs file
get_related_holons
method of the HolonGettable Trait. This implementation should just delegate the call to the same method on its variant._In the stagedreference.rs file
get_related_holons
method of the HolonGettable Trait._In the smartreference.rs file
get_related_holons
method of the HolonGettable Trait.Dance Enhancements
Implementation Initial Query Layer Data Objects
This issue provides the opportunity to introduce the Query Layer of the guest-side architecture:
The basic concept is a graph data structure consisting of nodes, relationships, and collections . Nodes, their relationships, and the collections referenced from those relationships are returned as results of query dances and those nodes or collections can be used as inputs to subsequent query dances.
pub struct Collection { members: Vec,
query_spec: Option
}
pub struct QueryPathMap (pub BTreeMap<RelationshipName, Collection>)
pub struct QueryExpression { relationship_name: Option
}
/// DanceRequest: /// - dance_name: "query_relationships" /// - dance_type: QueryMethod(Collection) -- specifies the Collection to use as the source of the query /// - request_body: QueryExpression(QueryExpression) /// /// /// ResponseBody: /// - Collection -- a collection containing the same source nodes passed in the request, but with their
relationships
/// updated to include entries that satisfy the criteria set by the QueryExpression supplied in the request ///