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
feff7e31
Commit
feff7e31
authored
7 years ago
by
Vladislav Shpilevoy
Committed by
Konstantin Osipov
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
tuple: check key for sequential parts on compile time
Closes #2048
parent
bde4c789
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/box/tuple_extract_key.cc
+47
-21
47 additions, 21 deletions
src/box/tuple_extract_key.cc
with
47 additions
and
21 deletions
src/box/tuple_extract_key.cc
+
47
−
21
View file @
feff7e31
...
...
@@ -57,6 +57,7 @@ tuple_extract_key_sequential(const struct tuple *tuple,
* General-purpose implementation of tuple_extract_key()
* @copydoc tuple_extract_key()
*/
template
<
bool
contains_sequential_parts
>
static
char
*
tuple_extract_key_slowpath
(
const
struct
tuple
*
tuple
,
const
struct
key_def
*
key_def
,
uint32_t
*
key_size
)
...
...
@@ -73,17 +74,21 @@ tuple_extract_key_slowpath(const struct tuple *tuple,
tuple_field_raw
(
format
,
data
,
field_map
,
key_def
->
parts
[
i
].
fieldno
);
const
char
*
end
=
field
;
/*
* Skip sequential part in order to minimize
* tuple_field_raw() calls.
*/
for
(;
i
<
key_def
->
part_count
-
1
;
i
++
)
{
if
(
key_def
->
parts
[
i
].
fieldno
+
1
!=
key_def
->
parts
[
i
+
1
].
fieldno
)
{
/* End of sequential part */
break
;
if
(
contains_sequential_parts
)
{
/*
* Skip sequential part in order to
* minimize tuple_field_raw() calls.
*/
for
(;
i
<
key_def
->
part_count
-
1
;
i
++
)
{
if
(
key_def
->
parts
[
i
].
fieldno
+
1
!=
key_def
->
parts
[
i
+
1
].
fieldno
)
{
/*
* End of sequential part.
*/
break
;
}
mp_next
(
&
end
);
}
mp_next
(
&
end
);
}
mp_next
(
&
end
);
bsize
+=
end
-
field
;
...
...
@@ -100,17 +105,21 @@ tuple_extract_key_slowpath(const struct tuple *tuple,
tuple_field_raw
(
format
,
data
,
field_map
,
key_def
->
parts
[
i
].
fieldno
);
const
char
*
end
=
field
;
/*
* Skip sequential part in order to minimize
* tuple_field_raw() calls
*/
for
(;
i
<
key_def
->
part_count
-
1
;
i
++
)
{
if
(
key_def
->
parts
[
i
].
fieldno
+
1
!=
key_def
->
parts
[
i
+
1
].
fieldno
)
{
/* End of sequential part */
break
;
if
(
contains_sequential_parts
)
{
/*
* Skip sequential part in order to
* minimize tuple_field_raw() calls.
*/
for
(;
i
<
key_def
->
part_count
-
1
;
i
++
)
{
if
(
key_def
->
parts
[
i
].
fieldno
+
1
!=
key_def
->
parts
[
i
+
1
].
fieldno
)
{
/*
* End of sequential part.
*/
break
;
}
mp_next
(
&
end
);
}
mp_next
(
&
end
);
}
mp_next
(
&
end
);
bsize
=
end
-
field
;
...
...
@@ -181,6 +190,17 @@ tuple_extract_key_slowpath_raw(const char *data, const char *data_end,
return
key
;
}
/** True, if a key con contain two or more parts in sequence. */
static
bool
key_def_contains_sequential_parts
(
struct
key_def
*
def
)
{
for
(
uint32_t
i
=
0
;
i
<
def
->
part_count
-
1
;
++
i
)
{
if
(
def
->
parts
[
i
].
fieldno
+
1
==
def
->
parts
[
i
+
1
].
fieldno
)
return
true
;
}
return
false
;
}
/**
* Initialize tuple_extract_key() and tuple_extract_key_raw()
*/
...
...
@@ -191,7 +211,13 @@ tuple_extract_key_set(struct key_def *key_def)
key_def
->
tuple_extract_key
=
tuple_extract_key_sequential
;
key_def
->
tuple_extract_key_raw
=
tuple_extract_key_sequential_raw
;
}
else
{
key_def
->
tuple_extract_key
=
tuple_extract_key_slowpath
;
if
(
key_def_contains_sequential_parts
(
key_def
))
{
key_def
->
tuple_extract_key
=
tuple_extract_key_slowpath
<
true
>
;
}
else
{
key_def
->
tuple_extract_key
=
tuple_extract_key_slowpath
<
false
>
;
}
key_def
->
tuple_extract_key_raw
=
tuple_extract_key_slowpath_raw
;
}
}
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