From patchwork Wed May 8 11:04:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13658541 Received: from fhigh4-smtp.messagingengine.com (fhigh4-smtp.messagingengine.com [103.168.172.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5910F81AA2 for ; Wed, 8 May 2024 11:04:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.155 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715166256; cv=none; b=GEG3VTWQJKyCacESEJhzps/xLoyg8aw8NRoD6Vnj6ZzUmxcZSfGMER/7yswrOL0TF86QtN519FUUouYQFWTnett6g2yeJSHI6s7G7R/03WfEndmC6WfGgPsYjpqwAGGvGEEMbXZ0fmzdYsXL4LyBPbp8Btr6akdlZQd9b7Lksbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715166256; c=relaxed/simple; bh=Hj/FvAQEjG22vrfkhkPL7UWVT0GmZl/Y7aWOVXdUVpg=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=b+vusPyXuOb/BtiS6s4FhCn/mqA4MHOzvcQt3GdFG843NAVKAzkrir8SzzRm2sdvsosMTip9lvmIpzF5DFCpEf+st7mgtLgEpisrBGusxSQt5dw2zbnSp4mgn6VW64E5M+K14iBlY3oUFz+9qsVaCdQTRL70ObDpWR/0eopXInk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=VCQ4FDjt; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=SD0C9c5+; arc=none smtp.client-ip=103.168.172.155 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="VCQ4FDjt"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="SD0C9c5+" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 8DE8C1140224 for ; Wed, 8 May 2024 07:04:14 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 08 May 2024 07:04:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1715166254; x=1715252654; bh=4zn2XNPS2x uTM/GvMgF+g18tLHkUJuVGA1XZwAFvQ0o=; b=VCQ4FDjt3YyE4HoKsZG8W6Bwd2 8+8t1fO9WNpOWXpvEfdAnC0PIgQOkoKisogbme3Cm2Q0VhKncxPrpTbsCRIF+/qy wY8oonTXMf8F14mMUk6Z6hG5gdb4WxZOpr6HUPUfbKPqjEpyzzn3nOdhMHboNcMD J2OtfHTIQJWKY1ZvZGoJtVclHbLnTsd3XSacdtGUFT3pQvNkw1Z9GBJPh5NT0t8q Srno7qA6pvVz95siIlkn0NnbVECtShSmK761KBIRbqScJyxey4J87ShhZjT6hqE6 c39Vld4SaN+3nMB2oae1yP7HIruI6Hft/Fj3FKkGfx1LRuCwt7gWrS5nlsOg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1715166254; x=1715252654; bh=4zn2XNPS2xuTM/GvMgF+g18tLHkU JuVGA1XZwAFvQ0o=; b=SD0C9c5+v2OtHdunZ127r106CLM7xL75ovZs1CBE7OzA 0pnCQc1JA2G8MZcaS2yWLPkFcEqtw+aH/a+Mn4Y1aBGZlS4h6xv0/F+xIX7CxYK2 dzmslT4FXdPzn3NfxR6hHQO8kapeniBWfTqJfpNABQgFacVvf+wlVMhIlwViABt4 Dt8MFcLyDF3RhM+x9O6kSDkcEYgsv3CFk3sp8FbVMmteWsaNXnm00nYZwL/4xeqx VQsgoZyK1e1MdU83j0qJW8RZUFQ/hj98IDTNl0O2FsKK90umEipzFs1zcYs4/DXV yNqwk5N2EFwLcu6ZsSObu2EPc4FAHrq7Yc9I8km4GA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdeftddgfeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecuvehluhhsthgvrhfuihiivgepvdenucfrrghr rghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 8 May 2024 07:04:13 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id eda0b46c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Wed, 8 May 2024 11:04:03 +0000 (UTC) Date: Wed, 8 May 2024 13:04:11 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 08/13] reftable/merged: simplify indices for subiterators Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: When seeking on a merged table, we perform the seek for each of the subiterators. If the subiterator hasa the desired record we add it to the priority queue, otherwise we skip it and don't add it to the stack of subiterators hosted by the merged table. The consequence of this is that the index of the subiterator in the merged table does not necessarily correspond to the index of it in the merged iterator. Next to being potentially confusing, it also means that we won't easily be able to re-seek the merged iterator because we have no clear connection between both of the data structures. Refactor the code so that the index stays the same in both structures. Signed-off-by: Patrick Steinhardt --- reftable/merged.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/reftable/merged.c b/reftable/merged.c index 4e1b78e93f..18a2a6f09b 100644 --- a/reftable/merged.c +++ b/reftable/merged.c @@ -37,6 +37,7 @@ static void merged_iter_init(struct merged_iter *mi, mi->advance_index = -1; mi->suppress_deletions = mt->suppress_deletions; REFTABLE_CALLOC_ARRAY(mi->subiters, mt->stack_len); + mi->stack_len = mt->stack_len; } static void merged_iter_close(void *p) @@ -236,21 +237,19 @@ static int merged_table_seek_record(struct reftable_merged_table *mt, merged_iter_init(&merged, mt); for (size_t i = 0; i < mt->stack_len; i++) { - reftable_record_init(&merged.subiters[merged.stack_len].rec, + reftable_record_init(&merged.subiters[i].rec, reftable_record_type(rec)); err = reftable_table_seek_record(&mt->stack[i], - &merged.subiters[merged.stack_len].iter, rec); + &merged.subiters[i].iter, rec); if (err < 0) goto out; if (err > 0) continue; - err = merged_iter_advance_subiter(&merged, merged.stack_len); + err = merged_iter_advance_subiter(&merged, i); if (err < 0) goto out; - - merged.stack_len++; } p = reftable_malloc(sizeof(*p));