Skip to content

Commit

Permalink
Support nebula-spark reader v1.0 (#155)
Browse files Browse the repository at this point in the history
* Support nebula-spark reader v1.0
  • Loading branch information
Nicole00 authored Oct 10, 2020
1 parent d50246b commit b6ab39f
Show file tree
Hide file tree
Showing 20 changed files with 471 additions and 362 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ target/
spark-importer.ipr
spark-importer.iws

.DS_Store
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.6-SNAPSHOT</version>
<version>3.0.4</version>
<configuration>
<threshold>High</threshold>
<effort>Default</effort>
Expand Down
80 changes: 77 additions & 3 deletions tools/nebula-spark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.12</artifactId>
<artifactId>spark-core_2.11</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-graphx_2.12</artifactId>
<artifactId>spark-sql_2.11</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.12</artifactId>
<artifactId>spark-graphx_2.11</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
Expand All @@ -43,6 +43,21 @@

<build>
<plugins>
<!-- maven-jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- maven-compiler -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand All @@ -51,6 +66,65 @@
<target>${compiler.target.version}</target>
</configuration>
</plugin>

<!-- maven-shade -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<excludes>
<exclude>org.apache.spark:*</exclude>
<exclude>org.apache.hadoop:*</exclude>
<exclude>org.apache.hive:*</exclude>
<exclude>log4j:log4j</exclude>
<exclude>org.apache.orc:*</exclude>
<exclude>xml-apis:xml-apis</exclude>
<exclude>javax.inject:javax.inject</exclude>
<exclude>org.spark-project.hive:hive-exec</exclude>
<exclude>stax:stax-api</exclude>
<exclude>org.glassfish.hk2.external:aopalliance-repackaged</exclude>
</excludes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>com/vesoft/tools/**</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>

<!-- scala-maven -->
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>
</project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/* Copyright (c) 2020 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License,
* attached with Common Clause Condition 1.0, found in the LICENSES directory.
*/

package com.vesoft.nebula.bean;

import com.google.common.net.HostAndPort;
import org.apache.commons.lang.StringUtils;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.ArrayList;

public class DataSourceConfig implements Serializable {

private final String nameSpace;

private final String type;

private final String label;

private final String returnColString;

private boolean allCols = false;

private final int partitionNumber;

private final String hostAndPorts;

/**
* @param nameSpace nameSpace
* @param type scan element type
* @param label vertex or edge label
* @param partitionNumber partition number
* @param returnColString scan col string example: name,age
* @param hostAndPorts host and port
*/
public DataSourceConfig(String nameSpace, String type, String label, String returnColString, int partitionNumber, String hostAndPorts) {
this.nameSpace = nameSpace;
this.type = type;
this.label = label;
this.returnColString = returnColString;
this.partitionNumber = partitionNumber;
this.hostAndPorts = hostAndPorts;
}

public String getNameSpace() {
return nameSpace;
}

public String getType() {
return type;
}

public String getLabel() {
return label;
}

public int getPartitionNumber() {
return partitionNumber;
}

public boolean getAllCols() {
return allCols;
}

public Map<String, List<String>> getReturnColMap() {
Map<String, List<String>> result = new HashMap<>(1);
if (StringUtils.isBlank(returnColString)) {
allCols = true;
result.put(label, new ArrayList<>());
} else {
List<String> properties = Arrays.asList(returnColString.split(","));
result.put(label, properties);
}
return result;
}

public List<HostAndPort> getHostAndPorts() {
List<HostAndPort> hostAndPortList = new ArrayList<>();
String[] hostAndPortArray = hostAndPorts.split(",");
for (String hostAndPort : hostAndPortArray) {
hostAndPortList.add(HostAndPort.fromString(hostAndPort));
}
return hostAndPortList;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* Copyright (c) 2020 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License,
* attached with Common Clause Condition 1.0, found in the LICENSES directory.
*/

package com.vesoft.nebula.bean;

public class Parameters {

public static final String SPACE_NAME = "spaceName";
public static final String LABEL = "label";
public static final String TYPE = "type";
public static final String HOST_AND_PORTS = "hostAndPorts";
public static final String RETURN_COLS = "returnCols";
public static final String PARTITION_NUMBER = "partitionNumber";
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public enum Type {

VERTEX("VERTEX"),EDGE("EDGE");
VERTEX("VERTEX"), EDGE("EDGE");

private String type;

Expand Down
Loading

0 comments on commit b6ab39f

Please sign in to comment.