Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dgraph
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
dgraph
Commits
70859515
Commit
70859515
authored
9 years ago
by
Ashwin
Browse files
Options
Downloads
Patches
Plain Diff
Made key and value generic (still to be done in merge.cc)
parent
0e23e858
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tools/merge/merge.cc
+3
-3
3 additions, 3 deletions
tools/merge/merge.cc
tools/merge/merge_heap.cc
+9
-9
9 additions, 9 deletions
tools/merge/merge_heap.cc
with
12 additions
and
12 deletions
tools/merge/merge.cc
+
3
−
3
View file @
70859515
...
...
@@ -64,12 +64,12 @@ int main(int argc, char* argv[]) {
rocksdb
::
Iterator
*
it
=
cur_db
->
NewIterator
(
rocksdb
::
ReadOptions
());
for
(
it
->
SeekToFirst
();
it
->
Valid
();
it
->
Next
())
{
std
::
string
key_s
=
it
->
key
()
.
ToString
()
;
std
::
string
val_s
=
it
->
value
()
.
ToString
()
;
Slice
key_s
=
it
->
key
();
Slice
val_s
=
it
->
value
();
std
::
string
val_t
;
Status
s
=
db
->
Get
(
ReadOptions
(),
key_s
,
&
val_t
);
if
(
s
.
ok
())
{
assert
(
val_t
==
val_s
&&
"Same key has different value"
);
assert
(
val_t
==
val_s
.
ToString
()
&&
"Same key has different value"
);
}
else
{
s
=
db
->
Put
(
WriteOptions
(),
key_s
,
val_s
);
assert
(
s
.
ok
());
...
...
This diff is collapsed.
Click to expand it.
tools/merge/merge_heap.cc
+
9
−
9
View file @
70859515
...
...
@@ -33,10 +33,10 @@ namespace fs = std::experimental::filesystem;
class
node
{
public:
std
::
string
key
;
std
::
string
value
;
Slice
key
;
Slice
value
;
int
idx
;
node
(
std
::
string
k
,
std
::
string
v
,
int
id
)
{
node
(
Slice
k
,
Slice
v
,
int
id
)
{
key
=
k
;
value
=
v
;
idx
=
id
;
...
...
@@ -46,14 +46,14 @@ public:
class
compare
{
public:
bool
operator
()(
node
&
a
,
node
&
b
)
{
return
a
.
key
<
b
.
key
;
return
a
.
key
.
compare
(
b
.
key
)
<=
0
;
}
};
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
3
)
{
std
::
cerr
<<
"Wrong number of arguments
\n
usage : ./<executable>\
<folder_having_rocksDB_directories_to_be_merged> <destination_folder>
\n
"
;
<folder_having_rocksDB_directories_to_be_merged> <destination_folder>
\n
"
;
exit
(
0
);
}
...
...
@@ -91,15 +91,15 @@ int main(int argc, char* argv[]) {
if
(
!
it
->
Valid
())
{
continue
;
}
struct
node
tnode
(
it
->
key
()
.
ToString
(),
it
->
value
().
ToString
(),
counter
++
);
struct
node
tnode
(
it
->
key
()
,
it
->
value
(),
counter
++
);
itVec
.
push_back
(
it
);
pq
.
push
(
tnode
);
}
std
::
string
lastKey
=
""
,
lastValue
=
""
;
Slice
lastKey
,
lastValue
;
while
(
!
pq
.
empty
())
{
struct
node
top
=
pq
.
top
();
const
struct
node
&
top
=
pq
.
top
();
pq
.
pop
();
if
(
top
.
key
==
lastKey
)
{
...
...
@@ -115,7 +115,7 @@ int main(int argc, char* argv[]) {
if
(
!
itVec
[
top
.
idx
]
->
Valid
())
{
continue
;
}
struct
node
tnode
(
itVec
[
top
.
idx
]
->
key
()
.
ToString
()
,
itVec
[
top
.
idx
]
->
value
()
.
ToString
()
,
top
.
idx
);
struct
node
tnode
(
itVec
[
top
.
idx
]
->
key
(),
itVec
[
top
.
idx
]
->
value
(),
top
.
idx
);
pq
.
push
(
tnode
);
}
...
...
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