Compare commits

...

9 Commits
master ... tmp

16 changed files with 107 additions and 77 deletions

2
.gitattributes vendored
View File

@ -2,7 +2,6 @@
.gitattributes export-ignore
.gitignore export-ignore
.asf.yaml export-ignore
checkstyle.xml export-ignore
apache-release.sh export-ignore
.licenserc.yaml export-ignore
.editorconfig export-ignore
@ -10,5 +9,4 @@ apache-release.sh export-ignore
# ignored directory
.github/ export-ignore
hugegraph-dist/scripts/ export-ignore
style/ export-ignore
#assembly/ export-ignore

View File

@ -20,8 +20,8 @@ jobs:
stale-pr-message: 'Due to the lack of activity, the current pr is marked as stale and will be closed after 180 days, any update will remove the stale label'
stale-issue-label: 'inactive'
stale-pr-label: 'inactive'
exempt-issue-labels: 'feature,bug,enhancement,improvement,wontfix,todo,guide,doc,help wanted'
exempt-pr-labels: 'feature,bug,enhancement,improvement,wontfix,todo,guide,doc,help wanted'
exempt-issue-labels: 'feature,bug,enhancement,improvement,todo,guide,doc,help wanted,security'
exempt-pr-labels: 'feature,bug,enhancement,improvement,todo,guide,doc,help wanted,security'
exempt-all-milestones: true
days-before-issue-stale: 15

View File

@ -55,6 +55,8 @@ header: # `header` section is configurations for source codes license header.
- '.gitignore'
- '.gitattributes'
- 'LICENSE'
- 'NOTICE'
- 'DISCLAIMER'
- '**/*.versionsBackup'
- '**/*.versionsBackup'
- '**/*.proto'

7
DISCLAIMER Normal file
View File

@ -0,0 +1,7 @@
Apache HugeGraph (incubating) is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator PMC.
Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications,
and decision making process have stabilized in a manner consistent with other successful ASF projects.
While incubation status is not necessarily a reflection of the completeness or stability of the code,
it does indicate that the project has yet to be fully endorsed by the ASF.

5
NOTICE Normal file
View File

@ -0,0 +1,5 @@
Apache HugeGraph(incubating)
Copyright 2022-2023 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).

View File

@ -230,7 +230,7 @@ public class PropertyKey extends SchemaElement implements Propertiable {
}
/**
* Check type of all the values(may be some of list properties) valid
* Check type of all the values(maybe some list properties) valid
* @param values the property values to be checked data type
* @param <V> the property value class
* @return true if all the values are or can convert to the data type,

View File

@ -47,12 +47,14 @@ import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
import org.apache.hugegraph.backend.serializer.BytesBuffer;
import org.apache.hugegraph.perf.PerfUtil.Watched;
import org.apache.hugegraph.util.E;
import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyProperty;
import com.google.common.collect.ImmutableList;
public class HugeEdge extends HugeElement implements Edge, Cloneable {
private Id id;
private EdgeLabel label;
private final EdgeLabel label;
private String name;
private HugeVertex sourceVertex;
@ -202,6 +204,11 @@ public class HugeEdge extends HugeElement implements Edge, Cloneable {
E.checkArgument(this.label.properties().contains(propertyKey.id()),
"Invalid property '%s' for edge label '%s'",
key, this.label());
if (value == null) {
this.removeProperty(propertyKey.id());
return EmptyProperty.instance();
}
// Sort-Keys can only be set once
if (this.schemaLabel().sortKeys().contains(propertyKey.id())) {
E.checkArgument(!this.hasProperty(propertyKey.id()),
@ -281,7 +288,7 @@ public class HugeEdge extends HugeElement implements Edge, Cloneable {
if (keys.length == 0) {
for (HugeProperty<?> prop : this.getProperties()) {
assert prop instanceof Property;
assert prop != null;
props.add((Property<V>) prop);
}
} else {
@ -297,7 +304,6 @@ public class HugeEdge extends HugeElement implements Edge, Cloneable {
// Not found
continue;
}
assert prop instanceof Property;
props.add((Property<V>) prop);
}
}
@ -322,8 +328,7 @@ public class HugeEdge extends HugeElement implements Edge, Cloneable {
case PROPERTIES:
return this.getPropertiesMap();
default:
E.checkArgument(false,
"Invalid system property '%s' of Edge", key);
E.checkArgument(false, "Invalid system property '%s' of Edge", key);
return null;
}
}
@ -364,6 +369,7 @@ public class HugeEdge extends HugeElement implements Edge, Cloneable {
if (ownerLabel.equals(this.label.sourceLabel())) {
this.vertices(true, owner, other);
} else {
// TODO: why compare the label but ignore the result?
ownerLabel.equals(this.label.targetLabel());
this.vertices(false, owner, other);
}
@ -517,8 +523,7 @@ public class HugeEdge extends HugeElement implements Edge, Cloneable {
ownerVertex.correctVertexLabel(tgtLabel);
otherVertexLabel = srcLabel;
}
HugeVertex otherVertex = new HugeVertex(graph, otherVertexId,
otherVertexLabel);
HugeVertex otherVertex = new HugeVertex(graph, otherVertexId, otherVertexLabel);
ownerVertex.propNotLoaded();
otherVertex.propNotLoaded();

View File

@ -33,7 +33,9 @@ import org.apache.hugegraph.HugeGraph;
import org.apache.hugegraph.backend.id.EdgeId;
import org.apache.hugegraph.backend.id.Id;
import org.apache.hugegraph.backend.id.IdGenerator;
import org.apache.hugegraph.backend.serializer.BytesBuffer;
import org.apache.hugegraph.backend.tx.GraphTransaction;
import org.apache.hugegraph.perf.PerfUtil.Watched;
import org.apache.hugegraph.schema.PropertyKey;
import org.apache.hugegraph.schema.SchemaLabel;
import org.apache.hugegraph.schema.VertexLabel;
@ -41,6 +43,9 @@ import org.apache.hugegraph.type.HugeType;
import org.apache.hugegraph.type.Idfiable;
import org.apache.hugegraph.type.define.Cardinality;
import org.apache.hugegraph.type.define.HugeKeys;
import org.apache.hugegraph.util.CollectionUtil;
import org.apache.hugegraph.util.E;
import org.apache.hugegraph.util.InsertionOrderUtil;
import org.apache.hugegraph.util.collection.CollectionFactory;
import org.apache.tinkerpop.gremlin.structure.Element;
import org.apache.tinkerpop.gremlin.structure.Property;
@ -49,12 +54,6 @@ import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
import org.eclipse.collections.api.iterator.IntIterator;
import org.eclipse.collections.api.map.primitive.MutableIntObjectMap;
import org.apache.hugegraph.backend.serializer.BytesBuffer;
import org.apache.hugegraph.perf.PerfUtil.Watched;
import org.apache.hugegraph.util.CollectionUtil;
import org.apache.hugegraph.util.E;
import org.apache.hugegraph.util.InsertionOrderUtil;
public abstract class HugeElement implements Element, GraphType, Idfiable {
private static final MutableIntObjectMap<HugeProperty<?>> EMPTY_MAP =
@ -63,8 +62,8 @@ public abstract class HugeElement implements Element, GraphType, Idfiable {
private final HugeGraph graph;
private MutableIntObjectMap<HugeProperty<?>> properties;
private long expiredTime; // TODO: move into properties to keep small object
// TODO: move into properties to keep small object
private long expiredTime;
private boolean removed;
private boolean fresh;
@ -427,10 +426,19 @@ public abstract class HugeElement implements Element, GraphType, Idfiable {
Object val = keyValues[i + 1];
if (!(key instanceof String) && !(key instanceof T)) {
throw Element.Exceptions
.providedKeyValuesMustHaveALegalKeyOnEvenIndices();
throw Element.Exceptions.providedKeyValuesMustHaveALegalKeyOnEvenIndices();
}
if (val == null) {
if (T.label.equals(key)) {
throw Element.Exceptions.labelCanNotBeNull();
}
// Ignore null value for tinkerpop test compatibility
continue;
}
if (val == null) {
if (key.equals(T.label)) {
throw Element.Exceptions.labelCanNotBeNull();
}
throw Property.Exceptions.propertyDoesNotExist();
}

View File

@ -51,8 +51,7 @@ public abstract class HugeProperty<V> implements Property<V>, GraphType {
}
public Object id() {
return SplicingIdGenerator.concat(this.owner.id().asString(),
this.key());
return SplicingIdGenerator.concat(this.owner.id().asString(), this.key());
}
@Override

View File

@ -22,6 +22,7 @@ package org.apache.hugegraph.structure;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@ -61,6 +62,9 @@ import org.apache.hugegraph.type.define.Directions;
import org.apache.hugegraph.type.define.HugeKeys;
import org.apache.hugegraph.type.define.IdStrategy;
import org.apache.hugegraph.util.E;
import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyProperty;
import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyVertexProperty;
import com.google.common.collect.ImmutableList;
public class HugeVertex extends HugeElement implements Vertex, Cloneable {
@ -164,8 +168,7 @@ public class HugeVertex extends HugeElement implements Vertex, Cloneable {
}
break;
default:
throw new AssertionError(String.format(
"Unknown id strategy '%s'", strategy));
throw new AssertionError(String.format("Unknown id strategy '%s'", strategy));
}
this.checkIdLength();
}
@ -252,7 +255,7 @@ public class HugeVertex extends HugeElement implements Vertex, Cloneable {
/**
* Add one edge between this vertex and other vertex
*
* <p>
* *** this method is not thread safe, must clone this vertex first before
* multi thread access e.g. `vertex.copy().resetTx();` ***
*/
@ -297,7 +300,7 @@ public class HugeVertex extends HugeElement implements Vertex, Cloneable {
label, this.label(), vertex.label());
// Check sortKeys
List<Id> keys = this.graph().mapPkName2Id(elemKeys.keys());
E.checkArgument(keys.containsAll(edgeLabel.sortKeys()),
E.checkArgument(new HashSet<>(keys).containsAll(edgeLabel.sortKeys()),
"The sort key(s) must be set for the edge " +
"with label: '%s'", edgeLabel.name());
@ -306,7 +309,7 @@ public class HugeVertex extends HugeElement implements Vertex, Cloneable {
Collection<Id> nonNullKeys = CollectionUtils.subtract(
edgeLabel.properties(),
edgeLabel.nullableKeys());
if (!keys.containsAll(nonNullKeys)) {
if (!new HashSet<>(keys).containsAll(nonNullKeys)) {
@SuppressWarnings("unchecked")
Collection<Id> missed = CollectionUtils.subtract(nonNullKeys, keys);
E.checkArgument(false, "All non-null property keys: %s " +
@ -421,9 +424,8 @@ public class HugeVertex extends HugeElement implements Vertex, Cloneable {
@Watched(prefix = "vertex")
@Override
public <V> VertexProperty<V> property(
VertexProperty.Cardinality cardinality,
String key, V value, Object... objects) {
public <V> VertexProperty<V> property(VertexProperty.Cardinality cardinality,
String key, V value, Object... objects) {
if (objects.length != 0 && objects[0].equals(T.id)) {
throw VertexProperty.Exceptions.userSuppliedIdsNotSupported();
}
@ -439,7 +441,7 @@ public class HugeVertex extends HugeElement implements Vertex, Cloneable {
* .property(list, "key2", val2)
*
* The cardinality single may be user supplied single, it may also be
* that user doesn't supplied cardinality, when it is latter situation,
* that user doesn't supply cardinality, when it is latter situation,
* we shouldn't check it. Because of this reason, we are forced to
* give up the check of user supplied cardinality single.
* The cardinality not single must be user supplied, so should check it
@ -462,10 +464,14 @@ public class HugeVertex extends HugeElement implements Vertex, Cloneable {
E.checkArgument(!this.hasProperty(propertyKey.id()),
"Can't update primary key: '%s'", key);
}
if (value == null) {
this.removeProperty(propertyKey.id());
return EmptyVertexProperty.instance();
}
@SuppressWarnings("unchecked")
VertexProperty<V> prop = (VertexProperty<V>) this.addProperty(
propertyKey, value, !this.fresh());
VertexProperty<V> prop = (VertexProperty<V>) this.addProperty(propertyKey,
value, !this.fresh());
return prop;
}

View File

@ -179,10 +179,11 @@
</goals>
<configuration>
<target>
<tar destfile="${final.destfile}"
basedir="${top.level.dir}"
includes="${final.name}/**"
compression="gzip"/>
<tar destfile="${final.destfile}" compression="gzip">
<tarfileset dir="${top.level.dir}/" filemode="755">
<include name="${final.name}/**"/>
</tarfileset>
</tar>
</target>
</configuration>
</execution>

View File

@ -48,6 +48,15 @@
<include>*.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${top.level.dir}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>LICENSE*</include>
<include>NOTICE*</include>
<include>DISCLAIMER*</include>
</includes>
</fileSet>
</fileSets>
<dependencySets>

View File

@ -45,5 +45,7 @@ cd $TOP
echo "Dumping HugeGraph Config($conf)..."
exec $JAVA -cp $LIB/hugegraph-dist-*.jar -Djava.ext.dirs=$LIB/ \
dump_conf_ext_jar_path=$LIB/hugegraph-dist-*.jar
for i in $LIB/*.jar; do dump_conf_ext_jar_path=$dump_conf_ext_jar_path:$i; export dump_conf_ext_jar_path; done
exec $JAVA -cp dump_conf_ext_jar_path \
org.apache.hugegraph.cmd.ConfDumper $conf

View File

@ -45,5 +45,7 @@ cd $TOP
echo "Dumping HugeGraph Store($conf)..."
exec $JAVA -cp $LIB/hugegraph-dist-*.jar -Djava.ext.dirs=$LIB/ \
dump_store_ext_jar_path=$LIB/hugegraph-dist-*.jar
for i in $LIB/*.jar; do dump_store_ext_jar_path=$dump_store_ext_jar_path:$i; export dump_store_ext_jar_path; done
exec $JAVA -cp dump_store_ext_jar_path \
org.apache.hugegraph.cmd.StoreDumper $conf $2 $3 $4

View File

@ -23,7 +23,6 @@ import org.apache.tinkerpop.gremlin.GraphProviderClass;
import org.junit.runner.RunWith;
@RunWith(ProcessBasicSuite.class)
@GraphProviderClass(provider = ProcessTestGraphProvider.class,
graph = TestGraph.class)
@GraphProviderClass(provider = ProcessTestGraphProvider.class, graph = TestGraph.class)
public class ProcessStandardTest {
}

View File

@ -47,6 +47,7 @@ import org.apache.hugegraph.task.TaskScheduler;
import org.apache.hugegraph.testutil.Whitebox;
import org.apache.hugegraph.type.define.IdStrategy;
import org.apache.hugegraph.type.define.NodeRole;
import com.google.common.collect.ImmutableSet;
@Graph.OptIn("org.apache.hugegraph.tinkerpop.StructureBasicSuite")
@ -57,8 +58,7 @@ public class TestGraph implements Graph {
public static final String DEFAULT_VL = "vertex";
public static final Set<String> TRUNCATE_BACKENDS =
ImmutableSet.of("rocksdb", "mysql");
public static final Set<String> TRUNCATE_BACKENDS = ImmutableSet.of("rocksdb", "mysql");
private static volatile int id = 666;
@ -132,19 +132,19 @@ public class TestGraph implements Graph {
// Clear schema and graph data will be cleared at same time
SchemaManager schema = this.graph.schema();
schema.getIndexLabels().stream().forEach(elem -> {
schema.getIndexLabels().forEach(elem -> {
schema.indexLabel(elem.name()).remove();
});
schema.getEdgeLabels().stream().forEach(elem -> {
schema.getEdgeLabels().forEach(elem -> {
schema.edgeLabel(elem.name()).remove();
});
schema.getVertexLabels().stream().forEach(elem -> {
schema.getVertexLabels().forEach(elem -> {
schema.vertexLabel(elem.name()).remove();
});
schema.getPropertyKeys().stream().forEach(elem -> {
schema.getPropertyKeys().forEach(elem -> {
schema.propertyKey(elem.name()).remove();
});
@ -157,7 +157,7 @@ public class TestGraph implements Graph {
@Watched
protected void clearVariables() {
Variables variables = this.variables();
variables.keys().forEach(key -> variables.remove(key));
variables.keys().forEach(variables::remove);
}
protected boolean closed() {
@ -252,8 +252,7 @@ public class TestGraph implements Graph {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public <I extends Io> I io(final Io.Builder<I> builder) {
Whitebox.setInternalState(HugeGraphSONModule.class,
"OPTIMIZE_SERIALIZE", false);
Whitebox.setInternalState(HugeGraphSONModule.class, "OPTIMIZE_SERIALIZE", false);
return (I) builder.graph(this).onMapper(mapper ->
mapper.addRegistry(HugeGraphIoRegistry.instance())
).create();
@ -317,8 +316,7 @@ public class TestGraph implements Graph {
case "regularLoad":
return false;
default:
throw new AssertionError(String.format(
"Wrong IO type %s", this.loadedGraph));
throw new AssertionError(String.format("Wrong IO type %s", this.loadedGraph));
}
}
@ -346,24 +344,19 @@ public class TestGraph implements Graph {
schema.propertyKey(key).ifNotExist().create();
break;
case "BooleanArray":
schema.propertyKey(key).asBoolean().valueList()
.ifNotExist().create();
schema.propertyKey(key).asBoolean().valueList().ifNotExist().create();
break;
case "IntegerArray":
schema.propertyKey(key).asInt().valueList()
.ifNotExist().create();
schema.propertyKey(key).asInt().valueList().ifNotExist().create();
break;
case "LongArray":
schema.propertyKey(key).asLong().valueList()
.ifNotExist().create();
schema.propertyKey(key).asLong().valueList().ifNotExist().create();
break;
case "FloatArray":
schema.propertyKey(key).asFloat().valueList()
.ifNotExist().create();
schema.propertyKey(key).asFloat().valueList().ifNotExist().create();
break;
case "DoubleArray":
schema.propertyKey(key).asDouble().valueList()
.ifNotExist().create();
schema.propertyKey(key).asDouble().valueList().ifNotExist().create();
break;
case "StringArray":
schema.propertyKey(key).valueList().ifNotExist().create();
@ -376,8 +369,7 @@ public class TestGraph implements Graph {
case "Serializable":
break;
default:
throw new RuntimeException(
String.format("Wrong type %s for %s", type, key));
throw new RuntimeException(String.format("Wrong type %s for %s", type, key));
}
}
@ -413,8 +405,7 @@ public class TestGraph implements Graph {
.useCustomizeStringId().ifNotExist().create();
break;
default:
throw new AssertionError(String.format(
"Id strategy must be customize or automatic"));
throw new AssertionError("Id strategy must be customize or automatic");
}
schema.edgeLabel("followedBy")
@ -509,8 +500,7 @@ public class TestGraph implements Graph {
.useCustomizeStringId().ifNotExist().create();
break;
default:
throw new AssertionError(String.format(
"Id strategy must be customize or automatic"));
throw new AssertionError("Id strategy must be customize or automatic");
}
schema.edgeLabel("knows").link("person", "person")
@ -586,8 +576,7 @@ public class TestGraph implements Graph {
.useCustomizeStringId().ifNotExist().create();
break;
default:
throw new AssertionError(String.format(
"Id strategy must be customize or automatic"));
throw new AssertionError("Id strategy must be customize or automatic");
}
schema.edgeLabel("knows").link("vertex", "vertex")
@ -675,8 +664,7 @@ public class TestGraph implements Graph {
schema.propertyKey("new").ifNotExist().create();
schema.propertyKey("color").ifNotExist().create();
schema.propertyKey("every").ifNotExist().create();
schema.propertyKey("gremlin.partitionGraphStrategy.partition")
.ifNotExist().create();
schema.propertyKey("gremlin.partitionGraphStrategy.partition").ifNotExist().create();
schema.propertyKey("blah").asDouble().ifNotExist().create();
schema.propertyKey("bloop").asInt().ifNotExist().create();
@ -695,8 +683,7 @@ public class TestGraph implements Graph {
}
@Watched
private void initBasicVertexLabelV(IdStrategy idStrategy,
String defaultVL) {
private void initBasicVertexLabelV(IdStrategy idStrategy, String defaultVL) {
SchemaManager schema = this.graph.schema();
switch (idStrategy) {
@ -769,7 +756,7 @@ public class TestGraph implements Graph {
private void initBasicVertexLabelAndEdgeLabelExceptV(String defaultVL) {
SchemaManager schema = this.graph.schema();
if (!defaultVL.equals("person")) {
if (!"person".equals(defaultVL)) {
schema.vertexLabel("person")
.properties("name", "age")
.nullableKeys("name", "age")