[redland-dev] Changing Immutable redland nodes

Dave Beckett dave.beckett at bristol.ac.uk
Thu Jul 31 18:57:12 BST 2003


I'm considering making Redland's node objects immutable once constructed.
i.e. if you make a node for a URI, for an anonymous node with some ID
or a literal, you will not be able to change anything.  You could of course
still build, destroy, use their get accessor methods and copy them.

This would have some nice performance improvement possibilities that
I could then do by interning them to be unique objects in the system
per URI, literal string etc.  Nodes are used a lot, so this would likely
make things faster.  (URIs are already interned in this fashion).

I propose to delete the following set accessors from the public API.

  librdf_node_set_blank_identifier(librdf_node* node, const char *identifier) 
  librdf_node_set_li_ordinal(librdf_node* node, int ordinal) 
  librdf_node_set_literal_value(librdf_node* node, const char* value, const char *xml_language, int is_wf_xml)
  librdf_node_set_type(librdf_node* node, librdf_node_type type)
  librdf_node_set_typed_literal_value(librdf_node* node, const char* value, const char *xml_language, librdf_uri* datatype_uri)
  librdf_node_set_uri(librdf_node* node, librdf_uri *uri)

and this also, which is sort of a set_type=resource and looks pretty
useless.
  librdf_node_init(librdf_world *world, librdf_node *node)

Plus consequent changes to the language interfaces.

So, if you use the node set methods a lot and have a good reason
to keep them around, please shout now.

Dave


----
Just for reference the following would remain:

The constructors:
librdf_new_node(librdf_world *world)
librdf_new_node_from_blank_identifier(librdf_world *world, ...)
librdf_new_node_from_literal(librdf_world *world,  ...)
librdf_new_node_from_normalised_uri_string(librdf_world *world,  ...)
librdf_new_node_from_typed_literal(librdf_world *world,  ...)
librdf_new_node_from_uri(librdf_world *world, librdf_uri *uri) 
librdf_new_node_from_uri_local_name(librdf_world *world,  ...)
librdf_new_node_from_uri_string(librdf_world *world, const char *uri_string) 

Copy constructor:
librdf_new_node_from_node(librdf_node *node) 

Destructor:
librdf_free_node(librdf_node *node) 

Methods:
librdf_node_decode(librdf_node* node, unsigned char *buffer, size_t length)
librdf_node_encode(librdf_node* node, unsigned char *buffer, size_t length)
librdf_node_equals(librdf_node* first_node, librdf_node* second_node) 
librdf_node_get_blank_identifier(librdf_node* node)
librdf_node_get_digest(librdf_node* node) 
librdf_node_get_li_ordinal(librdf_node* node)
librdf_node_get_literal_value(librdf_node* node) 
librdf_node_get_literal_value_as_counted_string(librdf_node* node,  ...)
librdf_node_get_literal_value_as_latin1(librdf_node* node) 
librdf_node_get_literal_value_datatype_uri(librdf_node* node)
librdf_node_get_literal_value_is_wf_xml(librdf_node* node) 
librdf_node_get_literal_value_language(librdf_node* node) 
librdf_node_get_type(librdf_node* node) 
librdf_node_get_type_as_string(int type)
librdf_node_get_uri(librdf_node* node) 
librdf_node_to_counted_string(librdf_node* node, size_t* len_p)
librdf_node_to_string(librdf_node* node) 

(Plus some redland internal things)



More information about the redland-dev mailing list