Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
204f68ed
Commit
204f68ed
authored
Sep 11, 2007
by
Rich Prohaska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement delete under brt cursor
git-svn-id:
file:///svn/tokudb@291
c7de825b-a66e-492c-adef-691d508d4ae1
parent
f5be7117
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
102 additions
and
14 deletions
+102
-14
newbrt/brt-test.c
newbrt/brt-test.c
+64
-0
newbrt/brt.c
newbrt/brt.c
+16
-0
newbrt/brt.h
newbrt/brt.h
+1
-0
newbrt/pma.c
newbrt/pma.c
+17
-0
newbrt/pma.h
newbrt/pma.h
+4
-14
No files found.
newbrt/brt-test.c
View file @
204f68ed
...
@@ -1548,6 +1548,68 @@ void test_brt_cursor_set_range(int n) {
...
@@ -1548,6 +1548,68 @@ void test_brt_cursor_set_range(int n) {
assert
(
r
==
0
);
assert
(
r
==
0
);
}
}
void
test_brt_cursor_delete
(
int
n
)
{
printf
(
"test_brt_cursor_delete:%d
\n
"
,
n
);
int
error
;
char
fname
[]
=
"testbrt.brt"
;
CACHETABLE
ct
;
BRT
brt
;
BRT_CURSOR
cursor
;
unlink
(
fname
);
error
=
brt_create_cachetable
(
&
ct
,
0
);
assert
(
error
==
0
);
error
=
open_brt
(
fname
,
0
,
1
,
&
brt
,
1
<<
12
,
ct
,
default_compare_fun
);
assert
(
error
==
0
);
error
=
brt_cursor
(
brt
,
&
cursor
);
assert
(
error
==
0
);
DBT
key
,
val
;
int
k
,
v
;
int
i
;
/* insert keys 0, 1, 2, .. (n-1) */
for
(
i
=
0
;
i
<
n
;
i
++
)
{
k
=
htonl
(
i
);
v
=
i
;
fill_dbt
(
&
key
,
&
k
,
sizeof
k
);
fill_dbt
(
&
val
,
&
v
,
sizeof
v
);
error
=
brt_insert
(
brt
,
&
key
,
&
val
,
0
);
assert
(
error
==
0
);
}
/* walk the tree and delete under the cursor */
for
(;;)
{
init_dbt
(
&
key
);
key
.
flags
=
DB_DBT_MALLOC
;
init_dbt
(
&
val
);
val
.
flags
=
DB_DBT_MALLOC
;
error
=
brt_c_get
(
cursor
,
&
key
,
&
val
,
DB_NEXT
);
if
(
error
==
DB_NOTFOUND
)
break
;
assert
(
error
==
0
);
toku_free
(
key
.
data
);
toku_free
(
val
.
data
);
error
=
brt_cursor_delete
(
cursor
,
0
);
assert
(
error
==
0
);
}
error
=
brt_cursor_delete
(
cursor
,
0
);
assert
(
error
!=
0
);
error
=
brt_cursor_close
(
cursor
);
assert
(
error
==
0
);
error
=
close_brt
(
brt
);
assert
(
error
==
0
);
error
=
cachetable_close
(
&
ct
);
assert
(
error
==
0
);
}
int
test_brt_cursor_inc
=
1000
;
int
test_brt_cursor_inc
=
1000
;
int
test_brt_cursor_limit
=
10000
;
int
test_brt_cursor_limit
=
10000
;
...
@@ -1588,6 +1650,7 @@ void test_brt_cursor() {
...
@@ -1588,6 +1650,7 @@ void test_brt_cursor() {
test_brt_cursor_set
(
1000
,
DB_SET_RANGE
);
memory_check_all_free
();
test_brt_cursor_set
(
1000
,
DB_SET_RANGE
);
memory_check_all_free
();
test_brt_cursor_set_range
(
1000
);
memory_check_all_free
();
test_brt_cursor_set_range
(
1000
);
memory_check_all_free
();
test_brt_cursor_set_range
(
10000
);
memory_check_all_free
();
test_brt_cursor_set_range
(
10000
);
memory_check_all_free
();
test_brt_cursor_delete
(
1000
);
memory_check_all_free
();
}
}
void
test_large_kv
(
int
bsize
,
int
ksize
,
int
vsize
)
{
void
test_large_kv
(
int
bsize
,
int
ksize
,
int
vsize
)
{
...
@@ -1848,6 +1911,7 @@ void test_brt_delete() {
...
@@ -1848,6 +1911,7 @@ void test_brt_delete() {
static
void
brt_blackbox_test
(
void
)
{
static
void
brt_blackbox_test
(
void
)
{
memory_check
=
1
;
memory_check
=
1
;
test_wrongendian_compare
(
0
,
2
);
memory_check_all_free
();
test_wrongendian_compare
(
0
,
2
);
memory_check_all_free
();
test_wrongendian_compare
(
1
,
2
);
memory_check_all_free
();
test_wrongendian_compare
(
1
,
2
);
memory_check_all_free
();
test_wrongendian_compare
(
1
,
257
);
memory_check_all_free
();
test_wrongendian_compare
(
1
,
257
);
memory_check_all_free
();
...
...
newbrt/brt.c
View file @
204f68ed
...
@@ -2390,3 +2390,19 @@ int brt_c_get (BRT_CURSOR cursor, DBT *kbt, DBT *vbt, int flags) {
...
@@ -2390,3 +2390,19 @@ int brt_c_get (BRT_CURSOR cursor, DBT *kbt, DBT *vbt, int flags) {
if
((
r
=
unpin_brt_header
(
cursor
->
brt
))
!=
0
)
return
r
;
if
((
r
=
unpin_brt_header
(
cursor
->
brt
))
!=
0
)
return
r
;
return
0
;
return
0
;
}
}
int
brt_cursor_delete
(
BRT_CURSOR
cursor
,
int
flags
__attribute__
((
__unused__
)))
{
int
r
;
if
(
cursor
->
path_len
>
0
)
{
BRTNODE
node
=
cursor
->
path
[
cursor
->
path_len
-
1
];
assert
(
node
->
height
==
0
);
int
kvsize
;
r
=
pma_cursor_delete_under
(
cursor
->
pmacurs
,
&
kvsize
);
if
(
r
==
0
)
node
->
u
.
l
.
n_bytes_in_buffer
-=
KEY_VALUE_OVERHEAD
+
kvsize
;
}
else
r
=
DB_NOTFOUND
;
return
r
;
}
newbrt/brt.h
View file @
204f68ed
...
@@ -31,6 +31,7 @@ int show_brt_blocknumbers(BRT);
...
@@ -31,6 +31,7 @@ int show_brt_blocknumbers(BRT);
typedef
struct
brt_cursor
*
BRT_CURSOR
;
typedef
struct
brt_cursor
*
BRT_CURSOR
;
int
brt_cursor
(
BRT
,
BRT_CURSOR
*
);
int
brt_cursor
(
BRT
,
BRT_CURSOR
*
);
int
brt_c_get
(
BRT_CURSOR
cursor
,
DBT
*
kbt
,
DBT
*
vbt
,
int
brtc_flags
);
int
brt_c_get
(
BRT_CURSOR
cursor
,
DBT
*
kbt
,
DBT
*
vbt
,
int
brtc_flags
);
int
brt_cursor_delete
(
BRT_CURSOR
cursor
,
int
flags
);
int
brt_cursor_close
(
BRT_CURSOR
curs
);
int
brt_cursor_close
(
BRT_CURSOR
curs
);
#endif
#endif
newbrt/pma.c
View file @
204f68ed
...
@@ -489,6 +489,23 @@ int pma_cursor_set_range(PMA_CURSOR c, DBT *key, DB *db) {
...
@@ -489,6 +489,23 @@ int pma_cursor_set_range(PMA_CURSOR c, DBT *key, DB *db) {
return
DB_NOTFOUND
;
return
DB_NOTFOUND
;
}
}
int
pma_cursor_delete_under
(
PMA_CURSOR
c
,
int
*
kvsize
)
{
int
r
=
DB_NOTFOUND
;
if
(
c
->
position
>=
0
)
{
PMA
pma
=
c
->
pma
;
assert
(
c
->
position
<
pma
->
N
);
struct
kv_pair
*
kv
=
pma
->
pairs
[
c
->
position
];
if
(
kv_pair_valid
(
kv
))
{
if
(
kvsize
)
*
kvsize
=
kv_pair_keylen
(
kv
)
+
kv_pair_vallen
(
kv
);
pma
->
pairs
[
c
->
position
]
=
kv_pair_set_deleted
(
kv
);
r
=
0
;
}
}
return
r
;
}
#if 0
#if 0
int pma_cget_first (PMA_CURSOR c, YBT *key, YBT *val) {
int pma_cget_first (PMA_CURSOR c, YBT *key, YBT *val) {
PMA pma=c->pma;
PMA pma=c->pma;
...
...
newbrt/pma.h
View file @
204f68ed
...
@@ -90,21 +90,11 @@ int pma_cursor_set_key(PMA_CURSOR c, DBT *key, DB *db);
...
@@ -90,21 +90,11 @@ int pma_cursor_set_key(PMA_CURSOR c, DBT *key, DB *db);
/* set the cursor to the smallest key >= requested key */
/* set the cursor to the smallest key >= requested key */
int
pma_cursor_set_range
(
PMA_CURSOR
c
,
DBT
*
key
,
DB
*
db
);
int
pma_cursor_set_range
(
PMA_CURSOR
c
,
DBT
*
key
,
DB
*
db
);
/*
/* delete the key under the cursor */
* Get the last key and value in the pma
int
pma_cursor_delete_under
(
PMA_CURSOR
c
,
int
*
kvsize
);
*/
int
pma_get_last
(
PMA
pma
,
DBT
*
key
,
DBT
*
val
);
/* Return PMA_NOTFOUND if the pma is empty. */
/* get the last key and value in the pma */
#if 0
int
pma_get_last
(
PMA
pma
,
DBT
*
key
,
DBT
*
val
);
int pma_cget_first (PMA_CURSOR, YBT */*key*/, YBT */*val*/);
int pma_cursor_first (PMA);
int pma_cursor_last (PMA);
int pma_cursor_set (PMA, bytevec key, int keylen);
int pma_cursor_next (PMA);
int pma_cursor_prev (PMA);
int pma_cursor_get (PMA, bytevec *key, int *keylen, bytevec *data, int *datalen);
#endif
int
pma_random_pick
(
PMA
,
bytevec
*
key
,
ITEMLEN
*
keylen
,
bytevec
*
data
,
ITEMLEN
*
datalen
);
int
pma_random_pick
(
PMA
,
bytevec
*
key
,
ITEMLEN
*
keylen
,
bytevec
*
data
,
ITEMLEN
*
datalen
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment