Skip to content
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 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions maven-projects/java-info/.scalafmt.conf
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
1 change: 1 addition & 0 deletions maven-projects/java-info/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module is under development
66 changes: 66 additions & 0 deletions maven-projects/java-info/pom.xml
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>
Copy link
Contributor

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 directly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, please review again.

<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>
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";
}
}
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();
}
}
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);
}
}
}
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;
}
}
Loading