Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0E32B627B for ; Mon, 13 Jun 2011 15:18:13 +0000 (UTC) Received: (qmail 37436 invoked by uid 500); 13 Jun 2011 15:18:12 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 37410 invoked by uid 500); 13 Jun 2011 15:18:12 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 37402 invoked by uid 99); 13 Jun 2011 15:18:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Jun 2011 15:18:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Jun 2011 15:18:11 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id D59AB417E42 for ; Mon, 13 Jun 2011 15:17:51 +0000 (UTC) Date: Mon, 13 Jun 2011 15:17:51 +0000 (UTC) From: "Jonathan Ellis (JIRA)" To: commits@cassandra.apache.org Message-ID: <1525696487.2736.1307978271871.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <18812680.234851296119023726.JavaMail.jira@thor> Subject: [jira] [Commented] (CASSANDRA-2062) Better control of iterator consumption MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CASSANDRA-2062?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13048591#comment-13048591 ] Jonathan Ellis commented on CASSANDRA-2062: ------------------------------------------- bq. To avoid seeking, we need to guarantee: bq. A = next() bq. A is completely consumed (see [1]) bq. hasNext() ? bq. B = next() Right, I'm saying that instead of trying to guarantee this particular pattern, which limits generality (and introduces subtle performance problems if this is violated), just use AbstractIterator. computeNext the block and then it handles making arbitrary combinations of next/hasNext efficient. > Better control of iterator consumption > -------------------------------------- > > Key: CASSANDRA-2062 > URL: https://issues.apache.org/jira/browse/CASSANDRA-2062 > Project: Cassandra > Issue Type: Improvement > Components: Core > Reporter: Stu Hood > Priority: Minor > Fix For: 1.0 > > Attachments: 0001-CASSANDRA-2062-0001-Improved-iterator-for-merging-sort.txt, 0002-CASSANDRA-2062-0002-Port-all-collating-consumers-to-Me.txt > > > The core reason for this ticket is to gain control over the consumption of the lazy nested iterators in the read path. > {quote}We survive now because we write the size of the row at the front of the row (via some serious acrobatics at write time), which gives us hasNext() for rows for free. But it became apparent while working on the block-based format that hasNext() will not be cheap unless the current item has been consumed. "Consumption" of the row is easy, and blocks will be framed so that they can be very easily skipped, but you don't want to have to seek to the end of the row to answer hasNext, and then seek back to the beginning to consume the row, which is what CollatingIterator would have forced us to do.{quote} > While we're at it, we can also improve efficiency: for {{M}} iterators containing {{N}} total items, commons.collections.CollatingIterator performs a {{O(M*N)}} merge, and calls hasNext multiple times per returned value. We can do better. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira