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
03ea974a
Commit
03ea974a
authored
Nov 16, 2007
by
Rich Prohaska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
build the dupsort split key
git-svn-id:
file:///svn/tokudb@605
c7de825b-a66e-492c-adef-691d508d4ae1
parent
f0dc1356
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
11 deletions
+33
-11
newbrt/pma.c
newbrt/pma.c
+31
-11
newbrt/pma.h
newbrt/pma.h
+2
-0
No files found.
newbrt/pma.c
View file @
03ea974a
...
...
@@ -63,6 +63,8 @@ static void __pma_delete_resume(PMA pma, int here);
*/
static
int
__pma_count_cursor_refs
(
PMA
pma
,
int
here
);
static
int
__pma_compare_kv
(
PMA
pma
,
struct
kv_pair
*
a
,
struct
kv_pair
*
b
,
DB
*
db
);
/**************************** end of static functions forward declarations. *********************/
...
...
@@ -614,6 +616,11 @@ static int __pma_resize_array(PMA pma, int asksize, int startz) {
return
0
;
}
int
pma_set_compare
(
PMA
pma
,
pma_compare_fun_t
compare_fun
)
{
pma
->
compare_fun
=
compare_fun
;
return
0
;
}
int
pma_set_dup_mode
(
PMA
pma
,
int
dup_mode
)
{
assert
(
dup_mode
==
0
||
dup_mode
==
DB_DUP
||
dup_mode
==
(
DB_DUP
+
DB_DUPSORT
));
pma
->
dup_mode
=
dup_mode
;
...
...
@@ -1291,6 +1298,15 @@ static void __pma_relocate_kvpairs(PMA pma) {
#endif
static
int
__pma_compare_kv
(
PMA
pma
,
struct
kv_pair
*
a
,
struct
kv_pair
*
b
,
DB
*
db
)
{
DBT
dbta
,
dbtb
;
int
cmp
=
pma
->
compare_fun
(
db
,
fill_dbt
(
&
dbta
,
kv_pair_key
(
a
),
kv_pair_keylen
(
a
)),
fill_dbt
(
&
dbtb
,
kv_pair_key
(
b
),
kv_pair_keylen
(
b
)));
if
(
cmp
==
0
&&
(
pma
->
dup_mode
&
DB_DUPSORT
))
{
cmp
=
pma
->
dup_compare_fun
(
db
,
fill_dbt
(
&
dbta
,
kv_pair_val
(
a
),
kv_pair_vallen
(
b
)),
fill_dbt
(
&
dbtb
,
kv_pair_val
(
b
),
kv_pair_vallen
(
b
)));
}
return
cmp
;
}
int
pma_split
(
PMA
origpma
,
unsigned
int
*
origpma_size
,
DBT
*
splitk
,
DB
*
db
,
PMA
leftpma
,
unsigned
int
*
leftpma_size
,
u_int32_t
leftrand4fp
,
u_int32_t
*
leftfingerprint
,
PMA
rightpma
,
unsigned
int
*
rightpma_size
,
u_int32_t
rightrand4fp
,
u_int32_t
*
rightfingerprint
)
{
...
...
@@ -1363,18 +1379,22 @@ int pma_split(PMA origpma, unsigned int *origpma_size, DBT *splitk, DB *db,
}
if
(
splitk
)
{
struct
kv_pair
*
kv
=
pairs
[
spliti
-
1
].
pair
;
assert
(
kv_pair_valid
(
kv
));
splitk
->
size
=
kv_pair_keylen
(
kv
);
splitk
->
data
=
memdup
(
kv_pair_key
(
kv
),
splitk
->
size
);
struct
kv_pair
*
a
=
pairs
[
spliti
-
1
].
pair
;
if
(
origpma
->
dup_mode
&
DB_DUPSORT
)
{
int
kl
=
kv_pair_keylen
(
a
);
int
vl
=
kv_pair_vallen
(
a
);
splitk
->
size
=
(
sizeof
vl
)
+
kl
+
vl
;
splitk
->
data
=
toku_malloc
(
splitk
->
size
);
memcpy
(
splitk
->
data
,
&
vl
,
sizeof
vl
);
memcpy
(
splitk
->
data
+
(
sizeof
vl
),
kv_pair_key
(
a
),
kl
);
memcpy
(
splitk
->
data
+
(
sizeof
vl
)
+
kl
,
kv_pair_val
(
a
),
vl
);
}
else
{
splitk
->
size
=
kv_pair_keylen
(
a
);
splitk
->
data
=
memdup
(
kv_pair_key
(
a
),
splitk
->
size
);
}
splitk
->
flags
=
BRT_PIVOT_PRESENT_L
;
if
(
spliti
<
npairs
)
{
kv
=
pairs
[
spliti
].
pair
;
DBT
k2
;
int
cmp
=
origpma
->
compare_fun
(
db
,
splitk
,
fill_dbt
(
&
k2
,
kv_pair_key
(
kv
),
kv_pair_keylen
(
kv
)));
if
(
cmp
==
0
)
{
splitk
->
flags
+=
BRT_PIVOT_PRESENT_R
;
}
if
(
spliti
<
npairs
&&
__pma_compare_kv
(
origpma
,
a
,
pairs
[
spliti
].
pair
,
db
)
==
0
)
{
splitk
->
flags
+=
BRT_PIVOT_PRESENT_R
;
}
}
...
...
newbrt/pma.h
View file @
03ea974a
...
...
@@ -21,6 +21,8 @@ typedef int (*pma_compare_fun_t)(DB *, const DBT *a, const DBT *b);
int
pma_create
(
PMA
*
,
pma_compare_fun_t
compare_fun
,
int
maxsize
);
int
pma_set_compare
(
PMA
pma
,
pma_compare_fun_t
compare_fun
);
/* set the duplicate mode
0 -> no duplications, DB_DUP, DB_DUPSORT */
int
pma_set_dup_mode
(
PMA
pma
,
int
mode
);
...
...
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