Question
· Feb 8, 2018

Time and space complexity for SDA parsing using object deserialization and xml xpath

Intersytems  documentation says not to hold entire SDA  as object in In-memory. 

 http://localhost:57772/csp/documatic/%25CSP.Documatic.cls?LIBRARY=registry&CLASSNAME=HS.SDA3.Container&MEMBER=&CSPCHD=001000000000x1zyO3kkajy0iIjjpi2dxUJUnwFSY_pz7jtbNV&CSPSHARE=1

 // Serialize Object to XML
  
  Set object = ##class(User.NewClass1).%New()
  object.Property1="one"
  object.Property2="two"
  object.Property3="three"
  object.Property4="four"
  Set w=##class(%XML.Writer).%New()
  set w.Charset="UTF-8"
  Set w.Indent=1
  set status=w.OutputToString()
  set status=w.StartDocument()
  Set status=w.RootObject(object,"Vivek")
  set status=w.EndDocument()
  If $$$ISERR(status) Do $system.OBJ.DisplayError(status) Quit
  set xmlstring = w.GetXMLString()
 
      // Serialize XML to Object
      Set obj = ##class(User.NewClass1).%New()
  Set reader = ##class(%XML.Reader).%New()
  Set status =reader.OpenString(xmlstring)
  Do reader.CorrelateRoot("User.NewClass1")
  Do reader.Next(.obj,.status)
  Write "Property1 "_obj.Property1 

Discussion (1)0
Log in or sign up to continue

Was there a question?  Yes, of course, Cache' supports methods to serialize and deserialize XML enabled objects.  However, those methods have to apply to all sorts of general XML structures, and as a result, are much less efficient than ones where we have a very known/constrained data model.  One specific case involves embedded serial objects - serializing these to XML will cause them to be instantiated in memory even if null.  In addition, SDA containers can be arbitrarily large - we have examples of 50-100mb size containers.  Depending on your partition size, attempting to deserialize an entire container can cause a <STORE> error.