Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions maven-projects/info/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
<version>${spotless-maven-plugin.version}</version>
<configuration>
<java>
<!--<includes>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remember to delete this line

<include>
src/test/java/org/apache/graphar/info/GraphInfoTest.java
</include>
</includes>-->
<googleJavaFormat>
<version>1.7</version>
<style>AOSP</style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,45 @@ public Optional<GraphInfo> addVertexAsNew(VertexInfo vertexInfo) {
edgeConcat2EdgeInfo));
}

public Optional<GraphInfo> removeVertex(VertexInfo vertexInfo) {

if (vertexInfo == null || !hasVertexInfo(vertexInfo.getType())) {
return Optional.empty();
}
List<EdgeInfo> newCachedEdgeInfoList =
edgeInfos.stream()
.filter(
currEdge ->
!currEdge.getSrcType().equals(vertexInfo.getType())
&& !currEdge.getDstType()
.equals(vertexInfo.getType()))
.collect(Collectors.toList());

final List<VertexInfo> newVertexInfoList =
vertexInfos.stream()
.filter(
v ->
!v.getType().equals(vertexInfo.getType())
&& !v.getPrefix().equals(vertexInfo.getPrefix()))
.collect(Collectors.toList());

final Map<String, VertexInfo> newVertexInfoMap =
vertexType2VertexInfo.entrySet().stream()
.filter(v -> !v.getValue().getType().equals(vertexInfo.getType()))
.collect(
Collectors.toUnmodifiableMap(
Map.Entry::getKey, Map.Entry::getValue));
return Optional.of(
new GraphInfo(
name,
newVertexInfoList,
newCachedEdgeInfoList,
baseUri,
version,
newVertexInfoMap,
edgeConcat2EdgeInfo));
}

public Optional<GraphInfo> addEdgeAsNew(EdgeInfo edgeInfo) {
if (edgeInfo == null
|| hasEdgeInfo(
Expand All @@ -162,6 +201,39 @@ public Optional<GraphInfo> addEdgeAsNew(EdgeInfo edgeInfo) {
newEdgeConcat2EdgeInfo));
}

public Optional<GraphInfo> removeEdge(EdgeInfo edgeInfo) {
if (edgeInfo == null
|| hasEdgeInfo(
edgeInfo.getSrcType(), edgeInfo.getEdgeType(), edgeInfo.getDstType())) {
return Optional.empty();
}
final List<EdgeInfo> newEdgeInfos =
edgeInfos.stream()
.filter(
e ->
!(e.getSrcType().equals(edgeInfo.getSrcType())
&& e.getDstType().equals(edgeInfo.getDstType())
&& e.getEdgeType().equals(edgeInfo.getEdgeType())))
.collect(Collectors.toList());

final Map<String, EdgeInfo> newEdgeConcat2EdgeInfo =
edgeConcat2EdgeInfo.entrySet().stream()
.filter(e -> !e.getKey().equals(edgeInfo.getConcat()))
.filter(e -> !e.getValue().getConcat().equals(edgeInfo.getConcat()))
.collect(
Collectors.toUnmodifiableMap(
Map.Entry::getKey, Map.Entry::getValue));
return Optional.of(
new GraphInfo(
name,
vertexInfos,
newEdgeInfos,
baseUri,
version,
vertexType2VertexInfo,
newEdgeConcat2EdgeInfo));
}

public boolean hasVertexInfo(String type) {
return vertexType2VertexInfo.containsKey(type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ public void testGraphInfoBasics() {
illegalArgumentException.getMessage());
// test version gar/v1
Assert.assertEquals(1, graphInfo.getVersion().getVersion());
// basic tests for addVertex and removeVertex (more advanced ones should include adjancency
// list checks)
VertexInfo testingVertexInfo =
new VertexInfo("", 100, Arrays.asList(TestUtil.pg1), "vertex/person/", "gar/v1");
GraphInfo testingGraphInfo =
new GraphInfo("graphTest", new ArrayList<>(), new ArrayList<>(), "", "");
// add the created vertex on an empty graph
Assert.assertEquals(
1,
testingGraphInfo.addVertexAsNew(testingVertexInfo).get().getVertexInfos().size());
// remove the newly created vertex and check again the emptied graph
Assert.assertEquals(true, testingGraphInfo.removeVertex(testingVertexInfo).isEmpty());
// TODO (same tests as vertices for edges)
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion testing
Submodule testing updated 85 files
+1 −1 .asf.yaml
+14 −7 java/ldbc_sample/csv/person_knows_person.edge.yml
+14 −7 java/ldbc_sample/orc/person_knows_person.edge.yml
+18 −6 java/ldbc_sample/parquet/person_knows_person.edge.yml
+0 −1 ldbc/parquet/ldbc.graph.yml
+0 −35 ldbc/parquet/person.vertex.yml
+ ldbc/parquet/vertex/person/emails/chunk0
+ ldbc/parquet/vertex/person/emails/chunk1
+ ldbc/parquet/vertex/person/firstName_lastName_gender/chunk0
+ ldbc/parquet/vertex/person/firstName_lastName_gender/chunk1
+ ldbc/parquet/vertex/person/id/chunk0
+ ldbc/parquet/vertex/person/id/chunk1
+ ldbc/parquet/vertex/person/locationIP_browserUsed/chunk0
+ ldbc/parquet/vertex/person/locationIP_browserUsed/chunk1
+ ldbc/parquet/vertex/person/vertex_count
+0 −6 ldbc/person.vertex.yml
+0 −1,529 ldbc/person_0_0.csv
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-date/part0/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-date/part1/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-date/part2/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-date/part3/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-date/part4/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-date/part5/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-date/part6/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-date/part7/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-date/part8/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-date/part9/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-timestamp/part0/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-timestamp/part1/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-timestamp/part2/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-timestamp/part3/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-timestamp/part4/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-timestamp/part5/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-timestamp/part6/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-timestamp/part7/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-timestamp/part8/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_dest/creationDate-timestamp/part9/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-date/part0/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-date/part1/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-date/part2/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-date/part2/chunk1
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-date/part3/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-date/part4/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-date/part5/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-date/part6/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-date/part7/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-date/part8/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-date/part9/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-timestamp/part0/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-timestamp/part1/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-timestamp/part2/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-timestamp/part2/chunk1
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-timestamp/part3/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-timestamp/part4/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-timestamp/part5/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-timestamp/part6/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-timestamp/part7/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-timestamp/part8/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/ordered_by_source/creationDate-timestamp/part9/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-date/part0/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-date/part1/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-date/part2/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-date/part2/chunk1
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-date/part3/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-date/part4/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-date/part5/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-date/part6/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-date/part7/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-date/part8/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-date/part9/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-timestamp/part0/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-timestamp/part1/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-timestamp/part2/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-timestamp/part2/chunk1
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-timestamp/part3/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-timestamp/part4/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-timestamp/part5/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-timestamp/part6/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-timestamp/part7/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-timestamp/part8/chunk0
+ ldbc_sample/parquet/edge/person_knows_person/unordered_by_source/creationDate-timestamp/part9/chunk0
+0 −6 ldbc_sample/parquet/ldbc_sample_date.graph.yml
+0 −6 ldbc_sample/parquet/ldbc_sample_timestamp.graph.yml
+0 −25 ldbc_sample/parquet/person_knows-date_person.edge.yml
+0 −25 ldbc_sample/parquet/person_knows-timestamp_person.edge.yml