From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 72DEC6DE009B for ; Thu, 18 May 2017 15:25:46 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.164 X-Spam-Level: X-Spam-Status: No, score=-0.164 tagged_above=-999 required=5 tests=[AWL=0.048, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.211, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U1ZxJYiUod5e for ; Thu, 18 May 2017 15:25:46 -0700 (PDT) Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by arlo.cworth.org (Postfix) with ESMTPS id ACAD96DE00B8 for ; Thu, 18 May 2017 15:25:41 -0700 (PDT) Received: by mail-wr0-f193.google.com with SMTP id g12so805119wrg.2 for ; Thu, 18 May 2017 15:25:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adirat-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=fUXjuPZM6IkVTGbfLPxdKJktXCkysSFxzBImo5Wu6gM=; b=VHhjUG7RzII1fzEImuYObEKgb6MiLJUfPjVODFhNmmGXIZvmEwmjQ1y0FqRKbowMhr SvrRUBDKs3OtReodmFnz6S56TR74DHb4lwA1J8DIar3TsGh+tB5wafliYtebZfdj6rn6 wjGI3oPMd/E/SlJipFVsMP2MP2y3Nlgkc3ttH86IxbodOB1jqRdJIjlI/Z29qUzINifu INMSLTT8cCowPRXf2TV9qHBK+hOIZj55KZQnl8Q2dcMiDRB1pbyLKWpuyUxDz23/vAeR u6euD6FtcYT5QzwZebAL6izvLlvvhglD6KzZRV6/wQ5dcSnDt5BFOl3hjDB3/q0UqanM S3wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=fUXjuPZM6IkVTGbfLPxdKJktXCkysSFxzBImo5Wu6gM=; b=kjzyxV/l+VH7YTHSm/QRY4uGfLZEDVsw0F8WKLTj85k9DY4mtaxsSocUo5sF/CZTEg zj8XUunhXnIrrh5pjRL3JFEBx6oBugHywGVZcn2aa3GhVn9LnLoIkwGq7eD9Wssd8SkF K90twu0RPcLKk5xG5v6DNwjuz2KoN7zwfcZQa/q5NT+It7zKoSuNjvoZYbCiNlJyatTy wpgvKZzCYm5MSrGrBS/iHPOeDl3Kv1S9Gnk4PyNTfR4pEedqTjB0ihsqTLAzpqfp10yw OMaaBI3rYW1zjJIlpVb3uBx4Qa+enAYQf0OzcmR0WJ1bwkVDr+pbmT13Z9Z1hBBOqucD jyFA== X-Gm-Message-State: AODbwcAJwdqdwNQeU9I8B1i90YjfRcgfySb1d7+CIKSB+XewHX+PshHg QTCGb0nVrbjLbvkQxiw= X-Received: by 10.223.136.235 with SMTP id g40mr682834wrg.107.1495146339515; Thu, 18 May 2017 15:25:39 -0700 (PDT) Received: from adiPC.adirat.com ([82.137.23.239]) by smtp.gmail.com with ESMTPSA id q16sm8141390wmg.2.2017.05.18.15.25.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 May 2017 15:25:38 -0700 (PDT) From: Ioan-Adrian Ratiu To: notmuch@notmuchmail.org Subject: [PATCH v2 02/11] lib: database: store message filesize & add range processor Date: Fri, 19 May 2017 01:26:59 +0300 Message-Id: <20170518222708.30032-3-adi@adirat.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170518222708.30032-1-adi@adirat.com> References: <20170518222708.30032-1-adi@adirat.com> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 May 2017 22:25:46 -0000 The filesize and range processor are very useful to do search queries like "filesize:1000..10000". All sizes are in bytes for now because that's what I'm interested in. I think the database needs to be re-created for this to work so that all newly indexed messages have the new xapian filesize value, I did not have the time to test a "hybrid" database where just some of the messages have the value. Signed-off-by: Ioan-Adrian Ratiu --- lib/database-private.h | 1 + lib/database.cc | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/lib/database-private.h b/lib/database-private.h index 727b1d61..d4d5ab6b 100644 --- a/lib/database-private.h +++ b/lib/database-private.h @@ -215,6 +215,7 @@ struct _notmuch_database { Xapian::ValueRangeProcessor *value_range_processor; Xapian::ValueRangeProcessor *date_range_processor; Xapian::ValueRangeProcessor *last_mod_range_processor; + Xapian::ValueRangeProcessor *filesize_range_processor; }; /* Prior to database version 3, features were implied by the database diff --git a/lib/database.cc b/lib/database.cc index 5b13f541..84e616cf 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -295,6 +295,7 @@ prefix_t prefix_table[] = { { "subject", "XSUBJECT", NOTMUCH_FIELD_EXTERNAL | NOTMUCH_FIELD_PROBABILISTIC | NOTMUCH_FIELD_PROCESSOR}, + { "filesize", "XFILESIZE", NOTMUCH_FIELD_EXTERNAL }, }; static void @@ -1082,6 +1083,7 @@ notmuch_database_open_verbose (const char *path, notmuch->value_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_TIMESTAMP); notmuch->date_range_processor = new ParseTimeValueRangeProcessor (NOTMUCH_VALUE_TIMESTAMP); notmuch->last_mod_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_LAST_MOD, "lastmod:"); + notmuch->filesize_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_FILESIZE, "filesize:"); notmuch->query_parser->set_default_op (Xapian::Query::OP_AND); notmuch->query_parser->set_database (*notmuch->xapian_db); @@ -1090,6 +1092,7 @@ notmuch_database_open_verbose (const char *path, notmuch->query_parser->add_valuerangeprocessor (notmuch->value_range_processor); notmuch->query_parser->add_valuerangeprocessor (notmuch->date_range_processor); notmuch->query_parser->add_valuerangeprocessor (notmuch->last_mod_range_processor); + notmuch->query_parser->add_valuerangeprocessor (notmuch->filesize_range_processor); for (i = 0; i < ARRAY_SIZE (prefix_table); i++) { const prefix_t *prefix = &prefix_table[i]; @@ -1166,6 +1169,8 @@ notmuch_database_close (notmuch_database_t *notmuch) notmuch->date_range_processor = NULL; delete notmuch->last_mod_range_processor; notmuch->last_mod_range_processor = NULL; + delete notmuch->filesize_range_processor; + notmuch->filesize_range_processor = NULL; return status; } @@ -2563,6 +2568,7 @@ notmuch_database_add_message (notmuch_database_t *notmuch, } _notmuch_message_add_filename (message, filename); + _notmuch_message_add_filesize (message, message_file); /* Is this a newly created message object or a ghost * message? We have to be slightly careful: if this is a -- 2.13.0