.\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.14) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "TM::Index 3pm" .TH TM::Index 3pm "2010-07-18" "perl v5.10.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" TM::Index \- Topic Maps, generic indexing support .SS "\s-1SYNOPSIS\s0" .IX Subsection "SYNOPSIS" .Vb 2 \& # this package only provides generic functionality \& # see TM::Index::* for specific indices .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" One performance bottleneck when using the \s-1TM\s0 package or any of its subclasses are the low-level query functions \f(CW\*(C`match_forall\*(C'\fR and \f(CW\*(C`match_exists\*(C'\fR. They are looking for assertions of a certain nature. Almost all high-level functions, and certainly \s-1TM::TS\s0 (TempleScript) use these. .PP This package (actually more its subclasses) provides an indexing mechanism to speed up the \&\f(CW\*(C`match_*\*(C'\fR functions by caching some results in a very specific way. When an index is attached to a map, then it will intercept all queries going to these functions. .SS "Open vs. Closed Index" .IX Subsection "Open vs. Closed Index" There are two options: .ie n .IP """open"":" 4 .el .IP "\f(CWopen\fR:" 4 .IX Item "open:" The default is to keep the index \fIlazy\fR. In this mode the index is empty at the start and it will learn more and more on its own. In this sense, the index lives under an \fIopen world assumption\fR (hence the name), as the absence of information does not mean that there is no result. .ie n .IP """closed"":" 4 .el .IP "\f(CWclosed\fR:" 4 .IX Item "closed:" A \fIclosed world\fR index has to be populated to be useful. If a query is launched and the result is stored in the index, then it will be used, like for an open index. If no result in the index is found for a query, the empty result will be assumed. .SS "Map Attachment" .IX Subsection "Map Attachment" To activate an index, you have to attach it to a map. This is done at constructor time. .PP It is possible (not sure how useful it is) to have one particular index to be attached to several different maps. It is also possible to have several TM::Index::* indices attached to one map. They are then consulted in the sequence of attachments: .PP .Vb 2 \& my $idx1 = new TM::Index::Whatever ($tm); \& my $idx2 = new TM::Index::Whatever2 ($tm); .Ve .PP If \f(CW$idx1\fR cannot help, then \f(CW$idx2\fR is tried. .PP \&\fB\s-1NOTE\s0\fR: If you use \fIseveral\fR indices for the \fIsame\fR map, then all of them \fB\s-1MUST\s0\fR be declared as being \fIopen\fR. If one of them were closed, it would give a definite answer and would make the machinery not look further into other indices. This implies that you will have to populate your index explicitly. .SS "Hash Technology" .IX Subsection "Hash Technology" The default implementation uses an in-memory hash, no further fancy. Optionally, you can provide your own hash object, also one which is \fItied\fR to an \s-1DBM\s0 file, etc. .SH "INTERFACE" .IX Header "INTERFACE" .SS "Constructor" .IX Subsection "Constructor" The only mandatory parameter for the constructor is the map for which this index should apply. The map must be an instance of \s-1TM\s0 or any of its subclasses, otherwise an exception is the consequence. .PP Optional parameters are .ie n .IP """closed"" (default: 0)" 4 .el .IP "\f(CWclosed\fR (default: \f(CW0\fR)" 4 .IX Item "closed (default: 0)" This controls whether the index is operating under closed or open world assumptions. If it is specified to be \fIclosed\fR the method \f(CW\*(C`populate\*(C'\fR will be triggered at the end of the constructor. .ie n .IP """cache"" (default: ""{}"")" 4 .el .IP "\f(CWcache\fR (default: \f(CW{}\fR)" 4 .IX Item "cache (default: {})" You optionally can pass in your own \s-1HASH\s0 reference. .PP Example: .PP .Vb 1 \& my $idx = new TM::Index::Match ($tm) .Ve .PP \&\fB\s-1NOTE\s0\fR: When the index object goes out of scope, the destructor will make the index detach itself from the map. Unfortunately, the exact moment when this happens is somehow undefined in Perl, so it is better to do this manually at the end. .PP Example: .PP .Vb 4 \& { \& my $idx2 = new TM::Index::Match ($tm, closed => 1); \& .... \& } # destructor called and index detaches automatically, but only in theory \& \& { \& my $idx2 = new TM::Index::Match ($tm, closed => 1); \& .... \& $idx2\->detach; # better do things yourself \& } .Ve .SS "Methods" .IX Subsection "Methods" .IP "\fBattach\fR" 4 .IX Item "attach" \&\fI\f(CI$idx\fI\fR\->attach .Sp This method attaches the index to the configured map. Normally you will not call this as the attachment is implicitly done at constructor time. The index itself is not destroyed; it is just deactivated to be used together with the map. .Sp @@ optional \s-1TM\s0 .IP "\fBdetach\fR" 4 .IX Item "detach" \&\fI\f(CI$idx\fI\fR\->detach .Sp Makes the index detach safely from the map. The map is not harmed in this process. .IP "\fBdiscard\fR" 4 .IX Item "discard" \&\fI\f(CI$idx\fI\fR\->discard .Sp This throws away the index content. .IP "\fBis_cached\fR" 4 .IX Item "is_cached" \&\fI\f(CI$bool\fI\fR = \fI\f(CI$idx\fI\fR\->is_cached (\fI\f(CI$key\fI\fR) .Sp Given a key parameter, the cache is consulted whether it already has a result for this key. If the index is \fIclosed\fR it will return the empty list (reference), if it has no result, otherwise it will give back \f(CW\*(C`undef\*(C'\fR. .IP "\fBdo_cache\fR" 4 .IX Item "do_cache" \&\fI\f(CI$idx\fI\fR\->do_cache (\fI\f(CI$key\fI\fR, \fI\f(CI$list_ref\fI\fR) .Sp Given a key and a list reference, it will store the list reference there in the cache. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\s-1TM\s0, TM::Index::Characteristics, TM::Index::Match .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright 20(0[6]|10) by Robert Barta, .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.