-
Notifications
You must be signed in to change notification settings - Fork 44
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
[java-info] Add basic architecture java-info into main #481
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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,8 @@ | ||
version = "3.0.6" | ||
|
||
align.preset = some | ||
runner.dialect = scala212 | ||
maxColumn = 80 | ||
docstrings.style = Asterisk | ||
docstrings.removeEmpty = true | ||
project.git = true |
This file contains 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 @@ | ||
This module is under development |
This file contains 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,66 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
|
||
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. | ||
|
||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.apache.graphar</groupId> | ||
<artifactId>graphar-root</artifactId> | ||
<version>${graphar.version}</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>java-info</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>java-info</name> | ||
|
||
<properties> | ||
<maven.compiler.source>11</maven.compiler.source> | ||
<maven.compiler.target>11</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.13.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.yaml</groupId> | ||
<artifactId>snakeyaml</artifactId> | ||
<version>2.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.hadoop</groupId> | ||
<artifactId>hadoop-common</artifactId> | ||
<version>3.4.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
|
||
</project> |
50 changes: 50 additions & 0 deletions
50
maven-projects/java-info/src/main/java/org/apache/graphar/info/type/AdjListType.java
This file contains 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,50 @@ | ||
/* | ||
* 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.type; | ||
|
||
public enum AdjListType { | ||
/** collection of edges by source, but unordered, can represent COO format */ | ||
unordered_by_source, | ||
/** collection of edges by destination, but unordered, can represent COO */ | ||
unordered_by_dest, | ||
/** collection of edges by source, ordered by source, can represent CSR format */ | ||
ordered_by_source, | ||
/** collection of edges by destination, ordered by destination, can represent CSC format */ | ||
ordered_by_dest; | ||
|
||
public static AdjListType fromOrderedAndAlignedBy(boolean ordered, String alignedBy) { | ||
switch (alignedBy) { | ||
case "src": | ||
return ordered ? ordered_by_source : unordered_by_source; | ||
case "dst": | ||
return ordered ? ordered_by_dest : unordered_by_dest; | ||
default: | ||
throw new IllegalArgumentException("Invalid alignedBy: " + alignedBy); | ||
} | ||
} | ||
|
||
public boolean isOrdered() { | ||
return this == ordered_by_source || this == ordered_by_dest; | ||
} | ||
|
||
public String getAlignedBy() { | ||
return this == ordered_by_source || this == unordered_by_source ? "src" : "dst"; | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
maven-projects/java-info/src/main/java/org/apache/graphar/info/type/DataType.java
This file contains 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,69 @@ | ||
/* | ||
* 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.type; | ||
|
||
public enum DataType { | ||
/** Boolean */ | ||
BOOL, | ||
|
||
/** Signed 32-bit integer */ | ||
INT32, | ||
|
||
/** Signed 64-bit integer */ | ||
INT64, | ||
|
||
/** 4-byte floating point value */ | ||
FLOAT, | ||
|
||
/** 8-byte floating point value */ | ||
DOUBLE, | ||
|
||
/** UTF8 variable-length string */ | ||
STRING, | ||
|
||
/** List of same type */ | ||
LIST; | ||
|
||
public static DataType fromString(String s) { | ||
switch (s) { | ||
case "bool": | ||
return BOOL; | ||
case "int32": | ||
return INT32; | ||
case "int64": | ||
return INT64; | ||
case "float": | ||
return FLOAT; | ||
case "double": | ||
return DOUBLE; | ||
case "string": | ||
return STRING; | ||
case "list": | ||
return LIST; | ||
default: | ||
throw new IllegalArgumentException("Unknown data type: " + s); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return name().toLowerCase(); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
maven-projects/java-info/src/main/java/org/apache/graphar/info/type/FileType.java
This file contains 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,42 @@ | ||
/* | ||
* 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.type; | ||
|
||
public enum FileType { | ||
CSV, | ||
PARQUET, | ||
ORC; | ||
|
||
public static FileType fromString(String fileType) { | ||
if (fileType == null) { | ||
return null; | ||
} | ||
switch (fileType) { | ||
case "csv": | ||
return CSV; | ||
case "parquet": | ||
return PARQUET; | ||
case "orc": | ||
return ORC; | ||
default: | ||
throw new IllegalArgumentException("Unknown file type: " + fileType); | ||
} | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
...projects/java-info/src/main/java/org/apache/graphar/info/yaml/AdjacentListYamlParser.java
This file contains 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,75 @@ | ||
/* | ||
* 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.yaml; | ||
|
||
import org.apache.graphar.info.AdjacentList; | ||
|
||
public class AdjacentListYamlParser { | ||
private boolean ordered; | ||
private String aligned_by; | ||
private String file_type; | ||
private String prefix; | ||
|
||
public AdjacentListYamlParser() { | ||
this.ordered = false; | ||
this.aligned_by = ""; | ||
this.file_type = ""; | ||
this.prefix = ""; | ||
} | ||
|
||
public AdjacentListYamlParser(AdjacentList adjacentList) { | ||
this.ordered = adjacentList.getType().isOrdered(); | ||
this.aligned_by = adjacentList.getType().getAlignedBy(); | ||
this.file_type = adjacentList.getFileType().toString(); | ||
this.prefix = adjacentList.getPrefix(); | ||
} | ||
|
||
public boolean isOrdered() { | ||
return ordered; | ||
} | ||
|
||
public void setOrdered(boolean ordered) { | ||
this.ordered = ordered; | ||
} | ||
|
||
public String isAligned_by() { | ||
return aligned_by; | ||
} | ||
|
||
public void setAligned_by(String aligned_by) { | ||
this.aligned_by = aligned_by; | ||
} | ||
|
||
public String getFile_type() { | ||
return file_type; | ||
} | ||
|
||
public void setFile_type(String file_type) { | ||
this.file_type = file_type; | ||
} | ||
|
||
public String getPrefix() { | ||
return prefix; | ||
} | ||
|
||
public void setPrefix(String prefix) { | ||
this.prefix = prefix; | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to use
info
as package and directory name since spark and java reader/writer would use the module directlyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, please review again.