Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
512f9d11
Commit
512f9d11
authored
9 years ago
by
Alexandr Lyapunov
Browse files
Options
Downloads
Patches
Plain Diff
*) Fixed gh-836 : Restored GE iterator for HASH
*) Additionally added GT iterator *) Added test for that
parent
ac674aea
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/box/index.cc
+1
-1
1 addition, 1 deletion
src/box/index.cc
src/box/memtx_hash.cc
+39
-3
39 additions, 3 deletions
src/box/memtx_hash.cc
test/big/iterator.result
+30
-0
30 additions, 0 deletions
test/big/iterator.result
test/big/iterator.test.lua
+14
-0
14 additions, 0 deletions
test/big/iterator.test.lua
with
84 additions
and
4 deletions
src/box/index.cc
+
1
−
1
View file @
512f9d11
...
...
@@ -60,7 +60,7 @@ key_validate(struct key_def *key_def, enum iterator_type type, const char *key,
/*
* Zero key parts are allowed:
* - for TREE index, all iterator types,
* - ITER
A
_ALL iterator type, all index types
* - ITER_ALL iterator type, all index types
* - ITER_GE iterator in HASH index (legacy)
*/
if
(
key_def
->
type
==
TREE
||
type
==
ITER_ALL
)
...
...
This diff is collapsed.
Click to expand it.
src/box/memtx_hash.cc
+
39
−
3
View file @
512f9d11
...
...
@@ -171,7 +171,23 @@ hash_iterator_ge(struct iterator *ptr)
{
assert
(
ptr
->
free
==
hash_iterator_free
);
struct
hash_iterator
*
it
=
(
struct
hash_iterator
*
)
ptr
;
struct
tuple
**
res
=
light_index_itr_get_and_next
(
it
->
hash_table
,
&
it
->
hitr
);
struct
tuple
**
res
=
light_index_itr_get_and_next
(
it
->
hash_table
,
&
it
->
hitr
);
return
res
?
*
res
:
0
;
}
struct
tuple
*
hash_iterator_gt
(
struct
iterator
*
ptr
)
{
assert
(
ptr
->
free
==
hash_iterator_free
);
ptr
->
next
=
hash_iterator_ge
;
struct
hash_iterator
*
it
=
(
struct
hash_iterator
*
)
ptr
;
struct
tuple
**
res
=
light_index_itr_get_and_next
(
it
->
hash_table
,
&
it
->
hitr
);
if
(
!
res
)
return
0
;
res
=
light_index_itr_get_and_next
(
it
->
hash_table
,
&
it
->
hitr
);
return
res
?
*
res
:
0
;
}
...
...
@@ -303,7 +319,7 @@ MemtxHash::replace(struct tuple *old_tuple, struct tuple *new_tuple,
if
(
old_tuple
)
{
uint32_t
h
=
tuple_hash
(
old_tuple
,
key_def
);
int
res
=
light_index_delete_value
(
hash_table
,
h
,
old_tuple
);
assert
(
res
==
0
);
assert
(
res
==
0
);
(
void
)
res
;
}
return
old_tuple
;
}
...
...
@@ -337,13 +353,33 @@ MemtxHash::initIterator(struct iterator *ptr, enum iterator_type type,
struct
hash_iterator
*
it
=
(
struct
hash_iterator
*
)
ptr
;
switch
(
type
)
{
case
ITER_GE
:
if
(
part_count
!=
0
)
{
light_index_itr_key
(
it
->
hash_table
,
&
it
->
hitr
,
key_hash
(
key
,
key_def
),
key
);
}
else
{
light_index_itr_begin
(
it
->
hash_table
,
&
it
->
hitr
);
}
it
->
base
.
next
=
hash_iterator_ge
;
break
;
case
ITER_GT
:
if
(
part_count
!=
0
)
{
light_index_itr_key
(
it
->
hash_table
,
&
it
->
hitr
,
key_hash
(
key
,
key_def
),
key
);
it
->
base
.
next
=
hash_iterator_gt
;
}
else
{
light_index_itr_begin
(
it
->
hash_table
,
&
it
->
hitr
);
it
->
base
.
next
=
hash_iterator_ge
;
}
break
;
case
ITER_ALL
:
light_index_itr_begin
(
it
->
hash_table
,
&
it
->
hitr
);
it
->
base
.
next
=
hash_iterator_ge
;
break
;
case
ITER_EQ
:
assert
(
part_count
>
0
);
light_index_itr_key
(
it
->
hash_table
,
&
it
->
hitr
,
key_hash
(
key
,
key_def
),
key
);
light_index_itr_key
(
it
->
hash_table
,
&
it
->
hitr
,
key_hash
(
key
,
key_def
),
key
);
it
->
base
.
next
=
hash_iterator_eq
;
break
;
default
:
...
...
This diff is collapsed.
Click to expand it.
test/big/iterator.result
+
30
−
0
View file @
512f9d11
...
...
@@ -1054,3 +1054,33 @@ space:select({}, {iterator = 'mistake'})
space:drop()
---
...
-------------------------------------------------------------------------------
-- Restore GE iterator for HASH https://github.com/tarantool/tarantool/issues/836
-------------------------------------------------------------------------------
space = box.schema.space.create('test', {temporary=true})
---
...
idx1 = space:create_index('primary', {type='hash',unique=true})
---
...
for i = 0,4 do space:insert{i} end
---
...
space:select(2)
---
- - [2]
...
space:select(2, {iterator="GE"})
---
- - [2]
- [3]
- [4]
...
space:select(2, {iterator="GT"})
---
- - [3]
- [4]
...
space:drop()
---
...
This diff is collapsed.
Click to expand it.
test/big/iterator.test.lua
+
14
−
0
View file @
512f9d11
...
...
@@ -229,3 +229,17 @@ space:select({}, {iterator = 'mistake'})
space
:
drop
()
-------------------------------------------------------------------------------
-- Restore GE iterator for HASH https://github.com/tarantool/tarantool/issues/836
-------------------------------------------------------------------------------
space
=
box
.
schema
.
space
.
create
(
'test'
,
{
temporary
=
true
})
idx1
=
space
:
create_index
(
'primary'
,
{
type
=
'hash'
,
unique
=
true
})
for
i
=
0
,
4
do
space
:
insert
{
i
}
end
space
:
select
(
2
)
space
:
select
(
2
,
{
iterator
=
"GE"
})
space
:
select
(
2
,
{
iterator
=
"GT"
})
space
:
drop
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment