Data::ObjectDriver::Driver::SimplePartition - basic partitioned object driver
use base qw( Data::ObjectDriver::BaseObject );
columns => [ 'parent_id', 'partition_id', ... ],
driver => Data::ObjectDriver::Driver::DBI->new( @$GLOBAL_DB_INFO ),
primary_key => 'parent_id',
number => scalar @PARTITIONS,
get_driver => \&get_driver_by_partition,
use base qw( Data::ObjectDriver::BaseObject );
driver => Data::ObjectDriver::Driver::SimplePartition->new(
using => 'ParentObject'
primary_key => ['parent_id', 'object_id'],
is a basic driver for objects
partitioned into separate databases. See Data::ObjectDriver::Driver::Partition
for more about partitioning databases.
helps you partition objects into databases based on their
association with one record of a parent
class. If your classes don't
meet the requirements imposed by SimplePartition
, you can still write
your own partitioning driver. See Data::ObjectDriver::Driver::Partition.
Often this is used for user partitioning, where the parent class is your user
account class; all records of other classes that are "owned" by that
user are partitioned into the same database. This allows you to scale
horizontally with the number of users, at the cost of complicating querying
multiple users' data together.
will load the related instance of the parent class every
time it needs to find the partition for a related object. Consider using a
minimal mapping class for the parent, keeping as much data as possible in
other related classes. For example, if "User" were your parent
class, you might keep only
the user ID and other data used to find
users (such as login name and email address) in "User", keeping
further profile data in another "UserProfile" class.
As all the partitioned classes related to a given parent class will share the
same "partition_get_driver" logic to turn a partition ID into a
driver, you might put the "partition_get_driver" function in the
parent class, or use a custom subclass of SimplePartition
and automatically specifies the "partition_get_driver" function.
Creates a new basic partitioning driver for a particular class. The required
members of %params are:
The name of the parent class on which the driven class is partitioned.
Using a class as a parent partitioned class requires these properties to be
The parent class must have a "partition_id" column containing a
partition identifier. This identifier is passed to the
"partition_get_driver" function to identify a driver to
The parent class's primary key must be a simple single-column key, and that
column must be the same as the referencing column in the partitioned
The "partition_get_driver" property must be a function that
returns an object driver, given a partition ID and any extra parameters
given to the "SimplePartition" constructor.
This property can also be defined as "get_driver" in a call to
You can also include any further optional parameters you like. They will be
passed to the partitioned class's "partition_get_driver" function as
driver will require these properties to be defined for
Your primary key should be a complex primary key (arrayref) with the simple
key of the parent object for the first field.
- "using is required."
The "using" parameter to the SimplePartition constructor is
required to create the partitioned class's "get_driver"
function. Perhaps you omitted it, or your subclass of
SimplePartition did not properly specify it to its parent's
- "Bogus classname."
The parent class name you specified in your "using" parameter does
not appear to be a valid class name. If you are automatically generating
parent class names, check that your method of converting strings to class
names is correct.
- "Failed to load parent class: error"
The parent class you specified in your "using" parameter could not
be loaded, for the given reason. Perhaps you didn't include its location
in your library path.
- "Partitioning driver not defined for partitioned
The partitioned class named in the error is configured to use the
SimplePartition driver but does not have a
"partition_get_driver" set. Check that you intended to use
SimplePartition with that class or, if you're automatically
specifying the "partition_get_driver" function, that your
technique is working correctly.
- "Cannot extract column from terms search
terms or primary key"
The SimplePartition driver could not determine from the given search
terms or object key what the ID of the related parent record was. Check
that your columns in the partitioned and parent classes share the same
name, and that your application includes the parent ID in all
"search()" calls for the partitioned class and instances of
partitioned objects before attempting to save them.
Optionally you can enable a basic support of search across multiple
partition by passing the 'multi_partition' arg (true value) to the search
- "Member of class with ID parent ID not
The parent record associated with the partitioned object could not be
loaded. Perhaps your application deleted the parent record without
removing its associated partitioned objects first.
There are no known bugs in this module.
is free software; you may redistribute it and/or
modify it under the same terms as Perl itself.
Except where otherwise noted, Data::ObjectDriver
is Copyright 2005-2006
Six Apart, email@example.com. All rights reserved.