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
30c35032
Commit
30c35032
authored
Aug 13, 2007
by
Bradley C. Kuszmaul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make it work with replace-or-insert
git-svn-id:
file:///svn/tokudb@114
c7de825b-a66e-492c-adef-691d508d4ae1
parent
b5d05c3f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
newbrt/brt.c
newbrt/brt.c
+4
-3
newbrt/pma.c
newbrt/pma.c
+2
-0
No files found.
newbrt/brt.c
View file @
30c35032
...
@@ -798,23 +798,24 @@ static int brtnode_maybe_push_down(BRT t, BRTNODE node, int *did_split, BRTNODE
...
@@ -798,23 +798,24 @@ static int brtnode_maybe_push_down(BRT t, BRTNODE node, int *did_split, BRTNODE
return
0
;
return
0
;
}
}
//
#define INSERT_ALL_AT_ONCE
#define INSERT_ALL_AT_ONCE
static
int
brt_leaf_insert
(
BRT
t
,
BRTNODE
node
,
DBT
*
k
,
DBT
*
v
,
static
int
brt_leaf_insert
(
BRT
t
,
BRTNODE
node
,
DBT
*
k
,
DBT
*
v
,
int
*
did_split
,
BRTNODE
*
nodea
,
BRTNODE
*
nodeb
,
DBT
*
splitk
,
int
*
did_split
,
BRTNODE
*
nodea
,
BRTNODE
*
nodeb
,
DBT
*
splitk
,
int
debug
,
int
debug
,
DB
*
db
)
{
DB
*
db
)
{
DBT
v2
;
#ifdef INSERT_ALL_AT_ONCE
#ifdef INSERT_ALL_AT_ONCE
int
replaced_v_size
;
int
replaced_v_size
;
enum
pma_errors
pma_status
=
pma_insert_or_replace
(
node
->
u
.
l
.
buffer
,
k
,
init_dbt
(
&
v2
)
,
db
,
&
replaced_v_size
);
enum
pma_errors
pma_status
=
pma_insert_or_replace
(
node
->
u
.
l
.
buffer
,
k
,
v
,
db
,
&
replaced_v_size
);
assert
(
pma_status
==
BRT_OK
);
assert
(
pma_status
==
BRT_OK
);
//printf("replaced_v_size=%d\n", replaced_v_size);
if
(
replaced_v_size
>=
0
)
{
if
(
replaced_v_size
>=
0
)
{
node
->
u
.
l
.
n_bytes_in_buffer
+=
v
->
size
-
replaced_v_size
;
node
->
u
.
l
.
n_bytes_in_buffer
+=
v
->
size
-
replaced_v_size
;
}
else
{
}
else
{
node
->
u
.
l
.
n_bytes_in_buffer
+=
k
->
size
+
v
->
size
+
KEY_VALUE_OVERHEAD
;
node
->
u
.
l
.
n_bytes_in_buffer
+=
k
->
size
+
v
->
size
+
KEY_VALUE_OVERHEAD
;
}
}
#else
#else
DBT
v2
;
enum
pma_errors
pma_status
=
pma_lookup
(
node
->
u
.
l
.
buffer
,
k
,
init_dbt
(
&
v2
),
db
);
enum
pma_errors
pma_status
=
pma_lookup
(
node
->
u
.
l
.
buffer
,
k
,
init_dbt
(
&
v2
),
db
);
if
(
pma_status
==
BRT_OK
)
{
if
(
pma_status
==
BRT_OK
)
{
pma_status
=
pma_delete
(
node
->
u
.
l
.
buffer
,
k
,
db
);
pma_status
=
pma_delete
(
node
->
u
.
l
.
buffer
,
k
,
db
);
...
...
newbrt/pma.c
View file @
30c35032
...
@@ -578,6 +578,7 @@ int pma_delete (PMA pma, DBT *k, DB *db) {
...
@@ -578,6 +578,7 @@ int pma_delete (PMA pma, DBT *k, DB *db) {
int
pma_insert_or_replace
(
PMA
pma
,
DBT
*
k
,
DBT
*
v
,
DB
*
db
,
int
pma_insert_or_replace
(
PMA
pma
,
DBT
*
k
,
DBT
*
v
,
DB
*
db
,
int
*
replaced_v_size
/* If it is a replacement, set to the size of the old value, otherwise set to -1. */
int
*
replaced_v_size
/* If it is a replacement, set to the size of the old value, otherwise set to -1. */
)
{
)
{
//printf("%s:%d v->size=%d\n", __FILE__, __LINE__, v->size);
int
idx
=
pmainternal_find
(
pma
,
k
,
db
);
int
idx
=
pmainternal_find
(
pma
,
k
,
db
);
struct
kv_pair
*
pair
;
struct
kv_pair
*
pair
;
if
(
idx
<
pma_index_limit
(
pma
)
&&
(
pair
=
pma
->
pairs
[
idx
]))
{
if
(
idx
<
pma_index_limit
(
pma
)
&&
(
pair
=
pma
->
pairs
[
idx
]))
{
...
@@ -592,6 +593,7 @@ int pma_insert_or_replace (PMA pma, DBT *k, DBT *v, DB *db,
...
@@ -592,6 +593,7 @@ int pma_insert_or_replace (PMA pma, DBT *k, DBT *v, DB *db,
idx
=
pmainternal_make_space_at
(
pma
,
idx
);
/* returns the new idx. */
idx
=
pmainternal_make_space_at
(
pma
,
idx
);
/* returns the new idx. */
}
}
assert
(
!
pma
->
pairs
[
idx
]);
assert
(
!
pma
->
pairs
[
idx
]);
//printf("%s:%d v->size=%d\n", __FILE__, __LINE__, v->size);
pma
->
pairs
[
idx
]
=
kv_pair_malloc
(
k
->
data
,
k
->
size
,
v
->
data
,
v
->
size
);
pma
->
pairs
[
idx
]
=
kv_pair_malloc
(
k
->
data
,
k
->
size
,
v
->
data
,
v
->
size
);
assert
(
pma
->
pairs
[
idx
]);
assert
(
pma
->
pairs
[
idx
]);
pma
->
n_pairs_present
++
;
pma
->
n_pairs_present
++
;
...
...
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