Skip to content

Commit

Permalink
feat(client): support "parent & child" EdgeLabel type (#624)
Browse files Browse the repository at this point in the history
Co-authored-by: imbajin <[email protected]>
  • Loading branch information
Thespica and imbajin authored Oct 11, 2024
1 parent 3b58fc6 commit 6156dee
Show file tree
Hide file tree
Showing 12 changed files with 291 additions and 85 deletions.
43 changes: 27 additions & 16 deletions .github/workflows/client-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,44 @@ jobs:
USE_STAGE: 'true' # Whether to include the stage repository.
TRAVIS_DIR: hugegraph-client/assembly/travis
# TODO: replace it with the (latest - n) commit id (n >= 15)
COMMIT_ID: 6a4041e
# hugegraph commit date: 2024-10-10
COMMIT_ID: 29ecc0
strategy:
fail-fast: false
matrix:
JAVA_VERSION: [ '8' ]

steps:
- name: Install JDK 8
uses: actions/setup-java@v3
- name: Fetch code
uses: actions/checkout@v4
with:
java-version: ${{ matrix.JAVA_VERSION }}
distribution: 'zulu'
fetch-depth: 2

# TODO: do we need it? (need test)
- name: Cache Maven packages
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-

- name: Checkout
uses: actions/checkout@v3
- name: Install JDK 11 for graph server
uses: actions/setup-java@v4
with:
fetch-depth: 2
java-version: '11'
distribution: 'zulu'
cache: 'maven'

- name: Prepare env and service
run: |
$TRAVIS_DIR/install-hugegraph-from-source.sh $COMMIT_ID
- name: Install Java ${{ matrix.JAVA_VERSION }} for client
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.JAVA_VERSION }}
distribution: 'zulu'
cache: 'maven'

- name: Use staged maven repo
if: ${{ env.USE_STAGE == 'true' }}
Expand All @@ -59,10 +74,6 @@ jobs:
run: |
mvn -e compile -pl hugegraph-client -Dmaven.javadoc.skip=true -ntp
- name: Prepare env and service
run: |
$TRAVIS_DIR/install-hugegraph-from-source.sh $COMMIT_ID
- name: Run test
run: |
cd hugegraph-client && ls *
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/loader-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
TRAVIS_DIR: hugegraph-loader/assembly/travis
STATIC_DIR: hugegraph-loader/assembly/static
# TODO: replace it with the (latest - n) commit id (n >= 15)
COMMIT_ID: 6a4041e
COMMIT_ID: f6f3708
DB_USER: root
DB_PASS: root
DB_DATABASE: load_test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spark-connector-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
env:
USE_STAGE: 'true' # Whether to include the stage repository.
TRAVIS_DIR: hugegraph-spark-connector/assembly/travis
COMMIT_ID: 6a4041e
COMMIT_ID: f6f3708
steps:
- name: Install JDK 11
uses: actions/setup-java@v4
Expand Down
4 changes: 4 additions & 0 deletions hugegraph-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
</parent>

<artifactId>hugegraph-client</artifactId>
<version>${revision}</version>
<packaging>jar</packaging>

<name>${project.artifactId}</name>
Expand All @@ -48,6 +49,9 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<!-- TODO: current version(2.8.48) will meet error when using java11 to test unit/RestResultTest,
switch to 2.25.1 will temporarily solve this problem -->
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public GraphElement property(String name, Object value) {
E.checkArgument(ReflectionUtil.isSimpleType(clazz) ||
clazz.equals(UUID.class) ||
clazz.equals(Date.class) ||
clazz.equals(byte[].class) ||
value instanceof List ||
value instanceof Set,
"Invalid property value type: '%s'", clazz);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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.hugegraph.structure.constant;

public enum EdgeLabelType {

NORMAL(0, "NORMAL"),

PARENT(1, "PARENT"),

SUB(2, "SUB");

private byte code = 0;
private String name = null;

EdgeLabelType(int code, String name) {
assert code < 256;
this.code = (byte) code;
this.name = name;
}

public boolean parent() {
return this == PARENT;
}

public boolean sub() {
return this == SUB;
}

public boolean normal() {
return this == NORMAL;
}

public byte code() {
return this.code;
}

public String string() {
return this.name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ public void targetLabel(String targetLabel) {
public String name() {
if (this.name == null) {
String[] idParts = SplicingIdGenerator.split(this.id);
E.checkState(idParts.length == 4,
"The edge id must be formatted by 4 parts, " +
E.checkState(idParts.length == 5 || idParts.length == 6,
"The edge id must be formatted by 5~6 parts, " +
"actual is %s", idParts.length);
this.name = idParts[2];
this.name = idParts[idParts.length - 2];
}
return this.name;
}
Expand Down
Loading

0 comments on commit 6156dee

Please sign in to comment.