]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/SearchMsg.pm
store less data in the Xapian document
[public-inbox.git] / lib / PublicInbox / SearchMsg.pm
index f5510b8e6b6f79c657fb3938460f9e4100e89f67..ab971e002d8a52846eaed9e83dacbab474e4f2d2 100644 (file)
@@ -9,13 +9,12 @@ use warnings;
 use PublicInbox::MID qw/mid_clean mid_mime/;
 use PublicInbox::Address;
 use PublicInbox::MsgTime qw(msg_timestamp msg_datestamp);
+use Time::Local qw(timegm);
 
 sub new {
        my ($class, $mime) = @_;
        my $doc = Search::Xapian::Document->new;
-       $doc->add_boolean_term('T' . 'mail');
-
-       bless { type => 'mail', doc => $doc, mime => $mime }, $class;
+       bless { doc => $doc, mime => $mime }, $class;
 }
 
 sub wrap {
@@ -46,9 +45,8 @@ sub to_doc_data {
                $self->cc,
                $oid,
                $mid0,
-               $self->ds,
-               $self->{bytes},
-               $self->{lines}
+               $self->{bytes} || '',
+               $self->{lines} || ''
        );
 }
 
@@ -66,7 +64,6 @@ sub load_from_data ($$) {
 
                $self->{blob},
                $self->{mid},
-               $self->{ds},
                $self->{bytes},
                $self->{lines}
        ) = split(/\n/, $_[1]);
@@ -76,7 +73,10 @@ sub load_expand {
        my ($self) = @_;
        my $doc = $self->{doc};
        my $data = $doc->get_data or return;
-       $self->{ts} = get_val($doc, &PublicInbox::Search::TS);
+       $self->{ts} = get_val($doc, PublicInbox::Search::TS());
+       my $dt = get_val($doc, PublicInbox::Search::DT());
+       my ($yyyy, $mon, $dd, $hh, $mm, $ss) = unpack('A4A2A2A2A2A2', $dt);
+       $self->{ds} = timegm($ss, $mm, $hh, $dd, $mon - 1, $yyyy);
        utf8::decode($data);
        load_from_data($self, $data);
        $self;
@@ -91,7 +91,6 @@ sub load_doc {
 # :bytes and :lines metadata in RFC 3977
 sub bytes ($) { $_[0]->{bytes} }
 sub lines ($) { $_[0]->{lines} }
-sub num ($) { $_[0]->{num} ||= _get_term_val($_[0], 'XNUM', qr/\AXNUM/) }
 
 sub __hdr ($$) {
        my ($self, $field) = @_;
@@ -187,26 +186,4 @@ sub mid ($;$) {
 
 sub _extract_mid { mid_clean(mid_mime($_[0]->{mime})) }
 
-sub thread_id {
-       my ($self) = @_;
-       my $tid = $self->{thread};
-       return $tid if defined $tid;
-       $self->{thread} = _get_term_val($self, 'G', qr/\AG/); # *G*roup
-}
-
-# XXX: consider removing this, we can phrase match subject
-sub path {
-       my ($self) = @_;
-       my $path = $self->{path};
-       return $path if defined $path;
-       $self->{path} = _get_term_val($self, 'XPATH', qr/\AXPATH/); # path
-}
-
-sub type {
-       my ($self) = @_;
-       my $type = $self->{type};
-       return $type if defined $type;
-       $self->{type} = _get_term_val($self, 'T', qr/\AT/);
-}
-
 1;