Data::...rtition(3pm)
okay so this is the Data::...rtition(3pm) page from the User Contributed Perl Documentation, and the module is Data::ObjectDriver::Driver::SimplePartition π
β¨ yes bestie, weβre talking about partitioning objects across databases β stay with me, itβs actually iconic.
πΈ NAME πΈ
Data::ObjectDriver::Driver::SimplePartition β basic partitioned object driver. Thatβs the whole vibe: a basic driver for partitioned objects π
π¦ SYNOPSIS π¦
Hereβs the code, verbatim, no cap:
package ParentObject;
use base qw( Data::ObjectDriver::BaseObject );
__PACKAGE__->install_properties({
columns => [ 'parent_id', 'partition_id', ... ],
...
driver => Data::ObjectDriver::Driver::DBI->new( @$GLOBAL_DB_INFO ),
primary_key => 'parent_id',
});
__PACKAGE__->has_partitions(
number => scalar @PARTITIONS,
get_driver => \&get_driver_by_partition,
);
package SomeObject;
use base qw( Data::ObjectDriver::BaseObject );
__PACKAGE__->install_properties({
...
driver => Data::ObjectDriver::Driver::SimplePartition->new(
using => 'ParentObject'
),
primary_key => ['parent_id', 'object_id'],
});
π DESCRIPTION π
Data::ObjectDriver::Driver::SimplePartition is a basic driver for objects partitioned into separate databases. Want the full tea on partitioning databases? See Data::ObjectDriver::Driver::Partition π«Ά
SimplePartition 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 β same reference, different moment β¨
π SUGGESTED PRACTICES π
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. That lets you scale horizontally with the number of users, at the cost of complicating querying multiple usersβ data together. trade-offs, bestie βοΈ
SimplePartition will load the related instance of the parent class every time it needs to find the partition for a related object. So 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. minimal parent, maximal slay π
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 that contains and automatically specifies the partition_get_driver function. shared logic, shared vibe π«Ά
β¨ USAGE β¨
π Data::ObjectDriver::Driver::SimplePartition->new(%params) π
Creates a new basic partitioning driver for a particular class. The required members of %params are:
usingβ 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 defined:
columnsβ the parent class must have apartition_idcolumn containing a partition identifier. This identifier is passed to thepartition_get_driverfunction to identify a driver to return.primary_keyβ 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 classes.partition_get_driverβ thepartition_get_driverproperty must be a function that returns an object driver, given a partition ID and any extra parameters given to theSimplePartitionconstructor. This property can also be defined asget_driverin a call toClass->has_partitions(). SeeData::ObjectDriver::BaseObject.
You can also include any further optional parameters you like. They will be passed to the partitioned classβs partition_get_driver function as given. extra params? sure bestie π
A SimplePartition driver will require these properties to be defined for partitioned classes:
primary_keyβ your primary key should be a complex primary key (arrayref) with the simple key of the parent object for the first field. first field = parent key, iykyk π
π DIAGNOSTICS π
using is required.β theusingparameter to theSimplePartitionconstructor is required to create the partitioned classβsget_driverfunction. Perhaps you omitted it, or your subclass ofSimplePartitiondid not properly specify it to its parentβs constructor. required means required, bestie πBogus classname.β the parent class name you specified in yourusingparameter 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. classname vibe check failed π¨Failed to load parent class: errorβ the parent class you specified in yourusingparameter could not be loaded, for the given reason. Perhaps you didnβt include its location in your library path. library path said no πPartitioning driver not defined for partitioned classβ the partitioned class named in the error is configured to use theSimplePartitiondriver but does not have apartition_get_driverset. Check that you intended to useSimplePartitionwith that class or, if youβre automatically specifying thepartition_get_driverfunction, that your technique is working correctly. driver? not defined? not cute π«Cannot extract column from terms search terms or primary keyβ theSimplePartitiondriver 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 allsearch()calls for the partitioned class and instances of partitioned objects before attempting to save them.
Optionaly you can enable a basic support of search across multiple partition by passing the 'multi_partition' arg (true value) to the search query. multi-partition search? optionaly iconic π
Member of class with ID parent ID not foundβ 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. rip, the parent is gone π
π BUGS AND LIMITATIONS π
There are no known bugs in this module. periodt, clean slate π
π SEE ALSO π
Data::ObjectDriver::Driver::Partition β go read that too, bestie π
π LICENSE π
Data::ObjectDriver is free software; you may redistribute it and/or modify it under the same terms as Perl itself. free software slay π
π AUTHOR & COPYRIGHT π
Except where otherwise noted, Data::ObjectDriver is Copyright 2005-2006 Six Apart, cpan@sixapart.com. All rights reserved. respect the copyright, bestie π«Ά
okay bye bestie π β this page comes from perl v5.42.0, dated 2024-10-24, and the footer tag is Data::...rtition(3pm). periodt β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Data-ObjectDriver 0.230.0-bp160.1.12 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms