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
b4c4e09b
Commit
b4c4e09b
authored
12 years ago
by
Konstantin Osipov
Browse files
Options
Downloads
Plain Diff
Merge branch 'stable'
Conflicts: src/box/box_lua.m
parents
82cb8532
18980af5
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/box_lua.m
+30
-12
30 additions, 12 deletions
src/box/box_lua.m
with
30 additions
and
12 deletions
src/box/box_lua.m
+
30
−
12
View file @
b4c4e09b
...
@@ -564,12 +564,22 @@ lbox_checkiterator(struct lua_State *L, int i)
...
@@ -564,12 +564,22 @@ lbox_checkiterator(struct lua_State *L, int i)
}
}
static
void
static
void
lbox
_
pushiterator
(
struct
lua
_
State
*
L
,
struct
iterator
*
it
)
lbox
_
pushiterator
(
struct
lua
_
State
*
L
,
Index
*
index
,
struct
iterator
*
it
,
enum
iterator
_
type
type
,
void
*
key
,
size
_
t
size
,
int
part
_
count
)
{
{
void
**
ptr
=
lua
_
newuserdata
(
L
,
sizeof
(
void
*
))
;
struct
{
struct
iterator
*
it
;
char
key
[]
;
}
*
holder
=
lua
_
newuserdata
(
L
,
sizeof
(
void
*
)
+
size
)
;
luaL
_
getmetatable
(
L
,
iteratorlib
_
name
)
;
luaL
_
getmetatable
(
L
,
iteratorlib
_
name
)
;
lua
_
setmetatable
(
L
,
-
2
)
;
lua
_
setmetatable
(
L
,
-
2
)
;
*
ptr
=
it
;
holder
->
it
=
it
;
memcpy
(
holder
->
key
,
key
,
size
)
;
[
index
initIterator
:
it
:
type
:
(
key
?
holder
->
key
:
NULL
)
:
part
_
count
]
;
}
}
static
int
static
int
...
@@ -722,19 +732,20 @@ lbox_create_iterator(struct lua_State *L)
...
@@ -722,19 +732,20 @@ lbox_create_iterator(struct lua_State *L)
{
{
Index
*
index
=
lua
_
checkindex
(
L
,
1
)
;
Index
*
index
=
lua
_
checkindex
(
L
,
1
)
;
int
argc
=
lua
_
gettop
(
L
)
;
int
argc
=
lua
_
gettop
(
L
)
;
size
_
t
allocated
_
size
=
palloc
_
allocated
(
fiber
->
gc
_
pool
)
;
/*
Create
a
new
iterator
.
*/
/*
Create
a
new
iterator
.
*/
enum
iterator
_
type
type
;
enum
iterator
_
type
type
;
u32
field
_
count
;
u32
field
_
count
=
0
;
void
*
key
;
void
*
key
=
NULL
;
u32
key
_
size
=
0
;
if
(
argc
==
1
||
(
argc
==
2
&&
lua
_
type
(
L
,
2
)
==
LUA
_
TNIL
))
{
if
(
argc
==
1
||
(
argc
==
2
&&
lua
_
type
(
L
,
2
)
==
LUA
_
TNIL
))
{
/*
/*
*
Nothing
or
nil
on
top
of
the
stack
,
*
Nothing
or
nil
on
top
of
the
stack
,
*
iteration
over
entire
range
from
the
*
iteration
over
entire
range
from
the
*
beginning
(
ITER
_
ALL
)
.
*
beginning
(
ITER
_
ALL
)
.
*/
*/
type
=
ITER
_
ALL
;
field
_
count
=
0
;
key
=
NULL
;
}
else
{
}
else
{
type
=
luaL
_
checkint
(
L
,
2
)
;
type
=
luaL
_
checkint
(
L
,
2
)
;
if
(
type
>=
iterator
_
type
_
MAX
)
if
(
type
>=
iterator
_
type
_
MAX
)
...
@@ -742,13 +753,12 @@ lbox_create_iterator(struct lua_State *L)
...
@@ -742,13 +753,12 @@ lbox_create_iterator(struct lua_State *L)
/*
What
else
do
we
have
on
the
stack
?
*/
/*
What
else
do
we
have
on
the
stack
?
*/
if
(
argc
==
2
||
(
argc
==
3
&&
lua
_
type
(
L
,
3
)
==
LUA
_
TNIL
))
{
if
(
argc
==
2
||
(
argc
==
3
&&
lua
_
type
(
L
,
3
)
==
LUA
_
TNIL
))
{
/*
Nothing
*/
/*
Nothing
*/
field
_
count
=
0
;
key
=
NULL
;
}
else
if
(
argc
==
3
&&
lua
_
type
(
L
,
3
)
==
LUA
_
TUSERDATA
)
{
}
else
if
(
argc
==
3
&&
lua
_
type
(
L
,
3
)
==
LUA
_
TUSERDATA
)
{
/*
Tuple
.
*/
/*
Tuple
.
*/
struct
tuple
*
tuple
=
lua
_
checktuple
(
L
,
2
)
;
struct
tuple
*
tuple
=
lua
_
checktuple
(
L
,
2
)
;
field
_
count
=
tuple
->
field
_
count
;
field
_
count
=
tuple
->
field
_
count
;
key
=
tuple
->
data
;
key
=
tuple
->
data
;
key
_
size
=
tuple
->
bsize
;
}
else
{
}
else
{
/*
Single
or
multi
-
part
key
.
*/
/*
Single
or
multi
-
part
key
.
*/
field
_
count
=
argc
-
2
;
field
_
count
=
argc
-
2
;
...
@@ -761,6 +771,7 @@ lbox_create_iterator(struct lua_State *L)
...
@@ -761,6 +771,7 @@ lbox_create_iterator(struct lua_State *L)
append
_
key
_
part
(
L
,
i
+
3
,
data
,
type
)
;
append
_
key
_
part
(
L
,
i
+
3
,
data
,
type
)
;
}
}
key
=
data
->
data
;
key
=
data
->
data
;
key
_
size
=
data
->
size
;
}
}
/*
/*
*
We
allow
partially
specified
keys
for
TREE
*
We
allow
partially
specified
keys
for
TREE
...
@@ -773,9 +784,11 @@ lbox_create_iterator(struct lua_State *L)
...
@@ -773,9 +784,11 @@ lbox_create_iterator(struct lua_State *L)
field
_
count
,
index
->
key
_
def
->
part
_
count
)
;
field
_
count
,
index
->
key
_
def
->
part
_
count
)
;
}
}
struct
iterator
*
it
=
[
index
allocIterator
]
;
struct
iterator
*
it
=
[
index
allocIterator
]
;
[
index
initIterator
:
it
:
type
:
key
:
field
_
count
]
;
lbox
_
pushiterator
(
L
,
index
,
it
,
type
,
key
,
key
_
size
,
lbox
_
pushiterator
(
L
,
i
t
)
;
field
_
coun
t
)
;
/*
truncate
memory
used
by
key
construction
*/
ptruncate
(
fiber
->
gc
_
pool
,
allocated
_
size
)
;
return
it
;
return
it
;
}
}
...
@@ -853,7 +866,9 @@ lbox_index_count(struct lua_State *L)
...
@@ -853,7 +866,9 @@ lbox_index_count(struct lua_State *L)
int
argc
=
lua
_
gettop
(
L
)
-
1
;
int
argc
=
lua
_
gettop
(
L
)
-
1
;
if
(
argc
==
0
)
if
(
argc
==
0
)
luaL
_
error
(
L
,
"index.count(): one or more arguments expected"
)
;
luaL
_
error
(
L
,
"index.count(): one or more arguments expected"
)
;
/*
preparing
single
or
multi
-
part
key
*/
/*
preparing
single
or
multi
-
part
key
*/
size
_
t
allocated
_
size
=
palloc
_
allocated
(
fiber
->
gc
_
pool
)
;
void
*
key
;
void
*
key
;
u32
key
_
part
_
count
;
u32
key
_
part
_
count
;
if
(
argc
==
1
&&
lua
_
type
(
L
,
2
)
==
LUA
_
TUSERDATA
)
{
if
(
argc
==
1
&&
lua
_
type
(
L
,
2
)
==
LUA
_
TUSERDATA
)
{
...
@@ -883,6 +898,9 @@ lbox_index_count(struct lua_State *L)
...
@@ -883,6 +898,9 @@ lbox_index_count(struct lua_State *L)
while
((
tuple
=
it
->
next
(
it
))
!=
NULL
)
while
((
tuple
=
it
->
next
(
it
))
!=
NULL
)
count
++;
count
++;
/*
truncate
memory
used
by
key
construction
*/
ptruncate
(
fiber
->
gc
_
pool
,
allocated
_
size
)
;
/*
returning
subtree
size
*/
/*
returning
subtree
size
*/
lua
_
pushnumber
(
L
,
count
)
;
lua
_
pushnumber
(
L
,
count
)
;
return
1
;
return
1
;
...
...
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