George Hartzell scribbled on 12/4/06 3:55 PM:
> Peter Karman writes:
>  > 
>  > 
>  > Peter Leonard scribbled on 12/4/06 1:57 PM:
>  > 
>  > > 
>  > > I understand the complexity involved, and what we're looking for is the 
>  > > quick storage & retrieval of the underlying data - I'll look at the 
>  > > json/yaml serialization implementations.
>  > > 
>  > 
>  > 
>  > fwiw, I'm using Swish-e to store my serialized RDBO objects, with the
>  > added benefit of being able to do full-text search and sorting on them
>  > as well. I'm using
>  > 
> http://search.cpan.org/~karman/SWISH-API-Object-0.05/lib/SWISH/API/Object.pm
> 
> Did you stumble upon and any pitfalls when you set this up?  Is it
> magical enough that an example might be useful?  (skimming the link
> above doesn't give me a feel if it's enough just to say that the
> result is an RDBO::... or if something more special needs to happen.

Sorry it's taken me awhile to get back to this; have been busy with new kid at 
our house.

I just uploaded to CPAN new versions of both SWISH::API::Object and 
SWISH::Prog::Object, which can be used together to de/serialize data structures 
in Swish-e indexes.

I was inspired by Rose's use of YAML::Syck and JSON::Syck to serialize objects, 
so the SWISH::* modules now offer those serialization formats (as well as the 
ability to subclass and define your own de/serializer).

Here's how I use them.

We have a group of <1000 RDBO objects that change only once a month or so. They 
are composed of several JOINs against many-to-many table relationships. We need 
to select and sort subgroups very often. The sorting in particular proved 
challenging and time-consuming. So we index them with the SWISH::* modules to 
pre-sort all the simple scalar values, which helps immensely. All those JOINs 
and the sorting is done once and cached in the index. And the Swish-e syntax is 
much simpler for searching than using SQL (though of course not as powerful).

Example:

  my @rdbobjects = get_my_objects();
  # these are flattened to remove all the Rose::* stuff and
  # leave only the column values. The values can be whatever can
  # be serialized with YAML or JSON.

  my $indexer = SWISH::Prog::Object->new(
        methods => [ @list_of_accessors_in_rdbobject ]
  );

  $indexer->create( [EMAIL PROTECTED] );
  # create the index


Then to search/thaw the objects, I use SWISH::API::Object to fetch each result 
as a hashref blessed into the class of my choice. Could be a RDBO, to get a 
'thaw-like' effect, though in my case, I don't need to hit the DB anymore, so I 
don't bother. But see the SWISH::API::Object doc, especially the 'stash' and 
'class' params to new().

Let me know offlist if you have more questions, since we've ventured out of 
Rose 
territory here. :)

Thanks again to John for the good Rose mojo and for the idea of using libsyck.

cheers,
pek




-- 
Peter Karman  .  http://peknet.com/  .  [EMAIL PROTECTED]

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to