Skip to content

Commit 7c57d8f

Browse files
Denitsa Stoyanovadenitsa
andauthored
GraphDB: Refactor update queries and fix adding tags (#352)
* GraphDB: Update insert queries * GraphDB: Update queries * GraphDB: fix adding tags in update queries Co-authored-by: denitsa <[email protected]>
1 parent acb197d commit 7c57d8f

File tree

8 files changed

+25
-59
lines changed

8 files changed

+25
-59
lines changed

graphdb/queries/interactive-update-2.rq

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ PREFIX sn: <http://www.ldbc.eu/ldbc_socialnet/1.0/data/>
33
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
44
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
55

6-
INSERT {
6+
INSERT DATA {
77
sn:pers%personId% snvoc:likes _:bnode .
88
_:bnode snvoc:hasPost sn:post%postId% ;
99
snvoc:creationDate "%creationDate%"^^xsd:dateTime .
10-
} WHERE{
11-
sn:pers%personId% rdf:type snvoc:Person .
12-
sn:post%postId% rdf:type snvoc:Post .
13-
}
10+
}

graphdb/queries/interactive-update-3.rq

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ PREFIX snvoc: <http://www.ldbc.eu/ldbc_socialnet/1.0/vocabulary/>
22
PREFIX sn: <http://www.ldbc.eu/ldbc_socialnet/1.0/data/>
33
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
44
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
5-
INSERT {
5+
INSERT DATA {
66
sn:pers%personId% snvoc:likes _:likes .
77
_:likes snvoc:hasComment sn:comm%commentId% ;
88
snvoc:creationDate "%creationDate%"^^xsd:dateTime .
9-
} WHERE{
10-
sn:pers%personId% rdf:type snvoc:Person .
11-
sn:comm%commentId% rdf:type snvoc:Comment .
12-
}
9+
}

graphdb/queries/interactive-update-4-add-forum.rq

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ INSERT DATA{
77
sn:forum%subjectId% rdf:type snvoc:Forum ;
88
snvoc:id "%forumId%"^^xsd:long ;
99
snvoc:title "%forumTitle%" ;
10-
snvoc:creationDate "%creationDate%"^^xsd:dateTime .
11-
};
12-
INSERT {
13-
sn:forum%subjectId% snvoc:hasModerator sn:pers%moderatorPersonId% .
14-
} WHERE {
15-
sn:pers%moderatorPersonId% rdf:type snvoc:Person .
10+
snvoc:creationDate "%creationDate%"^^xsd:dateTime ;
11+
snvoc:hasModerator sn:pers%moderatorPersonId% .
1612
};

graphdb/queries/interactive-update-5.rq

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ PREFIX sn: <http://www.ldbc.eu/ldbc_socialnet/1.0/data/>
33
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
44
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
55

6-
INSERT {
6+
INSERT DATA {
77
sn:forum%forumId% snvoc:hasMember _:hasMember .
88
_:hasMember snvoc:hasPerson sn:pers%personId% ;
99
snvoc:joinDate "%joinDate%"^^xsd:dateTime .
10-
} WHERE{
11-
sn:pers%personId% rdf:type snvoc:Person .
12-
sn:forum%forumId% rdf:type snvoc:Forum .
13-
}
10+
}

graphdb/queries/interactive-update-6-add-post.rq

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,25 @@ PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
77
INSERT {
88
sn:post%subjectId% rdf:type snvoc:Post ;
99
snvoc:id "%postId%"^^xsd:long ;
10-
# snvoc:imageFile "%imageFile%" ;
1110
snvoc:creationDate "%creationDate%"^^xsd:dateTime ;
1211
snvoc:locationIP "%locationIP%" ;
1312
snvoc:browserUsed "%browserUsed%" ;
14-
# snvoc:content "%content%" ;
1513
snvoc:length "%length%"^^xsd:int ;
1614
snvoc:language "%language%" ;
17-
?imageOrContent ?data .
15+
?imageOrContent ?data ;
16+
snvoc:hasCreator sn:pers%authorPersonId% .
1817
} WHERE {
1918
BIND(IF("%imageFile%" != "", snvoc:imageFile, snvoc:content) AS ?imageOrContent) .
2019
BIND(IF("%imageFile%" != "", "%imageFile%", "%content%") AS ?data) .
2120
};
2221

22+
INSERT DATA {
23+
sn:forum%forumId% snvoc:containerOf sn:post%subjectId% .
24+
};
25+
2326
INSERT{
2427
sn:post%subjectId% snvoc:isLocatedIn ?country .
2528
} WHERE {
2629
?country rdf:type dbpedia-owl:Country .
2730
?country snvoc:id "%countryId%"^^xsd:int .
2831
};
29-
30-
INSERT{
31-
sn:post%subjectId% snvoc:hasCreator sn:pers%authorPersonId% .
32-
} WHERE {
33-
sn:pers%authorPersonId% rdf:type snvoc:Person .
34-
};
35-
36-
INSERT {
37-
sn:forum%forumId% snvoc:containerOf sn:post%subjectId% .
38-
} WHERE {
39-
sn:forum%forumId% rdf:type snvoc:Forum.
40-
};

graphdb/queries/interactive-update-7-add-comment.rq

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ INSERT DATA {
1111
snvoc:locationIP "%locationIP%" ;
1212
snvoc:browserUsed "%browserUsed%" ;
1313
snvoc:content "%content%" ;
14-
snvoc:length "%length%"^^xsd:int .
14+
snvoc:length "%length%"^^xsd:int ;
15+
snvoc:hasCreator sn:pers%authorPersonId% .
1516
};
1617

1718
INSERT {
@@ -22,20 +23,10 @@ INSERT {
2223
sn:post%replyToPostId%
2324
))
2425
AS ?commOrPost)
25-
BIND ((IF (%replyToPostId% = -1,
26-
snvoc:Comment,
27-
snvoc:Post
28-
)) AS ?type)
29-
?commOrPost rdf:type ?type .
3026
};
3127
INSERT{
3228
sn:comm%subjectId% snvoc:isLocatedIn ?country .
3329
} WHERE {
3430
?country rdf:type dbpedia-owl:Country .
3531
?country snvoc:id "%countryId%"^^xsd:int .
36-
};
37-
INSERT{
38-
sn:comm%subjectId% snvoc:hasCreator sn:pers%authorPersonId% .
39-
} WHERE {
40-
?person rdf:type snvoc:Person .
41-
}
32+
};

graphdb/queries/interactive-update-8.rq

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ PREFIX sn: <http://www.ldbc.eu/ldbc_socialnet/1.0/data/>
33
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
44
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
55

6-
INSERT {
6+
INSERT DATA {
77
sn:pers%person1Id% snvoc:knows _:knows .
88
_:knows snvoc:hasPerson sn:pers%person2Id% ;
99
snvoc:creationDate "%creationDate%"^^xsd:dateTime .
10-
} WHERE{
11-
sn:pers%person1Id% rdf:type snvoc:Person .
12-
sn:pers%person2Id% rdf:type snvoc:Person .
13-
}
10+
}

graphdb/src/main/java/com/ldbc/impls/workloads/ldbc/snb/graphdb/GraphDBQueryStore.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ SUBJECT_ID, getConverter().convertId(operation.getPersonId()),
109109
)
110110
));
111111
}
112-
convertTags(list, operation.getTagIds(), operation.getPersonId());
112+
convertTags(QueryType.InteractiveUpdate1AddPersonTags, list, operation.getTagIds(), operation.getPersonId());
113113
for (LdbcUpdate1AddPerson.Organization organization : operation.getStudyAt()) {
114114
list.add(prepare(
115115
QueryType.InteractiveUpdate1AddPersonUniversities,
@@ -136,7 +136,7 @@ LdbcUpdate4AddForum.MODERATOR_PERSON_ID, getConverter().convertId(operation.getM
136136
SUBJECT_ID, getConverter().convertId(operation.getForumId())
137137
)
138138
));
139-
convertTags(list, operation.getTagIds(), operation.getForumId());
139+
convertTags(QueryType.InteractiveUpdate4AddForumTags, list, operation.getTagIds(), operation.getForumId());
140140
return list;
141141
}
142142

@@ -160,7 +160,7 @@ public List<String> getUpdate6Multiple(LdbcUpdate6AddPost operation) {
160160
.build()
161161
)
162162
);
163-
convertTags(list, operation.getTagIds(), operation.getPostId());
163+
convertTags(QueryType.InteractiveUpdate6AddPostTags, list, operation.getTagIds(), operation.getPostId());
164164
return list;
165165
}
166166

@@ -183,14 +183,14 @@ public List<String> getUpdate7Multiple(LdbcUpdate7AddComment operation) {
183183
.put(SUBJECT_ID, getConverter().convertId(operation.getCommentId()))
184184
.build()
185185
));
186-
convertTags(list, operation.getTagIds(), operation.getCommentId());
186+
convertTags(QueryType.InteractiveUpdate7AddCommentTags, list, operation.getTagIds(), operation.getCommentId());
187187
return list;
188188
}
189189

190-
private void convertTags(List<String> list, List<Long> tags, long id) {
190+
private void convertTags(QueryType queryType, List<String> list, List<Long> tags, long id) {
191191
for (long tagId : tags) {
192192
list.add(prepare(
193-
QueryType.InteractiveUpdate7AddCommentTags,
193+
queryType,
194194
ImmutableMap.of(
195195
SUBJECT_ID, getConverter().convertId(id),
196196
"tagId", getConverter().convertIdForInsertion(tagId))

0 commit comments

Comments
 (0)