Re: [OPEN-ILS-DEV] PATCH: osrf_json_object.c (tweaks)

2007-12-09 Thread Mike Rylander
On Dec 8, 2007 1:52 PM, Scott McKellar [EMAIL PROTECTED] wrote:
 These patches tidy up a few things and introduce a modest performance
 boost.  Summary:

Applied.

As an aside, I think Bill's design inside the parser was to model a
SAX parser, which would allow for construction of differently shaped
objects given different handlers.  In particular, we currently do the
standard JSON-jsonObject dance and then go back and build a classed,
semantically equivalent (though structurally different) object in
parallel.  One day, if it's warranted (and I think it is), we may have
a set of handlers that build the semantically correct objects the
first time around.

Bill, can you confirm that thinking?

-- 
Mike Rylander
 | VP, Research and Design
 | Equinox Software, Inc. / The Evergreen Experts
 | phone:  1-877-OPEN-ILS (673-6457)
 | email:  [EMAIL PROTECTED]
 | web:  http://www.esilibrary.com


Re: [OPEN-ILS-DEV] PATCH: osrf_json_object.c (tweaks)

2007-12-09 Thread Bill Erickson

Scott McKellar wrote:

I've never used a SAX-style parser, but as I understand it, the idea
is to parse the data stream incrementally, and respond to syntactic
features as you encounter them.  The alternative DOM-style approach
is to load the whole thing into memory at once in some kind of data
structure, such as a jsonObject.
  


That's pretty much it.

[snip]


What I'm leading up to is the following suggestion.

Some kinds of needs might be well met by something like a
jsonParseNextSubobject function, and maybe a jsonParseFirstSubobject.
Given a pointer to the middle of a buffer somewhere, it would parse
until it reached the end of the next subobject and then return
a pointer to a jsonObject representing it.

In the example of the Houghton-Mifflin extractor, it would extract
one book's worth of jsonObject at a time, including whatever
lower-level objects were contained therein.  Once you were done with
a given book you could free it and grab the next one.

However I have no idea whether such a thing would be useful in the
context of Evergreen -- nor can I claim to know much about what I'm
talking about.
  


The new JSON parser has both DOM and SAX style API's.  The DOM API is 
just a thin wrapper over the SAX core.  This makes the DOM internals 
slightly more obtuse and less efficient, but I'm sure with a little 
tweaking it can be as fast as a non-SAX implementation. 

There was no direct purpose for the SAX API when it was developed, but I 
would like to keep the API intact for potential future use.  Currently, 
no ILS or OpenSRF code is using the SAX API. 

Mike, your suggestion for replacing SAX callbacks to construct classed 
objects sounds like a good potential use.


-bill  



--
Bill Erickson
| VP, Software Development  Integration
| Equinox Software, Inc. / The Evergreen Experts
| phone: 877-OPEN-ILS (673-6457)
| email: [EMAIL PROTECTED]
| web: http://esilibrary.com