--- lib/Search/TokyoDystopia.pm 2008/08/18 18:55:38 23 +++ lib/Search/TokyoDystopia.pm 2009/02/14 17:54:28 41 @@ -6,7 +6,7 @@ require Exporter; require XSLoader; use base qw(Exporter); -our $VERSION = '0.00'; +our $VERSION = '0.01'; our $debug = 0; XSLoader::load('Search::TokyoDystopia', $VERSION); @@ -46,15 +46,119 @@ tcidbiternext tcidbsync tcidboptimize +tcidbvanish +tcidbcopy +tcidbpath +tcidbrnum +tcidbfsiz + +tdversion +tcqdberrmsg +tcqdbnew +tcqdbdel +tcqdbnew +tcqdbecode +tcqdbtune +QDBTLARGE +QDBTDEFLATE +QDBTTCBS +tcqdbsetcache +tcqdbsetfwmmax +tcqdbopen +QDBOREADER +QDBOWRITER +QDBOCREAT +QDBOTRUNC +QDBONOLCK +QDBOLCKNB +tcqdbclose +tcqdbput +tcqdbout +tcqdbget +tcqdbsearch +tcqdbsearch2 +QDBSSUBSTR +QDBSPREFIX +QDBSSUFFIX +QDBSFULL +QDBSTOKEN +QDBSTOKPRE +QDBSTOKSUF +tcqdbiterinit +tcqdbiternext +tcqdbsync +tcqdboptimize +tcqdbvanish +tcqdbcopy +tcqdbpath +tcqdbtnum +tcqdbfsiz + +tcjdberrmsg +tcjdbnew +tcjdbdel +tcjdbnew +tcjdbecode +tcjdbtune +JDBTLARGE +JDBTDEFLATE +JDBTTCBS +tcjdbsetcache +tcjdbsetfwmmax +tcjdbopen +JDBOREADER +JDBOWRITER +JDBOCREAT +JDBOTRUNC +JDBONOLCK +JDBOLCKNB +tcjdbclose +tcjdbput +tcjdbput2 +tcjdbout +tcjdbget +tcjdbget2 +tcjdbsearch +tcjdbsearch2 +JDBSSUBSTR +JDBSPREFIX +JDBSSUFFIX +JDBSFULL +tcjdbiterinit +tcjdbiternext +tcjdbsync +tcjdboptimize +tcjdbvanish +tcjdbcopy +tcjdbpath +tcjdbrnum +tcjdbfsiz ); =head1 NAME Search::TokyoDystopia - XS bindings for Tokyo Dystopia -=head1 EXPORTS +=head1 Core API If you don't prevent it, it will export all kind of stuff into your namespace to cut down on typing. +void +tcqdbget(qdb, id) + void * qdb + int id +PREINIT: + char *vbuf; +PPCODE: + vbuf = tcqdbget(qdb, id); + if(vbuf){ + XPUSHs(sv_2mortal(newSVpvn(vbuf, strlen(vbuf)))); + tcfree(vbuf); + } else { + XPUSHs((SV *)&PL_sv_undef); + } + XSRETURN(1); + + =head2 tcidberrmsg @@ -90,7 +194,7 @@ =head2 tcidbsetfwmmax - my $success = tcidbsetfwmmax( $idb, $fwnum ); + my $success = tcidbsetfwmmax( $idb, $fwmax ); =head2 tcidbopen @@ -159,6 +263,253 @@ my $success = tcidboptimize( $idb ); +=head2 tcidbvanish + + my $success = tcidbvanish( $idb ); + +=head2 tcidbcopy + + my $success = tcidbcopy( $idb, '/path/of/copy' ); + +=head2 tcidbpath + + my $path = tcidbpath( $idb ); + +=head2 tcidbrnum + + my $number_of_records = tcidbrnum( $idb ); + +=head2 tcidbfsiz + + my $file_size = tcidbfsiz( $idb ); + +=cut + + +=head1 Q-gram API + +=head2 tcqdberrmsg + + my $message = tcqdberrmsg( $ecode ); + +=head2 tcqdbnew + + my $qdb = tcqdbnew; + +=head2 tcqdbdel + + tcqdbdel( $qdb ); + +=head2 tcqdbecode + + my $ecode = tcqdbecode( $qdb ); + +=head2 tcqdbtune + + my $success = tcqdbtune( $qdb, $etnum, QDBTLARGE | QDBTDEFLATE ); + +=cut + +use constant { + QDBTLARGE => 1 << 0, + QDBTDEFLATE => 1 << 1, + QDBTTCBS => 1 << 2, +}; + +=head2 tcqdbsetcache + + my $success = tcqdbsetcache( $qdb, $icsiz, $lcnum ); + +=head2 tcqdbsetfwmmax + + my $success = tcqdbsetfwmmax( $qdb, $fwmax ); + +=head2 tcqdbopen + + my $success = tcqdbopen( $qdb, 'casket', QDBOWRITER | QDBOCREAT ); + +=cut + +use constant { + QDBOREADER => 1 << 0, + QDBOWRITER => 1 << 1, + QDBOCREAT => 1 << 2, + QDBOTRUNC => 1 << 3, + QDBONOLCK => 1 << 4, + QDBOLCKNB => 1 << 5, +}; + +=head2 tcqdbclose + + my $success = tcqdbclose( $qdb ); + +=head2 tcqdbput + + my $success = tcqdbput( $qdb, $id, $text ); + +=head2 tcqdbout + + my $success = tcqdbout( $qdb, $id ); + +=head2 tcqdbsearch + + my $ids = tcqdbsearch( $qdb, $word, QDBSSUBSTR ); + +=cut + +use constant { + QDBSSUBSTR => 0, # substring matching + QDBSPREFIX => 1, # prefix matching + QDBSUFFIX => 2, # suffix matching + QDBFULL => 3, # full matching + QDBTOKEN => 4, # token matching + QDBTOKPRE => 5, # token prefix matching + QDBTOKSUF => 6, # token suffix matching +}; + +=head2 tcqdbsync + + my $success = tcqdbsync( $qdb ); + +=head2 tcqdboptimize + + my $success = tcqdboptimize( $qdb ); + +=head2 tcqdbvanish + + my $success = tcqdbvanish( $qdb ); + +=head2 tcqdbcopy + + my $success = tcqdbcopy( $qdb, '/path/of/copy' ); + +=head2 tcqdbpath + + my $path = tcqdbpath( $qdb ); + +=head2 tcqdbtnum + + my $number_of_records = tcqdbtnum( $qdb ); + +=head2 tcqdbfsiz + + my $file_size = tcqdbtsiz( $qdb ); + + +=head1 Simple API + +=head2 tcjdberrmsg + + my $message = tcjdberrmsg( $ecode ); + +=head2 tcjdbnew + + my $jdb = tcjdbnew; + +=head2 tcjdbdel + + tcjdbdel( $jdb ); + +=head2 tcjdbecode + + my $ecode = tcjdbecode( $jdb ); + +=head2 tcjdbtune + + my $success = tcjdbtune( $jdb, $ernum, $etnum, $iusiz, JDBTLARGE | JDBTDEFLATE ); + +=cut + +use constant { + JDBTLARGE => 1 << 0, + JDBTDEFLATE => 1 << 1, + JDBTTCBS => 1 << 2, +}; + +=head2 tcjdbsetcache + + my $success = tcjdbsetcache( $jdb, $icsiz, $lcnum ); + +=head2 tcjdbsetfwmmax + + my $success = tcjdbsetfwmmax( $jdb, $fwmax ); + +=head2 tcjdbopen + + my $success = tcjdbopen( $jdb, 'casket', JDBOWRITER | JDBOCREAT ); + +=cut + +use constant { + JDBOREADER => 1 << 0, + JDBOWRITER => 1 << 1, + JDBOCREAT => 1 << 2, + JDBOTRUNC => 1 << 3, + JDBONOLCK => 1 << 4, + JDBOLCKNB => 1 << 5, +}; + +=head2 tcjdbclose + + my $success = tcjdbclose( $jdb ); + +=head2 tcjdbput + + my $success = tcjdbput( $jdb, $id, $text ); + +=head2 tcjdbput2 + + my $success = tcjdbput2( $jdb, $id, $text ); + +=head2 tcjdbout + + my $success = tcjdbout( $jdb, $id ); + +=head2 tcjdbsearch + + my $ids = tcjdbsearch( $jdb, $word, JDBSSUBSTR ); + +=head2 tcjdbsearch2 + + my $ids = tcjdbsearch2( $jdb, $word ); + +=cut + +use constant { + JDBSSUBSTR => 0, # substring matching + JDBSPREFIX => 1, # prefix matching + JDBSSUFFIX => 2, # suffix matching + JDBSFULL => 3, # full matching +}; + +=head2 tcjdbsync + + my $success = tcjdbsync( $jdb ); + +=head2 tcjdboptimize + + my $success = tcjdboptimize( $jdb ); + +=head2 tcjdbvanish + + my $success = tcjdbvanish( $jdb ); + +=head2 tcjdbcopy + + my $success = tcjdbcopy( $jdb, '/path/of/copy' ); + +=head2 tcjdbpath + + my $path = tcjdbpath( $jdb ); + +=head2 tcjdbrnum + + my $number_of_records = tcjdbrnum( $jdb ); + +=head2 tcjdbfsiz + + my $file_size = tcjdbtsiz( $jdb ); + =cut =head1 KNOWN BUGS