-
Notifications
You must be signed in to change notification settings - Fork 89
feat(java,info): refactor yaml saver api #763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b0c5db3
refactor saver
yangxk1 aa031ee
format
yangxk1 fd6d653
update
yangxk1 c97f027
update doc
yangxk1 049d8f2
add test case
yangxk1 3838667
update docs
yangxk1 27eb793
update
yangxk1 fce4131
merge from latest main branch
yangxk1 f9f1816
fix import
yangxk1 da0a256
update saver method and add test
yangxk1 27d9bc8
fix
yangxk1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
maven-projects/info/src/main/java/org/apache/graphar/info/saver/BaseGraphInfoSaver.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.graphar.info.saver; | ||
|
|
||
| import java.io.IOException; | ||
| import java.io.Writer; | ||
| import java.net.URI; | ||
| import org.apache.graphar.info.EdgeInfo; | ||
| import org.apache.graphar.info.GraphInfo; | ||
| import org.apache.graphar.info.VertexInfo; | ||
|
|
||
| public abstract class BaseGraphInfoSaver implements GraphInfoSaver { | ||
|
|
||
| public abstract Writer writeYaml(URI uri) throws IOException; | ||
|
|
||
| @Override | ||
| public void save(URI graphInfoUri, GraphInfo graphInfo) throws IOException { | ||
| Writer writer = writeYaml(graphInfoUri); | ||
| writer.write(graphInfo.dump(graphInfoUri)); | ||
| writer.close(); | ||
|
|
||
| for (VertexInfo vertexInfo : graphInfo.getVertexInfos()) { | ||
| URI saveUri = graphInfoUri.resolve(graphInfo.getStoreUri(vertexInfo)); | ||
| save(saveUri, vertexInfo); | ||
| } | ||
| for (EdgeInfo edgeInfo : graphInfo.getEdgeInfos()) { | ||
| URI saveUri = graphInfoUri.resolve(graphInfo.getStoreUri(edgeInfo)); | ||
| save(saveUri, edgeInfo); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void save(URI vertexInfoUri, VertexInfo vertexInfo) throws IOException { | ||
| Writer vertexWriter = writeYaml(vertexInfoUri); | ||
| vertexWriter.write(vertexInfo.dump()); | ||
| vertexWriter.close(); | ||
| } | ||
|
|
||
| @Override | ||
| public void save(URI edgeInfoUri, EdgeInfo edgeInfo) throws IOException { | ||
| Writer edgeWriter = writeYaml(edgeInfoUri); | ||
| edgeWriter.write(edgeInfo.dump()); | ||
| edgeWriter.close(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.