From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 143CE6E21E; Wed, 9 Feb 2022 20:54:01 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 143CE6E21E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1644429241; bh=aCn8KNYhRvRqVGlwKDKtmPmWfvpFNmNfAIVSXSjFh1g=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=nEP6Yjt3e4NrqclUXKWdp6k5W3tU71SCFE3DDnhMRo0Vo5v8Ifts70xDBHi28Mkwr riky0LghQEJ0QX+XyOiOF3r8p+pEIE/t212KVeGHUJlq9nqwJrZlY5bgDoAbfUQOKZ 7JuUEKa20hGPLfaLAko2pqyCNZHArbhOOovgjRTs= Received: from smtp37.i.mail.ru (smtp37.i.mail.ru [94.100.177.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 92CC76E21E for ; Wed, 9 Feb 2022 20:53:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 92CC76E21E Received: by smtp37.i.mail.ru with esmtpa (envelope-from ) id 1nHr9u-0003ou-1J; Wed, 09 Feb 2022 20:53:38 +0300 Message-ID: <43e7f638-c5da-22d3-2553-113141a786e5@tarantool.org> Date: Wed, 9 Feb 2022 20:53:37 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 To: Vladislav Shpilevoy , tarantool-patches@dev.tarantool.org References: <1e64752b75ac76272779b2a3c15c878d65cc20b8.1644366575.git.v.shpilevoy@tarantool.org> In-Reply-To: <1e64752b75ac76272779b2a3c15c878d65cc20b8.1644366575.git.v.shpilevoy@tarantool.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD9B74B50284A7C1A0B3AFEB45883C0D0F7B5075754E017D1DA182A05F538085040A079B9F1AEA8F1926BC8A889DAED723BA66769C7F7B03F4C60D3861FFD44AC21 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7F65C230EDDCD559EEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006374D0D183F14C070BA8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8A10D79435B2469B923CD924C86AE27F5117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD182CC0D3CB04F14752D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE4B6963042765DA4B4782AAF36435267CD8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE39E541A154B51D14B6136E347CC761E07C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637AD0424077D726551EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-8FC586DF: 6EFBBC1D9D64D975 X-C1DE0DAB: 0D63561A33F958A5C742242F0F24EA57AF40171A11951634ABAEA3C2625C1290D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75BFC02AB3DF06BA5A410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D346B222596F62B8FA9A95951B737BD992BB961CAC313078A850B83B1572F2FA57E55EE8101D80C36DA1D7E09C32AA3244C40AC95BB6D071B4FFD4B55BDAD69F1ADB4DF56057A86259F729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojptAT+HCMDqMflldjreq20A== X-Mailru-Sender: 583F1D7ACE8F49BD508BD8DBBD09B14DF6327956ED8DA88D79A5975B405CE1EC1762187F0D029BCF80EE221D05932256AD9BA6614E257C8ED9E51C16F2486AFBE342CF4F05FB7E8CB0DAF586E7D11B3E67EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH vshard 2/4] util: introduce Tarantool's semver parser X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Oleg Babin via Tarantool-patches Reply-To: Oleg Babin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thanks for your patch. Looks good. Probably it's worth to move this code into separate module. There are several modules in Tarantool ecosystem that implement its own parsers. One note below. On 09.02.2022 03:32, Vladislav Shpilevoy wrote: > Tarantool's version since recently has semver-like format. It > made impossible to check for features existence if they were > introduced not in the first release of one x.x.x triplet. > > An alternative would be to test for feature existence by its > usage, but it is not always possible with ease. > > This patch improves version parser in vshard to understand new > version names. > > It will be used by a future commit about netbox's return_raw > feature adoption to skip its tests for old versions > (<= 2.10.0-beta2). > > +local release_type_weight = { > + alpha = 0, > + beta = 1, > + rc = 2, > +} > + > +local function release_type_cmp(t1, t2) > + t1 = release_type_weight[t1] > + t2 = release_type_weight[t2] > + -- 'No release type' means the greatest. > + if not t1 then > + if not t2 then > + return 0 > + end > + return 1 > + end > + if not t2 then > + return -1 > + end > + return t1 - t2 > +end > + > +local function version_cmp(ver1, ver2) > + if ver1.id_major ~= ver2.id_major then > + return ver1.id_major - ver2.id_major > + end > + if ver1.id_middle ~= ver2.id_middle then > + return ver1.id_middle - ver2.id_middle > + end > + if ver1.id_minor ~= ver2.id_minor then > + return ver1.id_minor - ver2.id_minor > + end > + if ver1.rel_type ~= ver2.rel_type then > + return release_type_cmp(ver1.rel_type, ver2.rel_type) > + end > + if ver1.rel_num ~= ver2.rel_num then > + return ver1.rel_num - ver2.rel_num > + end > + if ver1.id_commit ~= ver2.id_commit then > + return ver1.id_commit - ver2.id_commit > + end > + return 0 > +end > + > +local version_mt = { > + __eq = function(l, r) > + return version_cmp(l, r) == 0 > + end, > + __lt = function(l, r) > + return version_cmp(l, r) < 0 > + end, > + __le = function(l, r) > + return version_cmp(l, r) <= 0 > + end, > +} > + > +local function version_new(id_major, id_middle, id_minor, rel_type, rel_num, > + id_commit) I think we could validate that at least id_major is not nil. > + -- There is no any validation - the API is not public. > + return setmetatable({ > + id_major = id_major, > + id_middle = id_middle, > + id_minor = id_minor, > + rel_type = rel_type, > + rel_num = rel_num, > + id_commit = id_commit, > + }, version_mt) > +end > + >