TM::Index::Characteristics - Topic Maps, Indexing support (match layer)


TM documentation Contained in the TM distribution.

Index


Code Index:

NAME

Top

TM::Index::Characteristics - Topic Maps, Indexing support (match layer)

SYNOPSIS

Top

    # somehow get a map (any subclass of TM will do)
    my $tm = ... 

    # one option: create a lazy index which learns as you go
    use TM::Index::Characteristics;
    my $idx = new TM::Index::Characteristics ($tm);

    # for most operations which involve match_forall to be called
    # for querying characteristics should be much faster

DESCRIPTION

Top

This index can be attached to a map if querying it for characteristics (here names and occurrences) is intensive.

The package inherits most of its functionality from TM::Index.

INTERFACE

Top

Constructor

The constructor/destructor is inherited from TM::Index.

Methods

SEE ALSO

Top

TM, TM::Index

COPYRIGHT AND LICENSE

Top


TM documentation Contained in the TM distribution.
package TM::Index::Characteristics;

use strict;
use warnings;
use Data::Dumper;

use TM;
use base qw(TM::Index);

sub populate {
    my $self  = shift;
    my $map   = $self->{map};
    my $cache = $self->{cache};

    foreach my $a (values %{ $map->{assertions} }) {
	next if $a->[TM->KIND] == TM->ASSOC;                                     # these are not interesting here
	my $mid = $a->[TM->PLAYERS]->[0];                                        # the thing is ALWAYS here
	push @{ $cache->{"char.topic:1.$mid"} }, $a->[TM->LID];
    }
}

our $VERSION = 0.1;
our $REVISION = '$Id: Characteristics.pm,v 1.1 2006/12/01 08:01:00 rho Exp $';

1;

__END__