diff --git a/posting/list.go b/posting/list.go index e0cd79927ffef1c5100906d92107666498b6bf2c..8c0a9d0a39663ef76964e001de875dffa5805760 100644 --- a/posting/list.go +++ b/posting/list.go @@ -76,8 +76,8 @@ func Key(uid uint64, attr string) []byte { return buf.Bytes() } -func addTripleToPosting(b *flatbuffers.Builder, - t x.Triple, op byte) flatbuffers.UOffsetT { +func addEdgeToPosting(b *flatbuffers.Builder, + t x.DirectedEdge, op byte) flatbuffers.UOffsetT { var bo flatbuffers.UOffsetT if t.Value != nil { @@ -405,19 +405,19 @@ func (l *List) generateIndex() { } func (l *List) addIfValid(b *flatbuffers.Builder, - offsets *[]flatbuffers.UOffsetT, t x.Triple, op byte) { + offsets *[]flatbuffers.UOffsetT, t x.DirectedEdge, op byte) { if op == Del { if fi := l.find(t.ValueId); fi >= 0 { // Delete. Only add it to the list if it exists in the posting list. - *offsets = append(*offsets, addTripleToPosting(b, t, op)) + *offsets = append(*offsets, addEdgeToPosting(b, t, op)) } } else { - *offsets = append(*offsets, addTripleToPosting(b, t, op)) + *offsets = append(*offsets, addEdgeToPosting(b, t, op)) } } -func (l *List) AddMutation(t x.Triple, op byte) error { +func (l *List) AddMutation(t x.DirectedEdge, op byte) error { l.mutex.Lock() defer l.mutex.Unlock() @@ -428,7 +428,7 @@ func (l *List) AddMutation(t x.Triple, op byte) error { // - If yes, store the mutation. // - If no, disregard this mutation. - // All triples with a value set, have the same uid. In other words, + // All edges with a value set, have the same uid. In other words, // an (entity, attribute) can only have one interface{} value. if t.Value != nil { t.ValueId = math.MaxUint64 diff --git a/posting/list_test.go b/posting/list_test.go index c6c1dee3f8a7ff2ab429c7c66689e295d7978afd..2d6fe2d3463144837e67f5c68724b62aa9caad41 100644 --- a/posting/list_test.go +++ b/posting/list_test.go @@ -70,12 +70,12 @@ func TestAddMutation(t *testing.T) { l.init(key, ps, ms) - triple := x.Triple{ + edge := x.DirectedEdge{ ValueId: 9, Source: "testing", Timestamp: time.Now(), } - if err := l.AddMutation(triple, Set); err != nil { + if err := l.AddMutation(edge, Set); err != nil { t.Error(err) } /* @@ -100,9 +100,9 @@ func TestAddMutation(t *testing.T) { } // return // Test 1. - // Add another triple now. - triple.ValueId = 81 - l.AddMutation(triple, Set) + // Add another edge now. + edge.ValueId = 81 + l.AddMutation(edge, Set) // l.CommitIfDirty() if l.Length() != 2 { t.Errorf("Length: %d", l.Length()) @@ -122,12 +122,12 @@ func TestAddMutation(t *testing.T) { } // return // Test 2. - // Add another triple, in between the two above. + // Add another edge, in between the two above. uids := []uint64{ 9, 49, 81, } - triple.ValueId = 49 - if err := l.AddMutation(triple, Set); err != nil { + edge.ValueId = 49 + if err := l.AddMutation(edge, Set); err != nil { t.Error(err) } /* @@ -140,20 +140,20 @@ func TestAddMutation(t *testing.T) { } // return // Test 3. - // Delete a triple, add a triple, replace a triple - triple.ValueId = 49 - if err := l.AddMutation(triple, Del); err != nil { + // Delete an edge, add an edge, replace an edge + edge.ValueId = 49 + if err := l.AddMutation(edge, Del); err != nil { t.Error(err) } - triple.ValueId = 69 - if err := l.AddMutation(triple, Set); err != nil { + edge.ValueId = 69 + if err := l.AddMutation(edge, Set); err != nil { t.Error(err) } - triple.ValueId = 9 - triple.Source = "anti-testing" - if err := l.AddMutation(triple, Set); err != nil { + edge.ValueId = 9 + edge.Source = "anti-testing" + if err := l.AddMutation(edge, Set); err != nil { t.Error(err) } /* @@ -207,12 +207,12 @@ func TestAddMutation_Value(t *testing.T) { ol.init(key, ps, ms) - triple := x.Triple{ + edge := x.DirectedEdge{ Value: "oh hey there", Source: "new-testing", Timestamp: time.Now(), } - if err := ol.AddMutation(triple, Set); err != nil { + if err := ol.AddMutation(edge, Set); err != nil { t.Error(err) } var p types.Posting @@ -246,8 +246,8 @@ func TestAddMutation_Value(t *testing.T) { } // The value made it to the posting list. Changing it now. - triple.Value = 119 - if err := ol.AddMutation(triple, Set); err != nil { + edge.Value = 119 + if err := ol.AddMutation(edge, Set); err != nil { t.Error(err) } if ol.Length() != 1 { diff --git a/posting/worker_test.go b/posting/worker_test.go index 9ed5ba1d071829aa2c3a18ca06656433c6cdc993..6412feaef2d022204d87c45742e0efa3858cd596 100644 --- a/posting/worker_test.go +++ b/posting/worker_test.go @@ -62,8 +62,8 @@ func TestPush(t *testing.T) { } } -func addTriple(t *testing.T, triple x.Triple, l *List) { - if err := l.AddMutation(triple, Set); err != nil { +func addEdge(t *testing.T, edge x.DirectedEdge, l *List) { + if err := l.AddMutation(edge, Set); err != nil { t.Error(err) } } @@ -82,27 +82,27 @@ func TestProcessTask(t *testing.T) { ms.Init(mdir) Init(ps, ms) - triple := x.Triple{ + edge := x.DirectedEdge{ ValueId: 23, Source: "author0", Timestamp: time.Now(), } - addTriple(t, triple, Get(Key(10, "friend"))) - addTriple(t, triple, Get(Key(11, "friend"))) - addTriple(t, triple, Get(Key(12, "friend"))) + addEdge(t, edge, Get(Key(10, "friend"))) + addEdge(t, edge, Get(Key(11, "friend"))) + addEdge(t, edge, Get(Key(12, "friend"))) - triple.ValueId = 25 - addTriple(t, triple, Get(Key(12, "friend"))) + edge.ValueId = 25 + addEdge(t, edge, Get(Key(12, "friend"))) - triple.ValueId = 26 - addTriple(t, triple, Get(Key(12, "friend"))) + edge.ValueId = 26 + addEdge(t, edge, Get(Key(12, "friend"))) - triple.ValueId = 31 - addTriple(t, triple, Get(Key(10, "friend"))) - addTriple(t, triple, Get(Key(12, "friend"))) + edge.ValueId = 31 + addEdge(t, edge, Get(Key(10, "friend"))) + addEdge(t, edge, Get(Key(12, "friend"))) - triple.Value = "photon" - addTriple(t, triple, Get(Key(12, "friend"))) + edge.Value = "photon" + addEdge(t, edge, Get(Key(12, "friend"))) query := NewQuery("friend", []uint64{10, 11, 12}) result, err := ProcessTask(query) diff --git a/query/query_test.go b/query/query_test.go index 6efd9a8deb3089e8208c71241ba224e9b1bdecec..9a6e26d134c358882eeffea25011e2ea1535260f 100644 --- a/query/query_test.go +++ b/query/query_test.go @@ -41,7 +41,7 @@ func setErr(err *error, nerr error) { func populateList(key []byte) error { pl := posting.Get(key) - t := x.Triple{ + t := x.DirectedEdge{ ValueId: 9, Source: "query_test", Timestamp: time.Now(), @@ -126,8 +126,8 @@ func NewStore(t *testing.T) string { return path } -func addTriple(t *testing.T, triple x.Triple, l *posting.List) { - if err := l.AddMutation(triple, posting.Set); err != nil { +func addEdge(t *testing.T, edge x.DirectedEdge, l *posting.List) { + if err := l.AddMutation(edge, posting.Set); err != nil { t.Error(err) } } @@ -179,47 +179,47 @@ func TestProcessGraph(t *testing.T) { // So, user we're interested in has uid: 1. // She has 4 friends: 23, 24, 25, 31, and 101 - triple := x.Triple{ + edge := x.DirectedEdge{ ValueId: 23, Source: "testing", Timestamp: time.Now(), } - addTriple(t, triple, posting.Get(posting.Key(1, "friend"))) + addEdge(t, edge, posting.Get(posting.Key(1, "friend"))) - triple.ValueId = 24 - addTriple(t, triple, posting.Get(posting.Key(1, "friend"))) + edge.ValueId = 24 + addEdge(t, edge, posting.Get(posting.Key(1, "friend"))) - triple.ValueId = 25 - addTriple(t, triple, posting.Get(posting.Key(1, "friend"))) + edge.ValueId = 25 + addEdge(t, edge, posting.Get(posting.Key(1, "friend"))) - triple.ValueId = 31 - addTriple(t, triple, posting.Get(posting.Key(1, "friend"))) + edge.ValueId = 31 + addEdge(t, edge, posting.Get(posting.Key(1, "friend"))) - triple.ValueId = 101 - addTriple(t, triple, posting.Get(posting.Key(1, "friend"))) + edge.ValueId = 101 + addEdge(t, edge, posting.Get(posting.Key(1, "friend"))) // Now let's add a few properties for the main user. - triple.Value = "Michonne" - addTriple(t, triple, posting.Get(posting.Key(1, "name"))) + edge.Value = "Michonne" + addEdge(t, edge, posting.Get(posting.Key(1, "name"))) - triple.Value = "female" - addTriple(t, triple, posting.Get(posting.Key(1, "gender"))) + edge.Value = "female" + addEdge(t, edge, posting.Get(posting.Key(1, "gender"))) - triple.Value = "alive" - addTriple(t, triple, posting.Get(posting.Key(1, "status"))) + edge.Value = "alive" + addEdge(t, edge, posting.Get(posting.Key(1, "status"))) // Now let's add a name for each of the friends, except 101. - triple.Value = "Rick Grimes" - addTriple(t, triple, posting.Get(posting.Key(23, "name"))) + edge.Value = "Rick Grimes" + addEdge(t, edge, posting.Get(posting.Key(23, "name"))) - triple.Value = "Glenn Rhee" - addTriple(t, triple, posting.Get(posting.Key(24, "name"))) + edge.Value = "Glenn Rhee" + addEdge(t, edge, posting.Get(posting.Key(24, "name"))) - triple.Value = "Daryl Dixon" - addTriple(t, triple, posting.Get(posting.Key(25, "name"))) + edge.Value = "Daryl Dixon" + addEdge(t, edge, posting.Get(posting.Key(25, "name"))) - triple.Value = "Andrea" - addTriple(t, triple, posting.Get(posting.Key(31, "name"))) + edge.Value = "Andrea" + addEdge(t, edge, posting.Get(posting.Key(31, "name"))) // Alright. Now we have everything set up. Let's create the query. sg, err := NewGraph(1, "") diff --git a/rdf/parse_test.go b/rdf/parse_test.go index 50a8741f75aff7cbcbf140ec73bec1ab83c248ef..af2433e3f2f0b1ddf9af4def3baae0cbaeb335b7 100644 --- a/rdf/parse_test.go +++ b/rdf/parse_test.go @@ -82,12 +82,12 @@ var testNQuads = []struct { }, }, { - input: `<http://www.w3.org/2001/sw/RDFCore/ntriples/> <http://purl.org/dc/terms/title> "N-Triples"@en-US .`, + input: `<http://www.w3.org/2001/sw/RDFCore/nedges/> <http://purl.org/dc/terms/title> "N-Edges"@en-US .`, nq: NQuad{ - Subject: "http://www.w3.org/2001/sw/RDFCore/ntriples/", + Subject: "http://www.w3.org/2001/sw/RDFCore/nedges/", Predicate: "http://purl.org/dc/terms/title", ObjectId: "", - ObjectValue: "N-Triples", + ObjectValue: "N-Edges", Language: "en-US", }, }, diff --git a/uid/assigner.go b/uid/assigner.go index 9c61a86057550e101a87e8fc7b6423097df2ca83..38f91cc61d050a1368a812714e07c00457f8d921 100644 --- a/uid/assigner.go +++ b/uid/assigner.go @@ -56,7 +56,7 @@ func allocateNew(xid string) (uid uint64, rerr error) { } // Uid hasn't been assigned yet. - t := x.Triple{ + t := x.DirectedEdge{ Value: xid, // not txid Source: "_assigner_", Timestamp: time.Now(), @@ -92,7 +92,7 @@ func GetOrAssign(xid string) (uid uint64, rerr error) { if err != nil { return 0, err } - t := x.Triple{ + t := x.DirectedEdge{ ValueId: uid, Source: "_assigner_", Timestamp: time.Now(), diff --git a/x/x.go b/x/x.go index 66da0a6214674345f837e6a1ba377ad7459d5e48..8c1a87d80915d14156ea20e6013b09e137d0ecc0 100644 --- a/x/x.go +++ b/x/x.go @@ -28,7 +28,7 @@ type Status struct { Message string `json:"message"` } -type Triple struct { +type DirectedEdge struct { Entity uint64 EntityEid string Attribute string