Re: Backward scrolling notmuch_messages_t and notmuch_threads_t
authorSergei Shilovsky <sshilovsky@gmail.com>
Tue, 7 Oct 2014 14:04:09 +0000 (18:04 +0400)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:05:08 +0000 (10:05 -0800)
f5/a876c963976aaff70704510819da75985ba08f [new file with mode: 0644]

diff --git a/f5/a876c963976aaff70704510819da75985ba08f b/f5/a876c963976aaff70704510819da75985ba08f
new file mode 100644 (file)
index 0000000..80590ae
--- /dev/null
@@ -0,0 +1,130 @@
+Return-Path: <sshilovsky@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 0A0DE431FB6\r
+       for <notmuch@notmuchmail.org>; Tue,  7 Oct 2014 07:04:18 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id EKLn6RV07Tl9 for <notmuch@notmuchmail.org>;\r
+       Tue,  7 Oct 2014 07:04:10 -0700 (PDT)\r
+Received: from mail-oi0-f52.google.com (mail-oi0-f52.google.com\r
+       [209.85.218.52]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id B42D0431FAF\r
+       for <notmuch@notmuchmail.org>; Tue,  7 Oct 2014 07:04:10 -0700 (PDT)\r
+Received: by mail-oi0-f52.google.com with SMTP id a3so5217253oib.11\r
+       for <notmuch@notmuchmail.org>; Tue, 07 Oct 2014 07:04:10 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=mime-version:reply-to:in-reply-to:references:date:message-id\r
+       :subject:from:to:cc:content-type:content-transfer-encoding;\r
+       bh=+AatGbCyyrCfWm9m+zgIozJNs8d4k+V0mYYoJ/LrpbQ=;\r
+       b=NV5G8ugAvX7FTLUZ25Q2P6OtWV3VwHPFKZs8Q18h65hW2EvF1Kyc6zOPpTUo8r7d/L\r
+       aVjWWcSmlQEZUKTy3MZr0MRfLhmm7UKv1HiPyx4JzhYhfmDECblA/ypE2O/1/dPLPxiK\r
+       QAsUJ27QqRmx09gK56WbUVdh0+bSI+SHONYKx41m33/df7Oo0Swdwdg19uG93oFb7F2d\r
+       h5eAWdyEfl4VXJUf4T7R99pNrIj6jzCrlHfiB+iGZixZa75mNNy6yZtsgRDO6kirb0IU\r
+       r/vTZc9izeUDvCwkWakYfTfvrLy2PJnhEOv6+5MDqS/WXajyNf6pCHs6/dBz8ted3NLB\r
+       Pong==\r
+MIME-Version: 1.0\r
+X-Received: by 10.182.236.65 with SMTP id us1mr4373287obc.38.1412690649854;\r
+       Tue, 07 Oct 2014 07:04:09 -0700 (PDT)\r
+Received: by 10.76.41.3 with HTTP; Tue, 7 Oct 2014 07:04:09 -0700 (PDT)\r
+In-Reply-To: <87lhos5duu.fsf@nikula.org>\r
+References:\r
+ <CAHc2pO2_mQZzG7TqntSLEY78YEZSVEwDSesgpCn1ZbngJvM0dQ@mail.gmail.com>\r
+       <87lhos5duu.fsf@nikula.org>\r
+Date: Tue, 7 Oct 2014 18:04:09 +0400\r
+Message-ID:\r
+ <CAHc2pO2J6-UMVnLx3dSGns1z4aaxSZZdGfVNVtetcex9xbsCKQ@mail.gmail.com>\r
+Subject: Re: Backward scrolling notmuch_messages_t and notmuch_threads_t\r
+From: Sergei Shilovsky <sshilovsky@gmail.com>\r
+To: Jani Nikula <jani@nikula.org>\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: quoted-printable\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+Reply-To: sshilovsky@gmail.com\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 07 Oct 2014 14:04:18 -0000\r
+\r
+notmuch search --offset` simply skips the number of threads/messages.\r
+This is not so fast if the offset is large.\r
+\r
+ 98     for (i =3D 0;\r
+ 99          notmuch_threads_valid (threads) && (limit < 0 || i <\r
+offset + limit    );\r
+100          notmuch_threads_move_to_next (threads), i++)\r
+101     {\r
+102         thread =3D notmuch_threads_get (threads);\r
+103\r
+104         if (i < offset) {\r
+105             notmuch_thread_destroy (thread);\r
+106             continue;\r
+107         }\r
+\r
+On Tue, Oct 7, 2014 at 3:16 PM, Jani Nikula <jani@nikula.org> wrote:\r
+> On Tue, 07 Oct 2014, Sergei Shilovsky <sshilovsky@gmail.com> wrote:\r
+>> Lets consider messages first.\r
+>>\r
+>> As far as I get there is no straightforward\r
+>> notmuch_messages_move_to_previous. One can usually implement such\r
+>> behaviour with caching previous messages which is slightly inefficient\r
+>> in memory consumption terms.\r
+>>\r
+>> But we can sort messages either date asc or date desc.\r
+>>\r
+>> Suppose, we're currently at the 1000th message in query "tag:whatever".\r
+>>\r
+>> So if we need to go to the previous message we could do something like\r
+>>\r
+>>     notmuch search --sort=3Doldest-first tag:whatever and \\r
+>>         date:..<here is the date of the 1000th message>\r
+>>\r
+>> This query's result should start with our 1000th message following its\r
+>> previous message (in terms of the original request). So backward\r
+>> scrolling with no cache looks to be at least possible.\r
+>>\r
+>> Any idea of would that be fine? Is it possible to implement similar\r
+>> thing at low-level?\r
+>\r
+> See notmuch search --offset=3DN and --limit=3DN options.\r
+>\r
+> BR,\r
+> Jani.\r
+>\r
+>\r
+>>\r
+>> --\r
+>> =D0=A1 =D1=83=D0=B2=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=D0=BC,\r
+>> =D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9 =D0=A8=D0=B8=D0=BB=D0=BE=D0=B2=D1=\r
+=81=D0=BA=D0=B8=D0=B9\r
+>> Sergei Shilovsky\r
+>> _______________________________________________\r
+>> notmuch mailing list\r
+>> notmuch@notmuchmail.org\r
+>> http://notmuchmail.org/mailman/listinfo/notmuch\r
+\r
+\r
+\r
+--=20\r
+=D0=A1 =D1=83=D0=B2=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=D0=BC,\r
+=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9 =D0=A8=D0=B8=D0=BB=D0=BE=D0=B2=D1=81=\r
+=D0=BA=D0=B8=D0=B9\r
+Sergei Shilovsky\r