Install
(XXXXXX)KiokuDBXXXXXXXXXXXXXXXXXXXXXXTask::KiokuDBXXXXXXXXXXXXXXXXXX
KiokuDBXMooseXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXX
KiokuDBXXXXXXXXXXXXXXXXXXXXX DBIXXXXXXXXXXXXXXXDBDXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXKiokuDB::Backend::HashXXXXXXXXXXXXXXXXX XXXXXXXXXXKiokuDB::Backend::DBDXKiokuDB::Backend::DBIXKiokuDB::Backend::BDB XXXXXXXXXXXXXXXX
KiokuDB::Backend::DBDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
CREATING A DIRECTORY HANDLE
(XXXXXXXXXXXXX)KiokuDBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX:
my $dir = KiokuDB->new( backend => KiokuDB::Backend::Hash->new );
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXDSNXXXXXXXXXXXXXX
KiokuDB->connect("hash"); KiokuDB->connect("dbi:SQLite:dbname=foo", create => 1); KiokuDB->connect("bdb:dir=foo", create => 1);
XXXXXXXXXXXXXXXXX
KiokuDB->connect("/path/to/my_db.yml");
XXYAMLXXXXXX:
--- # these are basically the arguments for 'new' backend: class: KiokuDB::Backend::DBI dsn: dbi:SQLite:dbname=/tmp/test.db create: 1
USING THE DBI BACKEND
(DBIXXXXXXXXX)2XXXXXXXXXXXXXXXXXDBIXXXXXXXXXXXX 1XXXXXXXDBIXXXXXXXXXXXXX 2XXXXXXXXXXXXXXXXXXXXXXXXXXX KiokuDBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXX$dirXXXXXXXXXXXXXX:
my $dir = KiokuDB->connect( "dbi:SQLite:dbname=kiokudb_tutorial.db", create => 1, # this causes the tables to be created );
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:
my $dir = KiokuDB->connect( $dsn, user => $user, password => $password, );
INSERTING OBJECTS
(XXXXXXXXXXXX)MooseXXXXXXXXXXXXXXXXXXXX:
package Person; use Moose; has name => ( isa => "Str", is => "rw", );
XXXXXXXXXXXXX:
my $obj = Person->new( name => "Homer Simpson" );
XXXXXXXXXXXXXXXXXXXXXXXX:
my $scope = $dir->new_scope; my $homer_id = $dir->store($obj);
XXXXKiokuDBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1XXXXXXXXXXXXXXXXXKiokuDBXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXMooseXXXXXXXXXXX
2XXXXXXXXXXXXXXXXXXXXXXXXXXXXIDXXXXXX XXXXXXXIDXXXXXXXXXKiokuDBXXXXXUUIDXXXXXXXX
IDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXIDXXXXXXXXXXXXXXXXXXXXXX:
$dir->store( homer => $obj );
3XXXXXXXXKiokuDBXXXscopeXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXweakXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXX
LOADING OBJECTS
(XXXXXXXXXXX)XXXXXXXXXXHomerXXXXXXX"store"XXXXIDXXXXXXXX
my $homer = $dir->lookup($homer_id);
$scopeX$objXXXXXXXXXXXXXXX$homerX$objXXXXXXXXXXXXXXXXXXX
# this is true: refaddr($homer) == refaddr($obj)
XXXXXXXXXXXXXXX (KiokuDB::LiveObjects)XXXXXXXXX ``XX''XXXXXXKiokuDBXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXKiokuDBXXXXXXXX XXXXXXXXXXXXXX
WHAT WAS STORED
(XXXXXXXX)XXXXXXXXXXXXXXX:
% sqlite3 kiokudb_tutorial.db SQLite version 3.4.0 Enter ".help" for instructions sqlite>
XXXXXXXXXXXXX2XXXXXXXXXXXX"entries"X"gin_index"XX:
sqlite> .tables entries gin_index
"gin_index"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXX"entries"XXXXXXXXXXXX:
sqlite> .schema entries CREATE TABLE entries ( id varchar NOT NULL, data blob NOT NULL, class varchar, root boolean NOT NULL, tied char(1), PRIMARY KEY (id) );
XXXXXXXX"id"X"data"XXXKiokuDBXXXXXXXXXXXXXXXXIDXXXX XXXXXXXXBLOBXXXXXXXXXXXXXXX
DBIXXXXXXXXXXXXXXXXXXXXXKiokuDB::Serializer::JSONXXXXX XXXXXXXXXXX
XXXX"sqlite"XXXXXXX"line"XXXXXXXXXXXXXXXXXX XXXXXXXX:
sqlite> .mode line
XXXXXXXXXXXXXXX:
sqlite> select id, data from entries; id = 201C5B55-E759-492F-8F20-A529C7C02C8B data = {"__CLASS__":"Person","data":{"name":"Homer Simpson"},"id":"201C5B55-E759-492F-8F20-A529C7C02C8B","root":true}
XXXXXXX"name"XXXblobXX"data"XXXXXXXXXXXXXXXXXXXXXXXXX
"data"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXX
KiokuDB::Backend::DBDXXXXXXXXXXXXXXXXXXXXXX"id"XX"data"XXXXXXXXX XXXXXXXXXXXXXXX
OBJECT RELATIONSHIPS
(XXXXXXXXXXXXXXXX)"Person"XXXX"name"XXXXXXXXXXXXXXXXXXXXXXX:
package Person; has spouse => ( isa => "Person", is => "rw", weak_ref => 1, );
"spouse"XXXXXPersonXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXX:
my $marge_id = $dir->store( Person->new( name => "Marge Simpson" ), );
XXXXXXXXXXXXXXXXXXXXXXX2XXXXXXXXXXXXX:
{ my $scope = $dir->new_scope; my ( $marge, $homer ) = $dir->lookup( $marge_id, $homer_id ); $marge->spouse($homer); $homer->spouse($marge); $dir->store( $marge, $homer ); }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXX
"spouse"XX"weak_ref"XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXLinkDBX"spouse"XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXIDXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXX:
{ my $scope = $dir->new_scope; my $homer = $dir->lookup($homer_id); print $homer->spouse->name; # Marge Simpson } { my $scope = $dir->new_scope; my $marge = $dir->lookup($marge_id); print $marge->spouse->name; # Homer Simpson refaddr($marge) == refaddr($marge->spouse->spouse); # true }
KiokuDBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXX"spouse"XXXXXXXXXXXX(IDX) XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The purpose of new_scope
("new_scope"XXX)"new_scope"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXX"lookup"XX$homerXXXXXXXXXXX "spouse"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX:
sub get_homer { my $homer = Person->new( name => "Homer Simpson" ); my $marge = Person->new( name => "Marge Simpson" ); $homer->spouse($marge); $marge->spouse($homer); return $homer; # at this point $homer and $marge go out of scope # $homer has a refcount of 1 because it's the return value # $marge has a refcount of 0, and gets destroyed # the weak reference in $homer->spouse is cleared } my $homer = get_homer(); $homer->spouse; # this returns undef
XXXXXXXXXXX:
{ my $scope = $dir->new_scope; # do all KiokuDB work in here }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
WebXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXCatalyst::Model::KiokuDBXXXXXXXXXXXXXX
REFERENCES IN THE DATABASE
(XXXXXXXXXXXXXX)XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sqlite> select id, data from entries; id = 201C5B55-E759-492F-8F20-A529C7C02C8B data = {"__CLASS__":"Person","data":{"name":"Homer Simpson","spouse":{"$ref":"05A8D61C-6139-4F51-A748-101010CC8B02.data"}},"id":"201C5B55-E759-492F-8F20-A529C7C02C8B","root":true} id = 05A8D61C-6139-4F51-A748-101010CC8B02 data = {"__CLASS__":"Person","data":{"name":"Marge Simpson","spouse":{"$ref":"201C5B55-E759-492F-8F20-A529C7C02C8B.data"}},"id":"05A8D61C-6139-4F51-A748-101010CC8B02","root":true}
"spouse"XXXXXXJSONXXXXXXXXXXXXXXXXXXXX XXXXXXXXX$refXXXXXXXXXXXXXXXXXXUUIDXXXXXX
XXXXXXXXXXXXKiokuDBXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXX"JPSON"X JavaScript Persistent Object notation(<http://www.jpson.org>)XXXXXXXXX KiokuDB::Backend::StorableXXXXXKiokuDB::EntryXKiokuDB::ReferenceXXXXXXXX XXXXXstorableXXXXXXXXXXXXXXX
OBJECT SETS
(XXXXXXXXX)XXXXXXXXXXXXXX(1X1XXXXX)XXSet::ObjectXXXXXXXXXXXXXXXX
"Person"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:
package Person; has children => ( does => "KiokuDB::Set", is => "rw", );
KiokuDB::SetXXXXXXXXSet::ObjectXKiokuDBXXXXXXXXX
my @kids = map { Person->new( name => $_ ) } qw(maggie lisa bart); use KiokuDB::Util qw(set); my $set = set(@kids); $homer->children($set); $dir->store($homer);
"set"XXXXXXXXXXXXKiokuDB::Set::TransientXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXX (XXXXXXXXXXXXXXXXXXXXXX)X
"weak_set"XXXXXXXXXXXXXX XXXX(XXXXXXXX"parent"XXXXXXX)XXXXXXXXXXXXXXXXX Set::Object::WeakXXXXXXXXXXXXXX
XXXXXXXXXXXXSet::ObjectXXXXXXXXXXXXXXXXX
my @kids = $dir->lookup($homer_id)->children->members;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX @kidsXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXKiokuDB::Set::DefferedXKiokuDB::Set::LoadedXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXX2XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
THE TYPEMAP
KiokuDBXXXXXXXXXXXXXXXXKiokuDB::CollapserXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXKiokuDB::EntryXX ``XXX''XXXXXXXXXXXXXXXcollapserXXXKiokuDB::TypeMapXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXtypemapXXXXXXX
typemapXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX(XXXX "DBI"XXXXXXXXXXXXXXSXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX)X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXMooseXXXXXXXXXXXXXMooseXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXX(DateTime, Path::ClassXX>)XX XXXXXXtypemapXXXXXXXXXKiokuDBXXXXXXXXXtypemapXXXXXXX XXXXXXXXXXXXXX
XXXXXXXKiokuDBXClass::AccessorXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXX:
KiokuDB->new( backend => $backend, allow_classes => [qw(My::Object)], );
XXXXXXXXXX:
my $dir = KiokuDB->new( backend => $backend, typemap => KiokuDB::TypeMap->new( entries => { "My::Object" => KiokuDB::TypeMap::Entry::Naive->new, }, ), );
KiokuDB::TypeMap::Entry::NaiveXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX
collapser XXXXXXXXXXXXXXXKiokuDB::TypeMap::ResolverXX XXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXX"ref $object"XXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXtypemapXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXX"isa_entries"XXXXXXXXXX
KiokuDB::TypeMap->new( isa_entries => { "My::Object" => KiokuDB::TypeMap::Entry::Naive->new, }, );
XXXXXXXXXX("ref" keyed)XXXXXXXXXXXXXXX isaXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Typemap Entries
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXX
KiokuDB::TypeMap::Entry::Callback->new( collapse => sub { my $object = shift; ... return @some_args; }, expand => sub { my ( $class, @some_args ) = @_; ... return $object; }, );
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXtypemapXISAXXXXXPath::ClassX:
'Path::Class::Entity' => KiokuDB::TypeMap::Entry::Callback->new( intrinsic => 1, collapse => "stringify", expand => "new", );
"intrinsic"XXXXXXXXXXXXXXXXX
typemapXXXXXXXXXXXXXKiokuDB::Typemap::Entry::PassthroughXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXX
XXXXXXXXXXXXXXStorableXXXXXX(XXXXXXXXXXXXXXXXXXXXXX)X XXXXXXXXXKiokuDB::Backend::Serialize::StorableXXXXXXXX DateTimeXXXXXXstorableXXXXXXXXXX:
'DateTime' => KiokuDB::Backend::Entry::Passthrough->new( intrinsic => 1 )
Intrinsic vs. First Class
KiokuDBXXXXXXXXXXXXXXXXXXIDXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXDateTimeXXPath::ClassXXXXXURIXXXXXXXXXXXXXX XXXXXXXX
KiokuDBXintrinsiclyXXXXXXXXXXXXXXX XXXXXXXXXXXXXXIDXXXXKiokuDB::EntryXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXX2XXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXX:
use Path::Class; my $path = file(qw(path to foo)); $obj_1->file($path); $obj_2->file($path); $dir->store( $obj_1, $obj_2 );
XXXXXXXXXXXXXXXXXXXXXXXXX $obj_1X$obj_2XXXXXXXXXXXXXXXXXXXXXXXXXXXXX:
refaddr($obj_1->file) == refaddr($obj_2->file)
$obj_1X$obj_2XXXX$pathXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXIDXXXXXXXXXXXXXXX XXXXXXXXXXXX
The Default Typemap
XXXXXXXXXXXXXXXXXXXXtypemapXXXXXXXX XXXXXXXXCPANXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX KiokuDB::TypeMap::DefaultXXXXXXXXXXXSIMPLE SEARCHES
(XXXXX)XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXAPIXXXXXXXXKiokuDB::Backend::DBIXXXXXXXXXXXXXX XXXXXXSQLXwhereXXXXXXXXXXXXXXXXXXXXX (XXXXXXXXXXXXXXXXXXXXXXXXXX)
"search"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXData::Stream::BulkXXXXXXXXXXXXX:
my $stream = $dir->search({ name => "Homer Simpson" }); while ( my $block = $stream->next ) { foreach my $object ( @$block ) { # $object->name eq "Homer Simpson" } }
XXXAPIXXXXXXXXXXXXXXXXXXDBIx::Class 0.09XXXXXXXX XXXXXXXXXXX
DBI SEARCH COLUMNS
XXXXXXXAPIXXXXXXDBIXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'name'XXXXXXXXXX:
my $dir = KiokuDB->connect( "dbi:SQLite:dbname=foo", columns => [ # specify extra columns for the 'entries' table # in the same format you pass to DBIC's add_columns name => { data_type => "varchar", is_nullable => 1, # probably important }, ], );
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"kioku dump"XXXX XXXXXXXXXXX"create => 1"XXXXX"kioku load"XXXXXXXXXXX
XXXXXXXXXXXXXXHomerXXXXXXXXXXXXXXXXXX:
{ my $s = $dir->new_scope; $dir->update( $dir->lookup( $homer_id ) ); }
XXXXXXXXXXXXXXXXX:
id = 201C5B55-E759-492F-8F20-A529C7C02C8B name = Homer Simpson
GETTING STARTED WITH BDB
(BDBXXXXX)KiokuDBXXXXXXXXXXXXXXXXXKiokuDB::Backend::DBDXX(XX:DBIXXXXXXXXXXXYAPC::Asia 2009XXXXXX)X XXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Search::GINXXXXXXXXXXXXXXXXXXX
KiokuDB::Backend::DBIXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXSearch::GINXXXXXX XXXXXXXXXXXXXXXXXXXKiokuDB::Backend::BDBXXXXXXXXXXXXXX (XX:YAPC::Asia 2009XXXXXXXXXXXXXXXX)
Installing KiokuDB::Backend::BDB
KiokuDB::Backend::BDBXXBerkeleyDBXXXXXXXXXXX XXXXXXXXXXXXBerkeley DBXXXXXXXXBerkeley DBXXXXXURLXXXXXX http://www.oracle.com/technology/software/products/berkeley-db/db/index.html <http://www.oracle.com/technology/software/products/berkeley-db/db/index.html>.BerkeleyDB(XXXXX)XXXX"/usr/local/BerkeleyDB.4.7"XXXXXXXXXXXX XXXXBerkeleyDB(XXXXX)XX"/usr/local/BerkeleyDB"XXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
BerkeleyDBXXXXXXXXXXXXKiokuDB::Backend::BDBXXXXXXXXXXXXXXXXXXX KiokuDBXXXXXXXXXXXXXX
Using KiokuDB::Backend::BDB
BDBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXX"create"XXXXXXXXXXXXXXXX
my $backend = KiokuDB::Backend::BDB->new( manager => { home => Path::Class::Dir->new(qw(path to storage)), create => 1, }, );
BDBXXXXXXXXBerkeleyDB::ManagerXXXXXXXXXXBerkeleyDBXXXXXXXXXX BerkeleyDB::ManagerXXXXXXX"manager"XXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
my $dir = KiokuDB->new( backend => $backend );
XXXXXXXXXXX"create"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XX"connect"XXXXXXXXXXX:
my $dir = KiokuDB->connect( "bdb:dir=path/to/storage", create => 1 );
TRANSACTIONS
(XXXXXXXX)XXXXXXXXXXX(KiokuDB::Backend::Role::TXNXXXXXXXX)XXXXXXXXXXXXXXXXXXXXXX
DBIx::ClassXXXXXXXXXXXXXXXXXX:
$dir->txn_do(sub { $dir->store($obj); });
BerkeleyDBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXX
KiokuDBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
$dir->txn_do(sub { my $scope = $dir->new_scope; $obj->name("Dancing Hippy"); $dir->store($obj); die "an error"; });
"name"XXXXXXXXXXXXXXX"store"XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX
QUERIES
(XXX)KiokuDB::Backend::BDB::GINXKiokuDB::Backend::BDBXXXXXXXX Serach::GINXXXXXXXXXXXXXXXXXX
Search::GINXXXXXXXXXXXXXXXXXXXXXXXXXXXXX PostgresXXXGIN apiXXXXXXXXXXXXX GINXXGeneralized Inverted Indexes(XX:XXXXXX)XXXXX
Search::GINXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXSearch::GINXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Search::GIN::Extract::Callback XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:
my $dir = KiokuDB->new( backend => KiokuDB::Backend::BDB::GIN->new( extract => Search::GIN::Extract::Callback->new( extract => sub { my ( $obj, $extractor, @args ) = @_; if ( $obj->isa("Person") ) { return { type => "user", name => $obj->name, }; } return; }, ), ), ); $dir->store( @random_objects );
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:
my $query = Search::GIN::Query::Manual->new( values => { type => "person", }, ); my $stream = $dir->search($query);
XXXXXXXXXXXXXData::Stream::BulkXXXXXXXXXXXX XXXXXXXXXXXXXXX
while ( my $block = $stream->next ) { foreach my $person ( @$block ) { print "found a person: ", $person->name; } }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:
my @people = $stream->all;
Search::GINXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXSearch::GIN::Extract::ClassXXXX XXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXX
XXXXXXX ([email protected])PerlXXXXXXXXXX Project XXX PerlXXXXXXXXXXXXXXXXXXXXXXXX
http://perldocjp.sourceforge.jp/ http://sourceforge.jp/projects/perldocjp/ http://www.freeml.com/ctrl/html/MLInfoForm/[email protected] http://www.perldoc.jp/