Search-GIN-0.08000755001750001750 011521546521 12764 5ustar00ruosoruoso000000000000README000644001750001750 142711521546521 13730 0ustar00ruosoruoso000000000000Search-GIN-0.08NAME Search::GIN - Generalized Inverted Indexing VERSION version 0.08 DESCRIPTION Inverted Indexing is an indexing method that maps from content to location in storage. Generalized Inverted Indexing (GIN, for short) is an inverted indexing method in which the index is unaware of what data exactly is it indexing. Search::GIN is primarily used by KiokuDB for custom indexing. SEE ALSO * pgsql-hackers msg #00960 * Inverted_index on Wikipedia AUTHOR Yuval Kogman COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Changes000644001750001750 115711521546521 14343 0ustar00ruosoruoso000000000000Search-GIN-0.080.08 01.31.11 * Fix dup release on CPAN 0.07 12.09.10 * Adds support for Set queries * Renaming excludes to -excludes, requiring Moose >= 0.89 * Removing special deprecated usage of qw (now complies with 5.13.5) 0.06 11.09.10 - Whoops, missed a debug output 0.05 11.09.10 - Adding a bit more docs - Moved to Dist::Zilla - Fixing SIGNATURE file (sorry sorry sorry) 0.04 04.03.10 - Safer attribute extraction - Multiplex extraction now works - Documentation for query modules - Fixed bug in manual query returning empty list - Updated copyright LICENSE000644001750001750 4361611521546521 14103 0ustar00ruosoruoso000000000000Search-GIN-0.08This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End dist.ini000644001750001750 53011521546521 14466 0ustar00ruosoruoso000000000000Search-GIN-0.08name = Search-GIN author = Yuval Kogman license = Perl_5 copyright_holder = Yuval Kogman, Infinity Interactive copyright_year = 2010 version = 0.08 [@Basic] [PodSyntaxTests] [PodWeaver] [ReadmeFromPod] [CheckChangeLog] [PkgVersion] [CompileTests] [AutoPrereq] skip = ^(Bar|Base|MyTagQuery)$ [Prereq] Moose = 0.89 t000755001750001750 011521546521 13150 5ustar00ruosoruoso000000000000Search-GIN-0.08rels.t000644001750001750 263611521546521 14450 0ustar00ruosoruoso000000000000Search-GIN-0.08/t#!/usr/bin/perl use strict; use warnings; use Test::More 'no_plan'; use ok 'Search::GIN::Query::Class'; use ok 'Search::GIN::Extract::Class'; { package MyGIN; use Moose; with ( qw( Search::GIN::Core Search::GIN::Driver::Hash Search::GIN::SelfIDs ), ); sub extract_values { my ( $self, $obj, @args ) = @_; return $self->objects_to_ids(@{ $obj->friends }); } package MyGIN::Query::Friends; use Moose; with qw(Search::GIN::Query); has friends => ( isa => "ArrayRef[Person]", is => "ro", required => 1, ); sub extract_values { my ( $self, $gin ) = @_; return ( values => [ $gin->objects_to_ids(@{ $self->friends }) ], ); } sub consistent { 1 } package Person; use Moose; has friends => ( isa => "ArrayRef[Person]", is => "rw", default => sub { [] }, ); } my @people = map { Person->new } 0 .. 4; $people[0]->friends([ @people[1,2] ]); $people[1]->friends([ @people[0,2,4] ]); $people[2]->friends([ @people[0,1] ]); $people[4]->friends([ $people[1] ]); my $gin = MyGIN->new; $gin->insert(@people); my $q = MyGIN::Query::Friends->new( friends => [ $people[1] ] ); my $res = $gin->query( $q ); is_deeply( [ sort $res->all ], [ sort @people[0, 2, 4] ], "friends of person 1", ); core.t000644001750001750 707511521546521 14435 0ustar00ruosoruoso000000000000Search-GIN-0.08/t#!/usr/bin/perl use strict; use warnings; use Test::More 'no_plan'; use Test::TempDir; use Set::Object; { # this will be a default class, for now I'm keeping them separate package MyGIN; use Moose; # in memory index: #with qw( # Search::GIN::DelegateToIndexed # Search::GIN::Driver::Hash #); # on disk index: with ( qw( Search::GIN::Core Search::GIN::Driver::Hash Search::GIN::SelfIDs ), 'Search::GIN::DelegateToIndexed' => { -excludes => "objects_to_ids", # SelfIDs }, ); } { # you create the query objects, the GIN implementation uses them # consistently with the index package MyTagQuery; use Moose::Role; use MooseX::Types::Set::Object; with qw(Search::GIN::Query); has tags => ( isa => "Set::Object", is => "ro", coerce => 1, required => 1, ); sub extract_values { my $self = shift; return ( values => [ $self->tags->members ], ); } } { package MyTagQuery::Intersection; use Moose; with qw(MyTagQuery); sub consistent { my ( $self, $index, $item ) = @_; return $self->tags->subset($item->tags); } around extract_values => sub { my ( $next, $self, @args ) = @_; return ( method => "all", $self->$next(@args), ); }; __PACKAGE__->meta->make_immutable; } { package MyTagQuery::Union; use Moose; with qw(MyTagQuery); sub consistent { my ( $self, $index, $item ) = @_; return $self->tags->intersection($item->tags)->size >= 1; } __PACKAGE__->meta->make_immutable; } { # this is an indexable object package MyObject; use Moose; use overload '""' => sub { $_[0]->id }, fallback => 1; # is_deeply diagnosis use MooseX::Types::Set::Object; with qw(Search::GIN::Indexable); has id => ( isa => "Str", is => "ro", ); sub gin_id { shift->id } has tags => ( isa => "Set::Object", is => "ro", coerce => 1, default => sub { Set::Object->new }, ); sub gin_extract_values { my $self = shift; $self->tags->members; } __PACKAGE__->meta->make_immutable; } my $gin = MyGIN->new( manager => { home => temp_root, create => 1, }, file => "foo.idx", distinct => 1, ); my @objs = map { MyObject->new(%$_) } ( { id => "aaaaaaaaaaaaaaaa", tags => [ qw(foo bar baz donkey) ], }, { id => "aaaaaaaaaaaaaaab", tags => [ qw(bar gorch baz) ], }, { id => "aaaaaaaaaaaaaaac", tags => [ qw(zot urf donkey gorch) ], }, ); $gin->insert(@objs); { my @res = $gin->query( MyTagQuery::Intersection->new( tags => [qw(foo)] ) )->all; is_deeply( [ @res ], [ $objs[0] ] ); } { my @res = $gin->query( MyTagQuery::Union->new( tags => [qw(foo)] ) )->all; is_deeply( [ @res ], [ $objs[0] ] ); } { my @res = $gin->query( MyTagQuery::Intersection->new( tags => [qw(bar)] ) )->all; is_deeply( [ sort @res ], [ sort @objs[0, 1] ] ); } { my @res = $gin->query( MyTagQuery::Intersection->new( tags => [qw(gorch)] ) )->all; is_deeply( [ sort @res ], [ sort @objs[1, 2] ] ); } { my @res = $gin->query( MyTagQuery::Intersection->new( tags => [qw(bar gorch)] ) )->all; is_deeply( [ @res ], [ $objs[1] ] ); } { my @res = $gin->query( MyTagQuery::Union->new( tags => [qw(bar gorch)] ) )->all; is_deeply( [ sort @res ], [ sort @objs ] ); } META.yml000644001750001750 133111521546521 14313 0ustar00ruosoruoso000000000000Search-GIN-0.08--- abstract: 'Generalized Inverted Indexing' author: - 'Yuval Kogman ' build_requires: File::Find: 0 File::Temp: 0 MooseX::Types::Set::Object: 0 Test::More: 0 Test::TempDir: 0 ok: 0 overload: 0 configure_requires: ExtUtils::MakeMaker: 6.31 dynamic_config: 0 generated_by: 'Dist::Zilla version 4.200001, CPAN::Meta::Converter version 2.102400' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Search-GIN requires: Carp: 0 Data::Stream::Bulk::Util: 0 MRO::Compat: 0 Moose: 0.89 Moose::Role: 0 Scalar::Util: 0 Scope::Guard: 0 Set::Object: 0 Test::Deep::NoTest: 0 constant: 0 namespace::clean: 0 version: 0.08 MANIFEST000644001750001750 205211521546521 14174 0ustar00ruosoruoso000000000000Search-GIN-0.08Changes LICENSE MANIFEST META.yml Makefile.PL README dist.ini lib/Search/GIN.pm lib/Search/GIN/Callbacks.pm lib/Search/GIN/Core.pm lib/Search/GIN/DelegateToIndexed.pm lib/Search/GIN/Driver.pm lib/Search/GIN/Driver/Hash.pm lib/Search/GIN/Driver/Pack.pm lib/Search/GIN/Driver/Pack/Delim.pm lib/Search/GIN/Driver/Pack/IDs.pm lib/Search/GIN/Driver/Pack/Length.pm lib/Search/GIN/Driver/Pack/UUID.pm lib/Search/GIN/Driver/Pack/Values.pm lib/Search/GIN/Driver/TXN.pm lib/Search/GIN/Extract.pm lib/Search/GIN/Extract/Attributes.pm lib/Search/GIN/Extract/Callback.pm lib/Search/GIN/Extract/Class.pm lib/Search/GIN/Extract/Delegate.pm lib/Search/GIN/Extract/Multiplex.pm lib/Search/GIN/Indexable.pm lib/Search/GIN/Keys.pm lib/Search/GIN/Keys/Deep.pm lib/Search/GIN/Keys/Expand.pm lib/Search/GIN/Keys/Join.pm lib/Search/GIN/Query.pm lib/Search/GIN/Query/Attributes.pm lib/Search/GIN/Query/Class.pm lib/Search/GIN/Query/Manual.pm lib/Search/GIN/Query/Set.pm lib/Search/GIN/SelfIDs.pm t/00-compile.t t/attrs.t t/class.t t/core.t t/key_expansion.t t/release-pod-syntax.t t/rels.t class.t000644001750001750 306311521546521 14603 0ustar00ruosoruoso000000000000Search-GIN-0.08/t#!/usr/bin/perl use strict; use warnings; use Test::More 'no_plan'; use ok 'Search::GIN::Query::Class'; use ok 'Search::GIN::Extract::Class'; use ok 'Search::GIN::Query::Manual'; { package MyGIN; use Moose; with ( qw( Search::GIN::Core Search::GIN::Driver::Hash Search::GIN::SelfIDs Search::GIN::Extract::Delegate ), ); __PACKAGE__->meta->make_immutable; # this is an indexable object package Base; use Moose; __PACKAGE__->meta->make_immutable; package Foo; use Moose; extends qw(Base); __PACKAGE__->meta->make_immutable; package Bar; use Moose; extends qw(Base); __PACKAGE__->meta->make_immutable; package Gorch; use Moose; extends qw(Bar); __PACKAGE__->meta->make_immutable; } my $gin = MyGIN->new( extract => Search::GIN::Extract::Class->new ); my @objs = ( Base->new, Foo->new, Bar->new, Bar->new, Gorch->new, ); $gin->insert(@objs); { my @res = $gin->query( Search::GIN::Query::Class->new( class => "Base" ) )->all; is_deeply( [ sort @res ], [ sort @objs ] ); } { my @res = $gin->query( Search::GIN::Query::Class->new( class => "Foo" ) )->all; is_deeply( [ @res ], [ $objs[1] ] ); } { my @res = $gin->query( Search::GIN::Query::Class->new( class => "Bar" ) )->all; is_deeply( [ sort @res ], [ sort @objs[2, 3, 4] ] ); } { my @res = $gin->query( Search::GIN::Query::Manual->new( values => { class => "Foo" } ) )->all; is_deeply( [ @res ], [ $objs[1] ] ); } attrs.t000644001750001750 241511521546521 14633 0ustar00ruosoruoso000000000000Search-GIN-0.08/t#!/usr/bin/perl use strict; use warnings; use Test::More 'no_plan'; use ok 'Search::GIN::Query::Attributes'; use ok 'Search::GIN::Extract::Attributes'; { package MyGIN; use Moose; with ( qw( Search::GIN::Core Search::GIN::Driver::Hash Search::GIN::SelfIDs Search::GIN::Extract::Delegate ), ); __PACKAGE__->meta->make_immutable; package Foo; use Moose; has age => ( isa => "Int", is => "rw", ); has name => ( isa => "Str", is => "rw", ); __PACKAGE__->meta->make_immutable; } my $gin = MyGIN->new( extract => Search::GIN::Extract::Attributes->new ); my @objs = ( map { Foo->new($_) } { name => "stevan", age => 47 }, { name => "jon", age => 2 }, { name => "yuval", age => 2 } ); $gin->insert(@objs); { my @res = $gin->query( Search::GIN::Query::Attributes->new( attributes => {} ) )->all; is_deeply( \@res, [ ] ); } { my @res = $gin->query( Search::GIN::Query::Attributes->new( attributes => { name => "jon" } ) )->all; is_deeply( \@res, [ $objs[1] ] ); } { my @res = $gin->query( Search::GIN::Query::Attributes->new( attributes => { age => 2 } ) )->all; is_deeply( [ sort @res ], [ sort @objs[1,2] ] ); } Makefile.PL000644001750001750 264411521546521 15024 0ustar00ruosoruoso000000000000Search-GIN-0.08 use strict; use warnings; use ExtUtils::MakeMaker 6.31; my %WriteMakefileArgs = ( 'ABSTRACT' => 'Generalized Inverted Indexing', 'AUTHOR' => 'Yuval Kogman ', 'BUILD_REQUIRES' => { 'File::Find' => '0', 'File::Temp' => '0', 'MooseX::Types::Set::Object' => '0', 'Test::More' => '0', 'Test::TempDir' => '0', 'ok' => '0', 'overload' => '0' }, 'CONFIGURE_REQUIRES' => { 'ExtUtils::MakeMaker' => '6.31' }, 'DISTNAME' => 'Search-GIN', 'EXE_FILES' => [], 'LICENSE' => 'perl', 'NAME' => 'Search::GIN', 'PREREQ_PM' => { 'Carp' => '0', 'Data::Stream::Bulk::Util' => '0', 'MRO::Compat' => '0', 'Moose' => '0.89', 'Moose::Role' => '0', 'Scalar::Util' => '0', 'Scope::Guard' => '0', 'Set::Object' => '0', 'Test::Deep::NoTest' => '0', 'constant' => '0', 'namespace::clean' => '0' }, 'VERSION' => '0.08', 'test' => { 'TESTS' => 't/*.t' } ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) { my $br = delete $WriteMakefileArgs{BUILD_REQUIRES}; my $pp = $WriteMakefileArgs{PREREQ_PM}; for my $mod ( keys %$br ) { if ( exists $pp->{$mod} ) { $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod}; } else { $pp->{$mod} = $br->{$mod}; } } } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); 00-compile.t000644001750001750 204111521546521 15336 0ustar00ruosoruoso000000000000Search-GIN-0.08/t#!perl use strict; use warnings; use Test::More; use File::Find; use File::Temp qw{ tempdir }; my @modules; find( sub { return if $File::Find::name !~ /\.pm\z/; my $found = $File::Find::name; $found =~ s{^lib/}{}; $found =~ s{[/\\]}{::}g; $found =~ s/\.pm$//; # nothing to skip push @modules, $found; }, 'lib', ); my @scripts = glob "bin/*"; my $plan = scalar(@modules) + scalar(@scripts); $plan ? (plan tests => $plan) : (plan skip_all => "no tests to run"); { # fake home for cpan-testers # no fake requested ## local $ENV{HOME} = tempdir( CLEANUP => 1 ); like( qx{ $^X -Ilib -e "require $_; print '$_ ok'" }, qr/^\s*$_ ok/s, "$_ loaded ok" ) for sort @modules; SKIP: { eval "use Test::Script 1.05; 1;"; skip "Test::Script needed to test script compilation", scalar(@scripts) if $@; foreach my $file ( @scripts ) { my $script = $file; $script =~ s!.*/!!; script_compiles( $file, "$script script compiles" ); } } } key_expansion.t000644001750001750 241511521546521 16352 0ustar00ruosoruoso000000000000Search-GIN-0.08/t#!/usr/bin/perl use strict; use warnings; use Test::More 'no_plan'; use ok 'Search::GIN::Keys::Deep'; { package Foo; use Moose; with qw(Search::GIN::Keys::Deep); } my $foo = Foo->new; ok( $foo->does("Search::GIN::Keys::Join"), "does Join" ); ok( $foo->does("Search::GIN::Keys::Expand"), "does Expand" ); is_deeply( [ $foo->join_keys([qw(foo bar gorch)], [qw(baz zot)]) ], [ "foo:bar:gorch", "baz:zot" ], "join keys", ); is_deeply( [ $foo->expand_keys({ foo => [qw(bar gorch)] }) ], [ [qw(foo bar)], [qw(foo gorch)] ], "expand keys", ); is_deeply( [ $foo->process_keys(qw(la la la)) ], [ qw(la la la) ], "simple keys", ); is_deeply( [ $foo->process_keys({ foo => [ qw(bar gorch) ] }) ], [ qw(foo:bar foo:gorch) ], "prefixing", ); is_deeply( [ sort $foo->process_keys([ { a => [qw(b)], foo => [ { thingy => [qw(bar gorch)] }, "thing" ] } ]) ], [ sort qw(a:b foo:thingy:bar foo:thingy:gorch foo:thing) ], "complex", ); is_deeply( [ $foo->process_keys() ], [ ], "empty", ); is_deeply( [ $foo->process_keys( [ ] ) ], [ ], "empty", ); is_deeply( [ $foo->process_keys( { } ) ], [ ], "empty", ); is_deeply( [ $foo->process_keys( { foo => [] } ) ], [ ], "empty", ); Search000755001750001750 011521546521 14660 5ustar00ruosoruoso000000000000Search-GIN-0.08/libGIN.pm000644001750001750 210111521546521 15764 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Searchuse strict; use warnings; package Search::GIN; BEGIN { $Search::GIN::VERSION = '0.08'; } # ABSTRACT: Generalized Inverted Indexing 1; =pod =head1 NAME Search::GIN - Generalized Inverted Indexing =head1 VERSION version 0.08 =head1 DESCRIPTION Inverted Indexing is an indexing method that maps from content to location in storage. Generalized Inverted Indexing (GIN, for short) is an inverted indexing method in which the index is unaware of what data exactly is it indexing. L is primarily used by L for custom indexing. =head1 SEE ALSO =over 4 =item * L =item * L =back =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ GIN000755001750001750 011521546521 15275 5ustar00ruosoruoso000000000000Search-GIN-0.08/lib/SearchCore.pm000644001750001750 320011521546521 16655 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GINuse strict; use warnings; package Search::GIN::Core; BEGIN { $Search::GIN::Core::VERSION = '0.08'; } # ABSTRACT: Core of Search::GIN use Moose::Role; use Data::Stream::Bulk::Util qw(bulk unique); use namespace::clean -except => [qw(meta)]; with qw( Search::GIN::Driver Search::GIN::Extract ); requires qw( objects_to_ids ids_to_objects ); has distinct => ( isa => "Bool", is => "rw", default => 0, # FIXME what should the default be? ); sub query { my ( $self, $query, @args ) = @_; my %args = ( distinct => $self->distinct, @args, ); my @spec = $query->extract_values($self); my $ids = $self->fetch_entries(@spec); $ids = unique($ids) if $args{distinct}; return $ids->filter(sub { [ grep { $query->consistent($self, $_) } $self->ids_to_objects(@$_) ] }); } sub remove { my ( $self, @items ) = @_; my @ids = $self->objects_to_ids(@items); $self->remove_ids(@ids); } sub insert { my ( $self, @items ) = @_; my @ids = $self->objects_to_ids(@items); my @entries; foreach my $item ( @items ) { my @keys = $self->extract_values( $item, gin => $self ); my $id = shift @ids; $self->insert_entry( $id, @keys ); } } 1; =pod =head1 NAME Search::GIN::Core - Core of Search::GIN =head1 VERSION version 0.08 =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Keys.pm000644001750001750 113411521546521 16704 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GINuse strict; use warnings; package Search::GIN::Keys; BEGIN { $Search::GIN::Keys::VERSION = '0.08'; } # ABSTRACT: use Moose::Role; use namespace::clean -except => 'meta'; requires qw(process_keys); 1; =pod =head1 NAME Search::GIN::Keys - use Moose::Role; =head1 VERSION version 0.08 =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ release-pod-syntax.t000644001750001750 45011521546521 17177 0ustar00ruosoruoso000000000000Search-GIN-0.08/t#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Pod 1.41"; plan skip_all => "Test::Pod 1.41 required for testing POD" if $@; all_pod_files_ok(); Query.pm000644001750001750 127511521546521 17104 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GINuse strict; use warnings; package Search::GIN::Query; BEGIN { $Search::GIN::Query::VERSION = '0.08'; } # ABSTRACT: use Moose::Role; use namespace::clean -except => [qw(meta)]; requires qw( consistent extract_values ); 1; =pod =head1 NAME Search::GIN::Query - use Moose::Role; =head1 VERSION version 0.08 =head1 SYNOPSIS use Search::GIN::Query; =head1 DESCRIPTION =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Driver.pm000644001750001750 447411521546521 17236 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GINuse strict; use warnings; package Search::GIN::Driver; BEGIN { $Search::GIN::Driver::VERSION = '0.08'; } # ABSTRACT: use Moose::Role; use Data::Stream::Bulk::Util qw(bulk nil cat unique); use namespace::clean -except => [qw(meta)]; requires qw( insert_entry remove_ids fetch_entry ); sub fetch_entry_streams { my ( $self, %args ) = @_; map { $self->fetch_entry($_) } @{ $args{values} }; } sub fetch_entries { my ( $self, %args ) = @_; my $method = "fetch_entries_" . ( $args{method} || "any" ); $self->$method(%args); } sub fetch_entries_any { my ( $self, @args ) = @_; my @streams = $self->fetch_entry_streams(@args); return nil unless @streams; my $res = cat(splice @streams); # splice disposes of @streams ASAP, keeping memory utilization down if ( $res->loaded ) { # if all results are already ready, we can uniqify them to avoid # duplicate calls to ->consistent return unique($res); } else { return $res; } } sub fetch_entries_all { my ( $self, @args ) = @_; my @streams = $self->fetch_entry_streams(@args); return nil unless @streams; return $streams[0] if @streams == 1; foreach my $stream ( @streams ) { return cat(splice @streams) unless $stream->loaded; } # if we made it to here then we have a > 1 list of fully realized streams # we can compute the intersection of the IDs to avoid unnecessary calls to # ->consistent # If all streams are known to be sorted this method could be overridden to # use merge sorting my $last = shift @streams; my $n = scalar @streams; # compute intersection my %seen; foreach my $stream ( splice @streams ) { ++$seen{$_} for $stream->all; } no warnings 'uninitialized'; # == with undef return bulk( grep { $seen{$_} == $n } $last->all ); } 1; =pod =head1 NAME Search::GIN::Driver - use Moose::Role; =head1 VERSION version 0.08 =head1 SYNOPSIS use Search::GIN::Driver; =head1 DESCRIPTION =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ SelfIDs.pm000644001750001750 143511521546521 17266 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GINuse strict; use warnings; package Search::GIN::SelfIDs; BEGIN { $Search::GIN::SelfIDs::VERSION = '0.08'; } # ABSTRACT: use Moose::Role; use namespace::clean -except => [qw(meta)]; sub ids_to_objects { my ( $self, @ids ) = @_; return @ids; } sub objects_to_ids { my ( $self, @objs ) = @_; return @objs; } 1; =pod =head1 NAME Search::GIN::SelfIDs - use Moose::Role; =head1 VERSION version 0.08 =head1 SYNOPSIS use Search::GIN::SelfIDs; =head1 DESCRIPTION =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Extract.pm000644001750001750 114611521546521 17406 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GINuse strict; use warnings; package Search::GIN::Extract; BEGIN { $Search::GIN::Extract::VERSION = '0.08'; } # ABSTRACT: use Moose::Role; use namespace::clean -except => 'meta'; requires 'extract_values'; 1; =pod =head1 NAME Search::GIN::Extract - use Moose::Role; =head1 VERSION version 0.08 =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Indexable.pm000644001750001750 162011521546521 17664 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GINuse strict; use warnings; package Search::GIN::Indexable; BEGIN { $Search::GIN::Indexable::VERSION = '0.08'; } # ABSTRACT: use Moose::Role; requires 'gin_extract_values'; sub gin_id { my $self = shift; return $self; } sub gin_compare_values { my ( $self, $one, $two ) = @_; $one cmp $two; } sub gin_consistent { my ( $self, $index, $query, @args ) = @_; $query->gin_consistent($index, $self, @args); } 1; =pod =head1 NAME Search::GIN::Indexable - use Moose::Role; =head1 VERSION version 0.08 =head1 SYNOPSIS use Search::GIN::Indexable; =head1 DESCRIPTION =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Callbacks.pm000644001750001750 170211521546521 17651 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GINuse strict; use warnings; package Search::GIN::Callbacks; BEGIN { $Search::GIN::Callbacks::VERSION = '0.08'; } # ABSTRACT: Provide callbacks use Moose::Role; with qw(Search::GIN::Core); foreach my $cb ( qw(objects_to_ids extract_values extract_query compare_values consistent ids_to_objects) ) { has "${cb}_callback" => ( isa => "CodeRef", is => "rw", required => 1, ); eval "sub $cb { \$self->${cb}_callback->(@_) }"; } 1; =pod =head1 NAME Search::GIN::Callbacks - Provide callbacks =head1 VERSION version 0.08 =head1 DESCRIPTION This role provides a few callbacks for L. =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Keys000755001750001750 011521546521 16210 5ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GINJoin.pm000644001750001750 140211521546521 17601 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Keysuse strict; use warnings; package Search::GIN::Keys::Join; BEGIN { $Search::GIN::Keys::Join::VERSION = '0.08'; } # ABSTRACT: use Moose::Role; sub join_keys { my ( $self, @keys ) = @_; map { $self->join_key($_) } @keys; } sub join_key { my ( $self, @key ) = @_; no warnings 'uninitialized'; join ":", map { ref($_) ? @$_ : $_ } @key; } 1; =pod =head1 NAME Search::GIN::Keys::Join - use Moose::Role; =head1 VERSION version 0.08 =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Deep.pm000644001750001750 154111521546521 17563 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Keysuse strict; use warnings; package Search::GIN::Keys::Deep; BEGIN { $Search::GIN::Keys::Deep::VERSION = '0.08'; } # ABSTRACT: use Moose::Role; use namespace::clean -except => 'meta'; with qw( Search::GIN::Keys Search::GIN::Keys::Join Search::GIN::Keys::Expand ); sub process_keys { my ( $self, @keys ) = @_; $self->join_keys( $self->expand_keys(@keys) ); } 1; =pod =head1 NAME Search::GIN::Keys::Deep - use Moose::Role; =head1 VERSION version 0.08 =head1 SYNOPSIS with qw(Search::GIN::Keys::Deep); =head1 DESCRIPTION =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Query000755001750001750 011521546521 16402 5ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GINSet.pm000644001750001750 470611521546521 17641 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Queryuse strict; use warnings; package Search::GIN::Query::Set; BEGIN { $Search::GIN::Query::Set::VERSION = '0.08'; } # ABSTRACT: Create queries with set operations use Moose; use namespace::clean -except => 'meta'; with qw( Search::GIN::Query ); use constant 'method' => 'set'; use constant 'has_method' => 1; has operation => ( isa => 'Str', is => 'ro', default => 'UNION' ); has subqueries => ( isa => "ArrayRef", is => "ro", required => 1, ); has _processed => ( is => "ro", lazy_build => 1, ); sub _build__processed { my $self = shift; return [ map { { $_->extract_values, () } } @{$self->subqueries} ]; } sub extract_values { my $self = shift; return ( subqueries => $self->_processed, operation => $self->operation, method => 'set' ); } sub consistent { return 1; } __PACKAGE__->meta->make_immutable; 1; =pod =head1 NAME Search::GIN::Query::Set - Create queries with set operations =head1 VERSION version 0.08 =head1 SYNOPSIS # build a query like: # (type:pdf OR type:png) AND (name:Homer OR name:Bart) use Search::GIN::Query::Set; use Search::GIN::Query::Manual; my $query = Search::GIN::Query::Set->new( operation => 'INTERSECT', subqueries => [ Search::GIN::Query::Manual->new( values => { type => [qw(pdf png)] } ), Search::GIN::Query::Manual->new( values => { name => [qw(Homer Bart)] } ), ] ); =head1 DESCRIPTION Creates a manual GIN query that can be used to search using basic set theory, in order to build more complex queries. This query doesn't provide any specific search, it's just a set operator for subqueries. You can build complex queries by using other set queries as subqueries for a set query. =head1 METHODS/SUBROUTINES =head2 new Creates a new query. =head1 ATTRIBUTES =head2 subqueries The subqueries to process =head2 operation One of the basic set operators: "UNION", "INTERSECT" and "EXCEPT". The default is "UNION" =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Driver000755001750001750 011521546521 16530 5ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GINTXN.pm000644001750001750 443511521546521 17704 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Driveruse strict; use warnings; package Search::GIN::Driver::TXN; BEGIN { $Search::GIN::Driver::TXN::VERSION = '0.08'; } # ABSTRACT: use Moose::Role; use Scope::Guard; use Carp qw(croak); use namespace::clean -except => [qw(meta)]; with qw(Search::GIN::Driver); requires qw(txn_begin txn_commit txn_rollback); has current_transaction => ( isa => "Any", is => "rw", writer => "set_current_transaction", predicate => "has_current_transaction", clearer => "clear_current_transaction", ); sub txn_do { my ( $self, $coderef ) = ( shift, shift ); ref $coderef eq 'CODE' or croak '$coderef must be a CODE reference'; my ( $txn, $scope_guard ); if ( $self->has_current_transaction ) { my $prev = $self->current_transaction; $txn = $self->txn_begin($prev); $scope_guard = Scope::Guard->new(sub { $self->set_current_transaction($prev) }); } else { $txn = $self->txn_begin; $scope_guard = Scope::Guard->new(sub { $self->clear_current_transaction() }); } my @result; my $want_array = wantarray; my $err = do { local $@; eval { if ( $want_array ) { @result = $coderef->(@_); } elsif( defined $want_array ) { $result[0] = $coderef->(@_); } else { $coderef->(@_); } $self->txn_commit($txn); 1; }; $@ }; if ( !$err ) { return $want_array ? @result : $result[0]; } else { my $rollback_exception = do { local $@; eval { $self->txn_rollback($txn) }; $@; }; if ($rollback_exception) { croak "Transaction aborted: $err, rollback failed: $rollback_exception"; } else { die $err; } } } 1; =pod =head1 NAME Search::GIN::Driver::TXN - use Moose::Role; =head1 VERSION version 0.08 =head1 SYNOPSIS use Search::GIN::Driver::TXN; =head1 DESCRIPTION =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Expand.pm000644001750001750 276111521546521 20132 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Keysuse strict; use warnings; package Search::GIN::Keys::Expand; BEGIN { $Search::GIN::Keys::Expand::VERSION = '0.08'; } # ABSTRACT: use Moose::Role; use Carp qw(croak); use namespace::clean -except => 'meta'; sub expand_keys { my ( $self, @keys ) = @_; return map { $self->expand_key($_) } @keys; } sub expand_key { my ( $self, $value, %args ) = @_; return $self->expand_key_string($value) if not ref $value; my $method = "expand_keys_" . lc ref($value); croak("Don't know how to expand $value in key") if $method =~ /::/ or not $self->can($method); return $self->$method($value); } sub expand_key_prepend { my ( $self, $prefix, @keys ) = @_; return map { [ $prefix, @$_ ] } @keys; } sub expand_key_string { my ( $self, $str ) = @_; return [ $str ]; } sub expand_keys_array { my ( $self, $array ) = @_; return map { $self->expand_key($_) } @$array; } sub expand_keys_hash { my ( $self, $hash ) = @_; return map { $self->expand_key_prepend( $_, $self->expand_key($hash->{$_}) ); } keys %$hash; } 1; =pod =head1 NAME Search::GIN::Keys::Expand - use Moose::Role; =head1 VERSION version 0.08 =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Class.pm000644001750001750 621211521546521 20145 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Queryuse strict; use warnings; package Search::GIN::Query::Class; BEGIN { $Search::GIN::Query::Class::VERSION = '0.08'; } # ABSTRACT: Create class-based GIN queries use Moose; use Carp qw(croak); use namespace::clean -except => [qw(meta)]; with qw( Search::GIN::Query Search::GIN::Keys::Deep ); has no_check => ( isa => "Bool", is => "rw", default => 0, ); has class => ( isa => "ArrayRef | Str", is => "ro", predicate => "has_class", ); has does => ( isa => "ArrayRef | Str", is => "ro", predicate => "has_does", ); has blessed => ( isa => "Str", is => "ro", predicate => "has_blessed", ); sub BUILD { my $self = shift; croak "One of 'class', 'does', or 'blessed' is required" unless $self->has_class or $self->has_does or $self->has_blessed; } sub extract_values { my $self = shift; return ( method => "all", values => [ $self->process_keys({ ( $self->has_class ? ( class => $self->class ) : () ), ( $self->has_does ? ( does => $self->does ) : () ), ( $self->has_blessed ? ( blessed => $self->blessed ) : () ), }) ], ); } sub consistent { my ( $self, $index, $object ) = @_; return 1 if $self->no_check; if ( $self->has_blessed ) { return unless ref($object) eq $self->blessed; } if ( $self->has_class ) { return unless $self->check_object($object, isa => $self->class); } if ( $self->has_does ) { return unless $self->check_object($object, DOES => $self->does); } return 1; } sub check_object { my ( $self, $object, $check, $classes ) = @_; my @classes = ref($classes) ? @$classes : $classes; foreach my $class ( @classes ) { $object->$check($class) or return; } return 1; } __PACKAGE__->meta->make_immutable; 1; =pod =head1 NAME Search::GIN::Query::Class - Create class-based GIN queries =head1 VERSION version 0.08 =head1 SYNOPSIS use Search::GIN::Query::Class; my $query = Search::GIN::Query::Class->new( class => 'Person', ); =head1 DESCRIPTION Creates a class-based GIN query that can be used to search records in a storage. This is a ready-to-use query that uses class definitions (specifically C, C and C) to search through the storage. =head1 METHODS/SUBROUTINES =head2 new Creates a new query. =head1 ATTRIBUTES =head2 class The class of the object you want to find. my $query = Search::GIN::Query::Class->new( class => 'Person', ); =head2 does A role consumed by the object you want to find. my $query = Search::GIN::Query::Class->new( does => 'TheMonkey', ); =head2 blessed The name of the package that the object is blessed into. my $query = Search::GIN::Query::Class->new( blessed => 'Person', ); =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Hash.pm000644001750001750 372711521546521 20121 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Driveruse strict; use warnings; package Search::GIN::Driver::Hash; BEGIN { $Search::GIN::Driver::Hash::VERSION = '0.08'; } # ABSTRACT: use Moose::Role; use Set::Object; use Data::Stream::Bulk::Util qw(bulk); use Scalar::Util qw(refaddr); use namespace::clean -except => [qw(meta)]; with qw(Search::GIN::Driver); has values => ( isa => "HashRef", is => "ro", default => sub { {} }, ); has objects => ( isa => "HashRef", is => "ro", default => sub { {} }, ); sub clear { my $self = shift; %{ $self->values } = (); %{ $self->objects } = (); return; } sub fetch_entry { my ( $self, $key ) = @_; if ( my $set = $self->values->{$key} ) { return bulk($set->members); } else { return; } } sub remove_ids { my ( $self, @ids ) = @_; my $values = $self->values; my $objects = $self->objects; my @key_sets = grep { defined } delete @{$objects}{map { ref() ? refaddr($_) : $_ } @ids}; return unless @key_sets; my $keys = (shift @key_sets)->union(@key_sets); foreach my $key ( $keys->members ) { my $set = $values->{$key}; $set->remove(@ids); delete $values->{$key} if $set->size == 0; } } sub insert_entry { my ( $self, $id, @keys ) = @_; my $values = $self->values; my $objects = $self->objects; $self->remove_ids($id); my $set = $objects->{ref($id) ? refaddr($id) : $id} = Set::Object->new; $set->insert(@keys); foreach my $id_set (@{$values}{@keys}) { $id_set ||= Set::Object->new; $id_set->insert($id); } } 1; =pod =head1 NAME Search::GIN::Driver::Hash - use Moose::Role; =head1 VERSION version 0.08 =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Pack.pm000644001750001750 120611521546521 20102 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Driveruse strict; use warnings; package Search::GIN::Driver::Pack; BEGIN { $Search::GIN::Driver::Pack::VERSION = '0.08'; } # ABSTRACT: use Moose::Role; with qw( Search::GIN::Driver::Pack::Values Search::GIN::Driver::Pack::IDs ); 1; =pod =head1 NAME Search::GIN::Driver::Pack - use Moose::Role; =head1 VERSION version 0.08 =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Manual.pm000644001750001750 401711521546521 20316 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Queryuse strict; use warnings; package Search::GIN::Query::Manual; BEGIN { $Search::GIN::Query::Manual::VERSION = '0.08'; } # ABSTRACT: Create manual GIN queries use Moose; use namespace::clean -except => 'meta'; with qw( Search::GIN::Query Search::GIN::Keys::Deep ); has method => ( isa => "Str", is => "ro", predicate => "has_method", ); has values => ( isa => "Any", is => "ro", required => 1, ); has _processed => ( is => "ro", lazy_build => 1, ); has filter => ( isa => "CodeRef|Str", is => "ro", ); sub _build__processed { my $self = shift; return [ $self->process_keys( $self->values ) ]; } sub extract_values { my $self = shift; my $EMPTY = q{}; return ( values => $self->_processed, method => $self->has_method ? $self->method : $EMPTY, ); } sub consistent { my ( $self, $obj ) = @_; if ( my $filter = $self->filter ) { return $obj->$filter; } else { return 1; } } __PACKAGE__->meta->make_immutable; 1; =pod =head1 NAME Search::GIN::Query::Manual - Create manual GIN queries =head1 VERSION version 0.08 =head1 SYNOPSIS use Search::GIN::Query::Manual; my $query = Search::GIN::Query::Manual->new( values => { name => 'Homer', } ); =head1 DESCRIPTION Creates a manual GIN query that can be used to search records in a storage. Unlike the stock GIN queries (L, L), with this object you define your search manually, allowing you to create any search you want. =head1 METHODS/SUBROUTINES =head2 new Creates a new query. =head1 ATTRIBUTES =head2 values The keys and values to build the query for. =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Extract000755001750001750 011521546521 16707 5ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GINClass.pm000644001750001750 223311521546521 20451 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Extractuse strict; use warnings; package Search::GIN::Extract::Class; BEGIN { $Search::GIN::Extract::Class::VERSION = '0.08'; } # ABSTRACT: use Moose; use MRO::Compat; use namespace::clean -except => 'meta'; with qw( Search::GIN::Extract Search::GIN::Keys::Deep ); sub extract_values { my ( $self, $obj, @args ) = @_; my $class = ref $obj; my $isa = $class->mro::get_linear_isa(); my $meta = Class::MOP::get_metaclass_by_name($class); my @roles = $meta && $meta->can("calculate_all_roles") ? ( map { $_->name } $meta->calculate_all_roles ) : (); return $self->process_keys({ blessed => $class, class => $isa, does => \@roles, }); } 1; =pod =head1 NAME Search::GIN::Extract::Class - use Moose; =head1 VERSION version 0.08 =head1 SYNOPSIS use Search::GIN::Extract::Class; =head1 DESCRIPTION =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Pack000755001750001750 011521546521 17406 5ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/DriverIDs.pm000644001750001750 121311521546521 20557 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Driver/Packuse strict; use warnings; package Search::GIN::Driver::Pack::IDs; BEGIN { $Search::GIN::Driver::Pack::IDs::VERSION = '0.08'; } # ABSTRACT: use Moose::Role; use namespace::clean -except => 'meta'; requires qw(pack_ids unpack_ids); 1; =pod =head1 NAME Search::GIN::Driver::Pack::IDs - use Moose::Role; =head1 VERSION version 0.08 =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Attributes.pm000644001750001750 524611521546521 21234 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Queryuse strict; use warnings; package Search::GIN::Query::Attributes; BEGIN { $Search::GIN::Query::Attributes::VERSION = '0.08'; } # ABSTRACT: Create attributes-based GIN queries use Moose; use Carp qw(croak); use namespace::clean -except => [qw(meta)]; with qw( Search::GIN::Query Search::GIN::Keys::Deep ); has attributes => ( isa => "HashRef", is => "rw", required => 1, ); has compare => ( isa => "Str|CodeRef", is => "rw", default => "compare_naive", ); sub extract_values { my $self = shift; return ( method => "all", values => [ $self->process_keys($self->attributes) ], ); } sub consistent { my ( $self, $index, $obj ) = @_; my $class = ref $obj; my $meta = Class::MOP::get_metaclass_by_name($class); my $query = $self->attributes; my %got; foreach my $attr_name ( keys %$query ) { my $expected = $query->{$attr_name}; my $meta_attr = $meta->find_attribute_by_name($attr_name) || return; $got{$attr_name} = $meta_attr->get_value($obj); } my $cmp = $self->compare; return $self->$cmp( \%got, $query ); } sub compare_naive { my ( $self, $got, $exp ) = @_; return unless keys %$got == keys %$exp; foreach my $key ( keys %$exp ) { return unless overload::StrVal($got->{$key}) eq overload::StrVal($exp->{$key}); } return 1; } sub compare_test_deep { my ( $self, $got, $exp ) = @_; require Test::Deep::NoTest; Test::Deep::NoTest::eq_deeply($got, $exp); } # FIXME Data::Compare too __PACKAGE__->meta->make_immutable; 1; =pod =head1 NAME Search::GIN::Query::Attributes - Create attributes-based GIN queries =head1 VERSION version 0.08 =head1 SYNOPSIS use Search::GIN::Query::Attributes; my $query = Search::GIN::Query::Attributes->new( attributes => { name => 'Homer', }, ); =head1 DESCRIPTION Creates an attributes-based GIN query that can be used to search records in a storage. This is a ready-to-use query that uses an object's attributes to search through the storage. =head1 METHODS/SUBROUTINES =head2 new Creates a new query. =head1 ATTRIBUTES =head2 attributes Attributes of the object you want to find. my $query = Search::GIN::Query::Attributes->new( attributes => { name => 'Homer', city => 'Springfield', }, ); =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Delegate.pm000644001750001750 145011521546521 21116 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Extractuse strict; use warnings; package Search::GIN::Extract::Delegate; BEGIN { $Search::GIN::Extract::Delegate::VERSION = '0.08'; } # ABSTRACT: use Moose::Role; use namespace::clean -except => 'meta'; has extract => ( does => "Search::GIN::Extract", is => "ro", required => 1, # handles => "Search::GIN::Extract" ); sub extract_values { shift->extract->extract_values(@_) } 1; =pod =head1 NAME Search::GIN::Extract::Delegate - use Moose::Role; =head1 VERSION version 0.08 =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Callback.pm000644001750001750 177111521546521 21106 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Extractuse strict; use warnings; package Search::GIN::Extract::Callback; BEGIN { $Search::GIN::Extract::Callback::VERSION = '0.08'; } # ABSTRACT: use Moose; use namespace::clean -except => 'meta'; with qw( Search::GIN::Extract Search::GIN::Keys::Deep ); has extract => ( isa => "CodeRef|Str", is => "ro", required => 1, ); sub extract_values { my ( $self, $obj, @args ) = @_; my $extract = $self->extract; $self->process_keys( $obj->$extract($self, @args) ); } __PACKAGE__->meta->make_immutable; 1; =pod =head1 NAME Search::GIN::Extract::Callback - use Moose; =head1 VERSION version 0.08 =head1 SYNOPSIS use Search::GIN::Extract::Callback; =head1 DESCRIPTION =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ UUID.pm000644001750001750 163011521546521 20651 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Driver/Packuse strict; use warnings; package Search::GIN::Driver::Pack::UUID; BEGIN { $Search::GIN::Driver::Pack::UUID::VERSION = '0.08'; } # ABSTRACT: UUID key packing use Moose::Role; use namespace::clean -except => [qw(meta)]; with qw(Search::GIN::Driver); sub unpack_ids { my ( $self, $str ) = @_; unpack("(a16)*", $str); } sub pack_ids { my ( $self, @ids ) = @_; pack("(a16)*", @ids); # FIXME enforce size } 1; =pod =head1 NAME Search::GIN::Driver::Pack::UUID - UUID key packing =head1 VERSION version 0.08 =head1 SYNOPSIS use Search::GIN::Driver::PackUUID; =head1 DESCRIPTION =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ DelegateToIndexed.pm000644001750001750 202411521546521 21306 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GINuse strict; use warnings; package Search::GIN::DelegateToIndexed; BEGIN { $Search::GIN::DelegateToIndexed::VERSION = '0.08'; } # ABSTRACT: use Moose::Role; use namespace::clean -except => 'meta'; with qw(Search::GIN::Core); requires "ids_to_objects"; sub extract_values { my ( $self, $obj, @args ) = @_; $obj->gin_extract_values($self, @args); } sub compare_values { my ( $self, $obj, @args ) = @_; $obj->gin_compare_values($self, @args); } sub objects_to_ids { my ( $self, @objs ) = @_; map { $_->gin_id } @objs; } 1; =pod =head1 NAME Search::GIN::DelegateToIndexed - use Moose::Role; =head1 VERSION version 0.08 =head1 SYNOPSIS use Search::GIN::DelegateToIndexed; =head1 DESCRIPTION =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Multiplex.pm000644001750001750 174011521546521 21371 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Extractuse strict; use warnings; package Search::GIN::Extract::Multiplex; BEGIN { $Search::GIN::Extract::Multiplex::VERSION = '0.08'; } # ABSTRACT: use Moose; use namespace::clean -except => 'meta'; with qw(Search::GIN::Extract); has extractors => ( isa => "ArrayRef[Search::GIN::Extract]", is => "ro", required => 1, ); sub extract_values { my ( $self, $obj, @args ) = @_; return map { $_->extract_values($obj, @args) } @{ $self->extractors }; } __PACKAGE__->meta->make_immutable; 1; =pod =head1 NAME Search::GIN::Extract::Multiplex - use Moose; =head1 VERSION version 0.08 =head1 SYNOPSIS use Search::GIN::Extract::Multiplex; =head1 DESCRIPTION =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Delim.pm000644001750001750 142311521546521 21135 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Driver/Packuse strict; use warnings; package Search::GIN::Driver::Pack::Delim; BEGIN { $Search::GIN::Driver::Pack::Delim::VERSION = '0.08'; } # ABSTRACT: use Moose::Role; use namespace::clean -except => [qw(meta)]; sub pack_delim { my ( $self, @strings ) = @_; join("\0", @strings ); } sub unpack_delim { my ( $self, $string ) = @_; split("\0", $string ); } 1; =pod =head1 NAME Search::GIN::Driver::Pack::Delim - use Moose::Role; =head1 VERSION version 0.08 =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Attributes.pm000644001750001750 302011521546521 21525 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Extractuse strict; use warnings; package Search::GIN::Extract::Attributes; BEGIN { $Search::GIN::Extract::Attributes::VERSION = '0.08'; } # ABSTRACT: use Moose; use namespace::clean -except => 'meta'; with qw( Search::GIN::Extract Search::GIN::Keys::Deep ); has attributes => ( isa => "ArrayRef[Str]", is => "rw", predicate => "has_attributes", ); sub extract_values { my ( $self, $obj, @args ) = @_; my @meta_attrs = $self->get_meta_attrs($obj, @args); return $self->process_keys({ map { my $val = $_->get_value($obj); $_->name => (defined($val) ? $val : undef); } @meta_attrs }); } sub get_meta_attrs { my ( $self, $obj, @args ) = @_; my $class = ref $obj; my $meta = Class::MOP::get_metaclass_by_name($class); if ( $self->has_attributes ) { return grep { defined } map { $meta->find_attribute_by_name($_) } @{ $self->attributes }; } else { return $meta->get_all_attributes; } } 1; =pod =head1 NAME Search::GIN::Extract::Attributes - use Moose; =head1 VERSION version 0.08 =head1 SYNOPSIS use Search::GIN::Extract::Attributes; =head1 DESCRIPTION =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Values.pm000644001750001750 123211521546521 21340 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Driver/Packuse strict; use warnings; package Search::GIN::Driver::Pack::Values; BEGIN { $Search::GIN::Driver::Pack::Values::VERSION = '0.08'; } # ABSTRACT: use Moose::Role; use namespace::clean -except => 'meta'; requires qw(pack_values unpack_values); 1; =pod =head1 NAME Search::GIN::Driver::Pack::Values - use Moose::Role; =head1 VERSION version 0.08 =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ Length.pm000644001750001750 155611521546521 21333 0ustar00ruosoruoso000000000000Search-GIN-0.08/lib/Search/GIN/Driver/Packuse strict; use warnings; package Search::GIN::Driver::Pack::Length; BEGIN { $Search::GIN::Driver::Pack::Length::VERSION = '0.08'; } # ABSTRACT: use Moose::Role; use namespace::clean -except => [qw(meta)]; sub pack_length { my ( $self, @strings ) = @_; pack("(n/a*)*", @strings); } sub unpack_length { my ( $self, $string ) = @_; unpack("(n/a*)*", $string); } 1; =pod =head1 NAME Search::GIN::Driver::Pack::Length - use Moose::Role; =head1 VERSION version 0.08 =head1 SYNOPSIS use Search::GIN::Driver::PackLength; =head1 DESCRIPTION =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__