about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-12-21 07:51:21 +0000
committerEric Wong <e@80x24.org>2020-12-21 21:51:58 +0000
commit427b4fbbc68e4e03b20d66062dd47a0213e18390 (patch)
treefe5bbd9aa2fe7b51852cd6b4733b53ce2a6118b9 /lib
parent3e9888ed30b7fe092b03789d19a8020d4bc0fb39 (diff)
downloadpublic-inbox-427b4fbbc68e4e03b20d66062dd47a0213e18390.tar.gz
Values can be strings in Xapian, although we currently use
integer values exclusively.  Give the wrapper a more appropriate
name in case we start using string columns.

For future-proofing, we'll now return `undef' on missing columns
and coerce the return value to an IV (integer value) to save
memory, as sortable_unserialise returns a PV (pointer value)
scalar despite it existing to support numeric values.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/SearchIdx.pm9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index b731f698..cf2c2c55 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -501,17 +501,18 @@ sub remove_eidx_info {
         $self->{xdb}->replace_document($docid, $doc);
 }
 
-sub get_val ($$) {
+sub int_val ($$) {
         my ($doc, $col) = @_;
-        sortable_unserialise($doc->get_value($col));
+        my $val = $doc->get_value($col) or return; # undefined is '' in Xapian
+        sortable_unserialise($val) + 0; # PV => IV conversion
 }
 
 sub smsg_from_doc ($) {
         my ($doc) = @_;
         my $data = $doc->get_data or return;
         my $smsg = bless {}, 'PublicInbox::Smsg';
-        $smsg->{ts} = get_val($doc, PublicInbox::Search::TS());
-        my $dt = get_val($doc, PublicInbox::Search::DT());
+        $smsg->{ts} = int_val($doc, PublicInbox::Search::TS());
+        my $dt = int_val($doc, PublicInbox::Search::DT());
         my ($yyyy, $mon, $dd, $hh, $mm, $ss) = unpack('A4A2A2A2A2A2', $dt);
         $smsg->{ds} = timegm($ss, $mm, $hh, $dd, $mon - 1, $yyyy);
         $smsg->load_from_data($data);