Closed drj826 closed 8 years ago
The current library methods that provide access to property data are:
my $text = $library->get_first_property_value($division_id,$property_name) my $element = $library->get_first_property_value_element($division_id,$property_name) my $list = $library->get_property_value_list($division_id,$property_name) my $list = $library->get_property_value_element_list($division_id,$property_name) my $element = $library->get_property_value_element($division_id,$property_name,$property_value) my $object = $library->get_property_value_object($division_id,$property_name,$property_value)
For the majority of templating needs I think I should be able to get by with:
my $text = $library->get_property_value($division_id,$property_name); # NEW my $string = $library->get_property_value_string($division_id,$property_name); # NEW my $list = $library->get_property_value_list($division_id,$property_name); my $list = $library->get_property_value_string_list($division_id,$property_name); # NEW
Actually, there is no collision between the old API and the new API. I just need to add 3 new methods.
I've decided to add two new classes: (1) ElementStore, and (2) PropertyStore. A library object will have one of each of these. The ElementStore object will store raw elements. The PropertyStore will store "assembled" property values in plain text and SML::String form. Properties in the PropertyStore may either be assembled from manuscript elements or be inferred by the Reasoner.
The ElementStore's 'add_element' method will update the PropertyStore's holdings whenever an element is added.
Templates should only access the PropertyStore and should never need to access raw elements.
The purpose of the ElementStore is to de-duplicate element data. It will store element data in a three dimensional hash:
$hash->{$division_id}{$property_name}{$property_text} = $element;
Even if an SML manuscript contains a division with duplicate elements like this:
>>>DOCUMENT.my-doc title:: My Document author:: Don Johnson author:: Don Johnson . . . <<<DOCUMENT
The duplicate element will be de-duplicated and the document author propery will only have one value.
After playing with this for a while I don't see why this functionality shouldn't be provided by a SINGLE class (SML::PropertyStore). The PropertyStore class can have the 'add_element' method.
Don't execute PropertyStore 'add_element' at Parser '_end_element' -- instead process all elements when you reach the end of an entity or the end of a document.
Well I screwed that up good!
Before optimization: 3 min 23 seconds to publish the library After optimization: 3 hours 20 minutes
The current API for getting property values from a library object is horrible. For instance:
Many templates use this call this way:
That's pretty terrible. The template system should probably not bother with individual elements. I would rather see: