Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dgraph
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
c859f212
Commit
c859f212
authored
9 years ago
by
Manish R Jain
Browse files
Options
Downloads
Patches
Plain Diff
Going for lunch, working on Posting List buffer regeneration
parent
0b1ac864
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
posting/list.go
+58
-12
58 additions, 12 deletions
posting/list.go
posting/types.fbs
+1
-0
1 addition, 0 deletions
posting/types.fbs
with
59 additions
and
12 deletions
posting/list.go
+
58
−
12
View file @
c859f212
...
@@ -20,36 +20,39 @@ import (
...
@@ -20,36 +20,39 @@ import (
"github.com/google/flatbuffers/go"
"github.com/google/flatbuffers/go"
"github.com/manishrjain/dgraph/posting/types"
"github.com/manishrjain/dgraph/posting/types"
"github.com/manishrjain/dgraph/x"
"github.com/manishrjain/dgraph/x"
linked
"container/list"
)
)
var
log
=
x
.
Log
(
"posting"
)
type
mutation
struct
{
Set
types
.
Posting
Delete
types
.
Posting
}
type
List
struct
{
type
List
struct
{
TList
*
types
.
PostingList
TList
*
types
.
PostingList
buffer
[]
byte
mutations
[]
mutation
}
}
func
addTripleToPosting
(
b
*
flatbuffers
.
Builder
,
func
addTripleToPosting
(
b
*
flatbuffers
.
Builder
,
t
x
.
Triple
)
flatbuffers
.
UOffsetT
{
t
x
.
Triple
)
flatbuffers
.
UOffsetT
{
// Do this before posting start.
so
:=
b
.
CreateString
(
t
.
Source
)
// Do this before posting start.
so
:=
b
.
CreateString
(
t
.
Source
)
types
.
PostingStart
(
b
)
types
.
PostingStart
(
b
)
types
.
PostingAddUid
(
b
,
t
.
ValueId
)
types
.
PostingAddUid
(
b
,
t
.
ValueId
)
// so := b.CreateString(t.Source)
types
.
PostingAddSource
(
b
,
so
)
types
.
PostingAddSource
(
b
,
so
)
types
.
PostingAddTs
(
b
,
t
.
Timestamp
.
UnixNano
())
types
.
PostingAddTs
(
b
,
t
.
Timestamp
.
UnixNano
())
return
types
.
PostingEnd
(
b
)
return
types
.
PostingEnd
(
b
)
}
}
func
addPosting
(
b
*
flatbuffers
.
Builder
,
p
types
.
Posting
)
flatbuffers
.
UOffsetT
{
func
addPosting
(
b
*
flatbuffers
.
Builder
,
p
types
.
Posting
)
flatbuffers
.
UOffsetT
{
// Do this before posting start.
so
:=
b
.
CreateByteString
(
p
.
Source
())
// Do this before posting start.
so
:=
b
.
CreateByteString
(
p
.
Source
())
types
.
PostingStart
(
b
)
types
.
PostingStart
(
b
)
types
.
PostingAddUid
(
b
,
p
.
Uid
())
types
.
PostingAddUid
(
b
,
p
.
Uid
())
types
.
PostingAddSource
(
b
,
so
)
types
.
PostingAddSource
(
b
,
so
)
types
.
PostingAddTs
(
b
,
p
.
Ts
())
types
.
PostingAddTs
(
b
,
p
.
Ts
())
return
types
.
PostingEnd
(
b
)
return
types
.
PostingEnd
(
b
)
}
}
...
@@ -60,10 +63,52 @@ func (l *List) Init() {
...
@@ -60,10 +63,52 @@ func (l *List) Init() {
of
:=
types
.
PostingListEnd
(
b
)
of
:=
types
.
PostingListEnd
(
b
)
b
.
Finish
(
of
)
b
.
Finish
(
of
)
l
.
TList
=
types
.
GetRootAsPostingList
(
b
.
Bytes
,
b
.
Head
()
)
l
.
buffer
=
b
.
Bytes
[
b
.
Head
()
:
]
}
}
func
(
l
*
List
)
AddTriple
(
t
x
.
Triple
)
{
func
(
l
*
List
)
AddTriple
(
t
x
.
Triple
)
{
m
:=
mutation
{
Add
:
t
,
}
}
func
(
l
*
List
)
Remove
(
t
x
.
Triple
)
{
}
func
addOrSet
(
ll
*
linked
.
List
,
m
mutation
)
{
}
func
remove
(
ll
*
linked
.
List
,
m
mutation
)
{
e
:=
ll
.
Front
()
for
e
:=
ll
.
Front
();
e
!=
nil
;
e
=
e
.
Next
()
{
}
}
func
(
l
*
List
)
GenerateLinkedList
()
*
linked
.
List
{
plist
:=
types
.
GetRootAsPostingList
(
l
.
Buffer
,
0
)
ll
:=
linked
.
New
()
for
i
:=
0
;
i
<
plist
.
PostingsLength
();
i
++
{
p
:=
new
(
types
.
Posting
)
plist
.
Postings
(
p
,
i
)
ll
.
PushBack
(
p
)
}
// Now go through mutations
for
i
,
m
:=
range
l
.
mutations
{
if
m
.
Set
.
Ts
>
0
{
start
:=
ll
.
Front
}
else
if
m
.
Delete
.
Ts
>
0
{
}
else
{
log
.
Fatalf
(
"Strange mutation: %+v"
,
m
)
}
}
}
func
(
l
*
List
)
Commit
()
{
b
:=
flatbuffers
.
NewBuilder
(
0
)
b
:=
flatbuffers
.
NewBuilder
(
0
)
num
:=
l
.
TList
.
PostingsLength
()
num
:=
l
.
TList
.
PostingsLength
()
...
@@ -104,5 +149,6 @@ func (l *List) AddTriple(t x.Triple) {
...
@@ -104,5 +149,6 @@ func (l *List) AddTriple(t x.Triple) {
end
:=
types
.
PostingListEnd
(
b
)
end
:=
types
.
PostingListEnd
(
b
)
b
.
Finish
(
end
)
b
.
Finish
(
end
)
l
.
Buffer
=
b
.
Bytes
[
b
.
Head
()
:
]
l
.
TList
=
types
.
GetRootAsPostingList
(
b
.
Bytes
,
b
.
Head
())
l
.
TList
=
types
.
GetRootAsPostingList
(
b
.
Bytes
,
b
.
Head
())
}
}
This diff is collapsed.
Click to expand it.
posting/types.fbs
+
1
−
0
View file @
c859f212
...
@@ -8,6 +8,7 @@ table Posting {
...
@@ -8,6 +8,7 @@ table Posting {
table PostingList {
table PostingList {
postings:[Posting];
postings:[Posting];
value:[byte];
}
}
root_type PostingList;
root_type PostingList;
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