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
d1e7ee51
Commit
d1e7ee51
authored
7 years ago
by
Roman Tsisyk
Committed by
Roman Tsisyk
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
tuple: extract field_def from tuple_format
No semantic changes. Needed for #2754
parent
5554f25e
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/field_def.h
+30
-0
30 additions, 0 deletions
src/box/field_def.h
src/box/tuple_format.c
+3
-3
3 additions, 3 deletions
src/box/tuple_format.c
src/box/tuple_format.h
+3
-34
3 additions, 34 deletions
src/box/tuple_format.h
src/box/vy_stmt.c
+2
-2
2 additions, 2 deletions
src/box/vy_stmt.c
with
38 additions
and
39 deletions
src/box/field_def.h
+
30
−
0
View file @
d1e7ee51
...
...
@@ -31,6 +31,8 @@
* SUCH DAMAGE.
*/
#include
<stdint.h>
#if defined(__cplusplus)
extern
"C"
{
#endif
/* defined(__cplusplus) */
...
...
@@ -61,6 +63,34 @@ extern const char *field_type_strs[];
enum
field_type
field_type_by_name
(
const
char
*
name
);
/**
* @brief Field definition
* Contains information about of one tuple field.
*/
struct
field_def
{
/**
* Field type of an indexed field.
* If a field participates in at least one of space indexes
* then its type is stored in this member.
* If a field does not participate in an index
* then UNKNOWN is stored for it.
*/
enum
field_type
type
;
/**
* Offset slot in field map in tuple. Normally tuple
* stores field map - offsets of all fields participating
* in indexes. This allows quick access to most used
* fields without parsing entire mspack. This member
* stores position in the field map of tuple for current
* field. If the field does not participate in indexes
* then it has no offset in field map and INT_MAX is
* stored in this member. Due to specific field map in
* tuple (it is stored before tuple), the positions in
* field map is negative.
*/
int32_t
offset_slot
;
};
#if defined(__cplusplus)
}
/* extern "C" */
#endif
/* defined(__cplusplus) */
...
...
This diff is collapsed.
Click to expand it.
src/box/tuple_format.c
+
3
−
3
View file @
d1e7ee51
...
...
@@ -63,7 +63,7 @@ tuple_format_create(struct tuple_format *format, struct key_def **keys,
for
(;
part
<
parts_end
;
part
++
)
{
assert
(
part
->
fieldno
<
format
->
field_count
);
struct
tuple_field_format
*
field
=
struct
field_def
*
field
=
&
format
->
fields
[
part
->
fieldno
];
if
(
field
->
type
==
FIELD_TYPE_ANY
)
{
...
...
@@ -168,7 +168,7 @@ tuple_format_alloc(struct key_def **keys, uint16_t key_count)
uint32_t
field_count
=
key_count
>
0
?
max_fieldno
+
1
:
0
;
uint32_t
total
=
sizeof
(
struct
tuple_format
)
+
field_count
*
sizeof
(
struct
tuple_field_format
);
field_count
*
sizeof
(
struct
field_def
);
struct
tuple_format
*
format
=
(
struct
tuple_format
*
)
malloc
(
total
);
if
(
format
==
NULL
)
{
...
...
@@ -215,7 +215,7 @@ struct tuple_format *
tuple_format_dup
(
const
struct
tuple_format
*
src
)
{
uint32_t
total
=
sizeof
(
struct
tuple_format
)
+
src
->
field_count
*
sizeof
(
struct
tuple_field_format
);
src
->
field_count
*
sizeof
(
struct
field_def
);
struct
tuple_format
*
format
=
(
struct
tuple_format
*
)
malloc
(
total
);
if
(
format
==
NULL
)
{
...
...
This diff is collapsed.
Click to expand it.
src/box/tuple_format.h
+
3
−
34
View file @
d1e7ee51
...
...
@@ -31,7 +31,8 @@
* SUCH DAMAGE.
*/
#include
"key_def.h"
/* for enum field_type */
#include
"key_def.h"
#include
"field_def.h"
#include
"errinj.h"
#if defined(__cplusplus)
...
...
@@ -60,38 +61,6 @@ enum { TUPLE_INDEX_BASE = 1 };
*/
enum
{
TUPLE_OFFSET_SLOT_NIL
=
INT32_MAX
};
/**
* @brief Tuple field format
* Support structure for struct tuple_format.
* Contains information of one field.
*/
struct
tuple_field_format
{
/**
* Field type of an indexed field.
* If a field participates in at least one of space indexes
* then its type is stored in this member.
* If a field does not participate in an index
* then UNKNOWN is stored for it.
*/
enum
field_type
type
;
/**
* Offset slot in field map in tuple.
* Normally tuple stores field map - offsets of all fields
* participating in indexes. This allows quick access to most
* used fields without parsing entire mspack.
* This member stores position in the field map of tuple
* for current field.
* If the field does not participate in indexes then it has
* no offset in field map and INT_MAX is stored in this member.
* Due to specific field map in tuple (it is stored before tuple),
* the positions in field map is negative.
* Thus if this member is negative, smth like
* tuple->data[((uint32_t *)tuple)[format->offset_slot[fieldno]]]
* gives the start of the field
*/
int32_t
offset_slot
;
};
struct
tuple
;
struct
tuple_format
;
...
...
@@ -132,7 +101,7 @@ struct tuple_format {
/* Length of 'fields' array. */
uint32_t
field_count
;
/* Formats of the fields */
struct
tuple_field_format
fields
[];
struct
field_def
fields
[
0
];
};
extern
struct
tuple_format
**
tuple_formats
;
...
...
This diff is collapsed.
Click to expand it.
src/box/vy_stmt.c
+
2
−
2
View file @
d1e7ee51
...
...
@@ -397,7 +397,7 @@ vy_stmt_new_surrogate_from_key(const char *key, enum iproto_type type,
char
*
raw
=
(
char
*
)
tuple_data
(
stmt
);
char
*
wpos
=
mp_encode_array
(
raw
,
field_count
);
for
(
uint32_t
i
=
0
;
i
<
field_count
;
++
i
)
{
struct
tuple_field_format
*
field
=
&
format
->
fields
[
i
];
struct
field_def
*
field
=
&
format
->
fields
[
i
];
if
(
field
->
type
==
FIELD_TYPE_ANY
)
{
wpos
=
mp_encode_nil
(
wpos
);
continue
;
...
...
@@ -450,7 +450,7 @@ vy_stmt_new_surrogate(struct tuple_format *format, const struct tuple *src,
(
void
)
src_count
;
char
*
pos
=
mp_encode_array
(
data
,
format
->
field_count
);
for
(
uint32_t
i
=
0
;
i
<
format
->
field_count
;
++
i
)
{
struct
tuple_field_format
*
field
=
&
format
->
fields
[
i
];
struct
field_def
*
field
=
&
format
->
fields
[
i
];
if
(
field
->
type
==
FIELD_TYPE_ANY
)
{
/* Unindexed field - write NIL */
pos
=
mp_encode_nil
(
pos
);
...
...
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