Skip to content

Commit

Permalink
memtx: create tree with block cardinalities if fast_offset is set
Browse files Browse the repository at this point in the history
This patch makes the memtx tree index create different trees depending
on the `fast_offset` index option. This is the first step towards the
logarithmic select and iteration with offset and count implementation.

NO_DOC=see the next commit
NO_CHANGELOG=see the next commit
  • Loading branch information
mkostoevr committed Jun 14, 2024
1 parent 635be77 commit 4f6af76
Show file tree
Hide file tree
Showing 5 changed files with 464 additions and 284 deletions.
9 changes: 7 additions & 2 deletions src/box/lua/space.cc
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,13 @@ lbox_fillspace(struct lua_State *L, struct space *space, int i)
lua_setfield(L, -2, "hint");
}

lua_pushnil(L);
lua_setfield(L, -2, "fast_offset");
if (space_is_memtx(space) && index_def->type == TREE) {
lua_pushboolean(L, index_opts->fast_offset);
lua_setfield(L, -2, "fast_offset");
} else {
lua_pushnil(L);
lua_setfield(L, -2, "fast_offset");
}

if (index_opts->func_id > 0) {
lua_pushstring(L, "func");
Expand Down
2 changes: 2 additions & 0 deletions src/box/memtx_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2014,6 +2014,8 @@ memtx_index_def_change_requires_rebuild(struct index *index,
return true;
if (old_def->opts.hint != new_def->opts.hint)
return true;
if (old_def->opts.fast_offset != new_def->opts.fast_offset)
return true;

const struct key_def *old_cmp_def, *new_cmp_def;
if (index_depends_on_pk(index)) {
Expand Down
26 changes: 21 additions & 5 deletions src/box/memtx_space.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,11 +761,6 @@ memtx_space_check_index_def(struct space *space, struct index_def *index_def)
{
struct key_def *key_def = index_def->key_def;

if (index_def->opts.fast_offset) {
diag_set(ClientError, ER_UNSUPPORTED, "memtx",
"logarithmic select with offset");
return -1;
}
if (key_def->is_nullable) {
if (index_def->iid == 0) {
diag_set(ClientError, ER_NULLABLE_PRIMARY,
Expand All @@ -787,6 +782,13 @@ memtx_space_check_index_def(struct space *space, struct index_def *index_def)
"HASH index must be unique");
return -1;
}
if (index_def->opts.fast_offset) {
diag_set(ClientError, ER_MODIFY_INDEX,
index_def->name, space_name(space),
"HASH index does not support "
"logarithmic select with offset");
return -1;
}
if (key_def->is_multikey) {
diag_set(ClientError, ER_MODIFY_INDEX,
index_def->name, space_name(space),
Expand Down Expand Up @@ -816,6 +818,13 @@ memtx_space_check_index_def(struct space *space, struct index_def *index_def)
"RTREE index can not be unique");
return -1;
}
if (index_def->opts.fast_offset) {
diag_set(ClientError, ER_MODIFY_INDEX,
index_def->name, space_name(space),
"RTREE index does not support "
"logarithmic select with offset");
return -1;
}
if (key_def->parts[0].type != FIELD_TYPE_ARRAY) {
diag_set(ClientError, ER_MODIFY_INDEX,
index_def->name, space_name(space),
Expand Down Expand Up @@ -849,6 +858,13 @@ memtx_space_check_index_def(struct space *space, struct index_def *index_def)
"BITSET can not be unique");
return -1;
}
if (index_def->opts.fast_offset) {
diag_set(ClientError, ER_MODIFY_INDEX,
index_def->name, space_name(space),
"BITSET index does not support "
"logarithmic select with offset");
return -1;
}
if (key_def->parts[0].type != FIELD_TYPE_UNSIGNED &&
key_def->parts[0].type != FIELD_TYPE_STRING &&
key_def->parts[0].type != FIELD_TYPE_VARBINARY) {
Expand Down

0 comments on commit 4f6af76

Please sign in to comment.