Skip to content

Revert remove tuple keydef #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/workflows/test_on_push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ jobs:
github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
tarantool-version: ["1.10", "2.2", "2.3", "2.7", "2.8"]
# We need 1.10.6 here to check that module works with
# old Tarantool versions that don't have "tuple-keydef"/"tuple-merger" support.
tarantool-version: ["1.10.6", "1.10", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7"]
remove-merger: [false]
include:
- tarantool-version: "2.7"
Expand All @@ -23,11 +25,23 @@ jobs:
steps:
- uses: actions/checkout@master

- name: Setup Tarantool CE
- name: Setup Tarantool CE (~= 1.10.6)
uses: tarantool/setup-tarantool@v1
if: matrix.tarantool-version != '1.10.6'
with:
tarantool-version: ${{ matrix.tarantool-version }}

- name: Setup Tarantool CE 1.10.6
if: matrix.tarantool-version == '1.10.6'
run: |
curl -L https://tarantool.io/release/1.10/installer.sh | bash
sudo apt install -y tarantool=1.10.6.0.g5372cd2fa-1 tarantool-dev=1.10.6.0.g5372cd2fa-1

- name: Fix luarocks in Tarantool CE 1.10.6
if: matrix.tarantool-version == '1.10.6'
run: |
sudo patch -p1 /usr/share/tarantool/luarocks/manif.lua luarocks.patch

- name: Install requirements for community
run: |
tarantool --version
Expand Down
5 changes: 0 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Changed

* Remove support of Tarantool versions that have no builtin tuple-keydef
module.
* Tarantool versions 2.{4,5,6} have reached EOL and removed from regression
testing. It means that methods `crud.min()` and `crud.max` won't work for old
versions (< 1.10.8) anymore.
* Names of errors generated by CRUD operations have been unified.
* Opmimize `crud.select()` / `crud.pairs()` for one replicaset case (say, when
`bucket_id` is passed or deducible from conditions). It gives 13% boost on
Expand Down
43 changes: 34 additions & 9 deletions crud/borders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ local dev_checks = require('crud.common.dev_checks')
local call = require('crud.common.call')
local utils = require('crud.common.utils')
local schema = require('crud.common.schema')
local Keydef = require('crud.compare.keydef')
local has_keydef, Keydef = pcall(require, 'crud.compare.keydef')
local select_comparators = require('crud.compare.comparators')

local BorderError = errors.new_class('BorderError', {capture_stack = false})

Expand Down Expand Up @@ -44,14 +45,25 @@ function borders.init()
_G._crud.get_border_on_storage = get_border_on_storage
end

local is_closer = function (compare_sign, keydef, tuple, res_tuple)
if res_tuple == nil then
return true
end
local is_closer

if has_keydef then
is_closer = function (compare_sign, keydef, tuple, res_tuple)
if res_tuple == nil then
return true
end

local cmp = keydef:compare(tuple, res_tuple)
local cmp = keydef:compare(tuple, res_tuple)

return cmp * compare_sign > 0
return cmp * compare_sign > 0
end
else
is_closer = function (_, comparator, tuple, res_tuple)
if res_tuple == nil then
return true
end
return comparator(tuple, res_tuple)
end
end

local function call_get_border_on_router(border_name, space_name, index_name, opts)
Expand Down Expand Up @@ -100,7 +112,20 @@ local function call_get_border_on_router(border_name, space_name, index_name, op
end

local compare_sign = border_name == 'max' and 1 or -1
local keydef = Keydef.new(space, field_names, index.id)
local comparator
if has_keydef then
comparator = Keydef.new(space, field_names, index.id)
else
local tarantool_iter
if compare_sign > 0 then
tarantool_iter = box.index.GT
else
tarantool_iter = box.index.LT
end
local key_parts = utils.merge_primary_key_parts(index.parts, primary_index.parts)
local cmp_operator = select_comparators.get_cmp_operator(tarantool_iter)
comparator = select_comparators.gen_tuples_comparator(cmp_operator, key_parts, field_names, space:format())
end

local res_tuple = nil
for _, storage_result in pairs(results) do
Expand All @@ -111,7 +136,7 @@ local function call_get_border_on_router(border_name, space_name, index_name, op
end

local tuple = storage_result.res
if tuple ~= nil and is_closer(compare_sign, keydef, tuple, res_tuple) then
if tuple ~= nil and is_closer(compare_sign, comparator, tuple, res_tuple) then
res_tuple = tuple
end
end
Expand Down
20 changes: 20 additions & 0 deletions luarocks.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua
index 34ae02da5..79a427819 100644
--- a/src/luarocks/manif.lua
+++ b/src/luarocks/manif.lua
@@ -444,11 +444,10 @@ function manif.add_to_manifest(name, version, repo, deps_mode)

local manifest, err = manif_core.load_local_manifest(rocks_dir)
if not manifest then
- util.printerr("No existing manifest. Attempting to rebuild...")
- -- Manifest built by `manif.make_manifest` should already
- -- include information about given name and version,
- -- no need to update it.
- return manif.make_manifest(rocks_dir, deps_mode)
+ util.printerr("No existing manifest. Creating an empty one...")
+ -- Create an empty manifest.
+ manifest, err = { repository = {}, modules = {}, commands = {} }, nil
+ manif_core.cache_manifest(rocks_dir, nil, manifest)
end

local results = {[name] = {[version] = {{arch = "installed", repo = rocks_dir}}}}