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
d15c1f56
Commit
d15c1f56
authored
9 years ago
by
Ashwin
Browse files
Options
Downloads
Patches
Plain Diff
removed index field in heap
parent
dfae5ca1
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/rocksmerge
+0
-0
0 additions, 0 deletions
tools/merge/rocksmerge
tools/merge/rocksmerge.go
+22
-32
22 additions, 32 deletions
tools/merge/rocksmerge.go
with
22 additions
and
32 deletions
tools/merge/rocksmerge
deleted
100755 → 0
+
0
−
0
View file @
dfae5ca1
File deleted
This diff is collapsed.
Click to expand it.
tools/merge/rocksmerge.go
+
22
−
32
View file @
d15c1f56
...
...
@@ -29,14 +29,14 @@ import (
type
Item
struct
{
key
,
value
[]
byte
itIdx
int
index
int
storeIdx
int
}
type
PriorityQueue
[]
*
Item
var
stores
=
flag
.
String
(
"stores"
,
""
,
"Folder containing rocksDB directories"
)
var
destinationDB
=
flag
.
String
(
"destination"
,
""
,
var
stores
=
flag
.
String
(
"stores"
,
""
,
"Root directory containing rocksDB directories"
)
var
destinationDB
=
flag
.
String
(
"dest"
,
""
,
"Folder to store merged rocksDB"
)
var
glog
=
x
.
Log
(
"rocksmerge"
)
...
...
@@ -44,23 +44,17 @@ var glog = x.Log("rocksmerge")
func
(
pq
PriorityQueue
)
Len
()
int
{
return
len
(
pq
)
}
func
(
pq
PriorityQueue
)
Swap
(
i
,
j
int
)
{
pq
[
i
],
pq
[
j
]
=
pq
[
j
],
pq
[
i
]
pq
[
i
]
.
index
=
i
pq
[
j
]
.
index
=
j
}
func
(
pq
PriorityQueue
)
Less
(
i
,
j
int
)
bool
{
return
(
bytes
.
Compare
(
pq
[
i
]
.
key
,
pq
[
j
]
.
key
)
<=
0
)
return
bytes
.
Compare
(
pq
[
i
]
.
key
,
pq
[
j
]
.
key
)
<=
0
}
func
(
pq
*
PriorityQueue
)
Push
(
y
interface
{})
{
n
:=
len
(
*
pq
)
item
:=
y
.
(
*
Item
)
item
.
index
=
n
*
pq
=
append
(
*
pq
,
item
)
*
pq
=
append
(
*
pq
,
y
.
(
*
Item
))
}
func
(
pq
*
PriorityQueue
)
Pop
()
interface
{}
{
old
:=
*
pq
n
:=
len
(
old
)
item
:=
old
[
n
-
1
]
item
.
index
=
-
1
// for safety
*
pq
=
old
[
0
:
n
-
1
]
return
item
}
...
...
@@ -80,25 +74,20 @@ func main() {
var
wopt
*
rocksdb
.
WriteOptions
opt
=
rocksdb
.
NewOptions
()
opt
.
SetCreateIfMissing
(
true
)
fp
:=
rocksdb
.
NewBloomFilter
(
16
)
opt
.
SetFilterPolicy
(
fp
)
ropt
=
rocksdb
.
NewReadOptions
()
wopt
=
rocksdb
.
NewWriteOptions
()
wopt
.
SetSync
(
true
)
var
itVec
[]
*
rocksdb
.
Iterator
var
db
*
rocksdb
.
DB
var
lastKey
,
lastValue
[]
byte
count
:=
0
for
range
files
{
count
++
}
pq
:=
make
(
PriorityQueue
,
count
)
i
:=
0
for
_
,
f
:=
range
files
{
pq
:=
make
(
PriorityQueue
,
count
)
var
itVec
[]
*
rocksdb
.
Iterator
for
i
,
f
:=
range
files
{
curDb
,
err
:=
rocksdb
.
Open
(
*
stores
+
f
.
Name
(),
opt
)
defer
curDb
.
Close
()
if
err
!=
nil
{
glog
.
WithField
(
"filepath"
,
*
stores
+
f
.
Name
())
.
Fatal
(
"While opening store"
)
...
...
@@ -109,27 +98,29 @@ func main() {
continue
}
pq
[
i
]
=
&
Item
{
key
:
it
.
Key
(),
value
:
it
.
Value
(),
itIdx
:
i
,
index
:
i
,
key
:
it
.
Key
(),
value
:
it
.
Value
(),
storeIdx
:
i
,
}
i
++
itVec
=
append
(
itVec
,
it
)
}
heap
.
Init
(
&
pq
)
var
db
*
rocksdb
.
DB
db
,
err
=
rocksdb
.
Open
(
*
destinationDB
,
opt
)
defer
db
.
Close
()
if
err
!=
nil
{
glog
.
WithField
(
"filepath"
,
*
destinationDB
)
.
Fatal
(
"While opening store"
)
}
var
lastKey
,
lastValue
[]
byte
for
pq
.
Len
()
>
0
{
top
:=
heap
.
Pop
(
&
pq
)
.
(
*
Item
)
if
bytes
.
Compare
(
top
.
key
,
lastKey
)
==
0
{
if
bytes
.
Compare
(
top
.
value
,
lastValue
)
!=
0
{
// TODO::value comparison considering timestamps
glog
.
Fatalf
(
"different value for same key %s"
,
lastKey
)
}
}
else
{
...
...
@@ -138,16 +129,15 @@ func main() {
lastValue
=
top
.
value
}
itVec
[
top
.
it
Idx
]
.
Next
()
if
!
itVec
[
top
.
it
Idx
]
.
Valid
()
{
itVec
[
top
.
store
Idx
]
.
Next
()
if
!
itVec
[
top
.
store
Idx
]
.
Valid
()
{
continue
}
item
:=
&
Item
{
key
:
itVec
[
top
.
it
Idx
]
.
Key
(),
value
:
itVec
[
top
.
it
Idx
]
.
Value
(),
it
Idx
:
top
.
it
Idx
,
key
:
itVec
[
top
.
store
Idx
]
.
Key
(),
value
:
itVec
[
top
.
store
Idx
]
.
Value
(),
store
Idx
:
top
.
store
Idx
,
}
heap
.
Push
(
&
pq
,
item
)
}
db
.
Close
()
}
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