Apache-Wyrd
view release on metacpan or search on metacpan
Wyrd/Services/MySQLIndex.pm view on Meta::CPAN
Arrayref of which attributes to treat as maps. Any attribute that is a
map must also be included in the list of attributes.
=back
=cut
sub new {
my ($class, $init) = @_;
die ('Must provide a database handle') unless($$init{'dbh'});
$$init{'debug'} = 0 unless exists($$init{'debug'});
$$init{'strict'} = 1 unless exists($$init{'strict'});
$$init{'quiet'} = 0 unless exists($$init{'quiet'});
$$init{'transactions'} = 0 unless exists($$init{'transactions'});
$$init{'transactions_wanted'} = $$init{'transactions'};
$$init{'wordmin'} = 3 unless exists($$init{'wordmin'});
my @attributes = qw(name timestamp digest data wordcount title keywords description);
my @check_reserved = ();
foreach my $reserved (@attributes, 'id', 'score', 'db_metadata', 'blob') {
push @check_reserved, $reserved if (grep {$reserved eq $_} @{$$init{'attributes'}});
push @check_reserved, $reserved if ($$init{'reversemaps'} and $reserved =~ /^_rev/);
}
my $s = '';
$s = 's' if (@check_reserved > 1);
die ("Reserved/Illegal attribute$s specified. Use different name$s: " . join(', ', @check_reserved)) if (@check_reserved);
my @maps = qw(data);
my (%attributes, %maps) = ();
@maps = (@maps, @{$init->{'maps'}}) if (ref($init->{'maps'}) eq 'ARRAY');
foreach my $map (@maps) {
$maps{$map} = 1;
}
@attributes = (@attributes, @{$init->{'attributes'}}) if (ref($init->{'attributes'}) eq 'ARRAY');
my $attr_index = 0;
my @tables = ('_wyrd_index', (map {"_wyrd_index_$_"} @maps));
my @attribute_map = @attributes;
my $data = {
dbh => $$init{'dbh'},
status => undef,
debug => $$init{'debug'},
strict => $$init{'strict'},
transactions => $$init{'transactions'},
transactions_wanted => $$init{'transactions_wanted'},
quiet => $$init{'quiet'},
error => [],
attribute_list => \@attributes,
maps => \%maps,
map_list => \@maps,
tables => \@tables,
extended => ((scalar(@attributes) > 8) ? 8 : 0),
wordmin => $$init{'wordmin'}
};
bless $data, $class;
return $data;
}
sub obsolete {
my @caller = caller(1);
my @source = caller(2);
die "$source[3]() called obsolete method $caller[3]()";
}
sub dbh {
my ($self) = @_;
return $self->{'dbh'};
}
sub db {
my ($self) = @_;
return $self->{'db'};
}
sub db_big {
&obsolete;
}
sub env {
&obsolete;
}
sub extended {
my ($self) = @_;
return $self->{'extended'};
}
sub attributes {
&obsolete;
}
sub maps {
my ($self) = @_;
return $self->{'maps'};
}
sub attribute_list {
my ($self) = @_;
return $self->{'attribute_list'};
}
sub attribute_map {
&obsolete;
}
sub map_list {
my ($self) = @_;
return $self->{'map_list'};
}
sub status {
my ($self) = @_;
return $self->{'status'};
}
sub debug {
my ($self) = @_;
return $self->{'debug'};
}
sub strict {
( run in 0.526 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )