Upgrade tinkerpop version to 3.4.3 (#648)

Change-Id: I5443b6a05eea74205a373f093dad27536e04f0be
This commit is contained in:
Linary 2019-09-12 19:04:30 +08:00 committed by Jermy Li
parent 64f94091b4
commit 1c062b8947
56 changed files with 658 additions and 717 deletions

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>hugegraph</artifactId>
<groupId>com.baidu.hugegraph</groupId>
<version>0.10.3</version>
<version>0.10.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -25,7 +25,6 @@ import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATH
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.NO_LIMIT;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@ -47,6 +46,7 @@ import org.slf4j.Logger;
import com.baidu.hugegraph.HugeGraph;
import com.baidu.hugegraph.api.API;
import com.baidu.hugegraph.backend.id.Id;
import com.baidu.hugegraph.backend.query.QueryResults;
import com.baidu.hugegraph.core.GraphManager;
import com.baidu.hugegraph.schema.EdgeLabel;
import com.baidu.hugegraph.server.RestServer;
@ -97,7 +97,7 @@ public class CustomizedCrosspointsAPI extends API {
CustomizedCrosspointsTraverser.CrosspointsPaths paths;
paths = traverser.crosspointsPaths(sources, patterns, request.capacity,
request.limit);
Iterator<Vertex> iter = Collections.emptyIterator();
Iterator<Vertex> iter = QueryResults.emptyIterator();
if (!request.withVertex) {
return manager.serializer(g).writeCrosspoints(paths, iter,
request.withPath);

View File

@ -27,7 +27,6 @@ import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_WEIG
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.NO_LIMIT;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@ -49,6 +48,7 @@ import org.slf4j.Logger;
import com.baidu.hugegraph.HugeGraph;
import com.baidu.hugegraph.api.API;
import com.baidu.hugegraph.backend.id.Id;
import com.baidu.hugegraph.backend.query.QueryResults;
import com.baidu.hugegraph.core.GraphManager;
import com.baidu.hugegraph.schema.EdgeLabel;
import com.baidu.hugegraph.schema.PropertyKey;
@ -114,7 +114,7 @@ public class CustomizedPathsAPI extends API {
for (HugeTraverser.Path p : paths) {
ids.addAll(p.vertices());
}
Iterator<Vertex> iter = Collections.emptyIterator();
Iterator<Vertex> iter = QueryResults.emptyIterator();
if (!ids.isEmpty()) {
iter = g.vertices(ids.toArray());
}

View File

@ -23,13 +23,11 @@ import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadFactory;
import org.apache.commons.lang3.SystemUtils;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.server.GraphManager;
import org.apache.tinkerpop.gremlin.server.GremlinServer;
import org.apache.tinkerpop.gremlin.server.Settings;
import org.apache.tinkerpop.gremlin.server.util.MetricManager;
import org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor;
import org.apache.tinkerpop.gremlin.server.util.ThreadFactoryUtil;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.slf4j.Logger;
@ -40,10 +38,6 @@ import com.baidu.hugegraph.auth.HugeGraphAuthProxy.Context;
import com.baidu.hugegraph.auth.HugeGraphAuthProxy.ContextThreadPoolExecutor;
import com.baidu.hugegraph.util.Log;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
/**
* GremlinServer with custom ServerGremlinExecutor, which can pass Context
*/
@ -51,17 +45,11 @@ public class ContextGremlinServer extends GremlinServer {
private static final Logger LOG = Log.logger(ContextGremlinServer.class);
@SuppressWarnings("deprecation")
public ContextGremlinServer(final Settings settings) {
/*
* TODO: use GremlinServer(Settings, ExecutorService)
* which can be obtained from https://github.com/apache/tinkerpop/pull/813
*
* NOTE: should call GremlinServer::configureMetrics() but it's private
* settings.optionalMetrics().ifPresent(GremlinServer::configureMetrics)
*/
super(create(settings));
settings.optionalMetrics().ifPresent(this::configureMetrics);
super(settings, newGremlinExecutorService(settings));
}
public void injectAuthGraph() {
@ -92,28 +80,10 @@ public class ContextGremlinServer extends GremlinServer {
}
}
static ServerGremlinExecutor<EventLoopGroup> create(Settings settings) {
static ExecutorService newGremlinExecutorService(Settings settings) {
if (settings.gremlinPool == 0) {
settings.gremlinPool = Runtime.getRuntime().availableProcessors();
}
ExecutorService service = newGremlinExecutorService(settings);
EventLoopGroup group;
boolean isEpollEnabled = settings.useEpollEventLoop &&
SystemUtils.IS_OS_LINUX;
ThreadFactory factory = ThreadFactoryUtil.create("worker-%d");
if (isEpollEnabled) {
group = new EpollEventLoopGroup(settings.threadPoolWorker, factory);
} else {
group = new NioEventLoopGroup(settings.threadPoolWorker, factory);
}
return new ServerGremlinExecutor<>(settings, service,
group, EventLoopGroup.class);
}
static ExecutorService newGremlinExecutorService(Settings settings) {
int size = settings.gremlinPool;
ThreadFactory factory = ThreadFactoryUtil.create("exec-%d");
return new ContextThreadPoolExecutor(size, size, factory);
@ -146,7 +116,7 @@ public class ContextGremlinServer extends GremlinServer {
if (config.enabled) {
try {
metrics.addGangliaReporter(config.host, config.port,
config.optionalAddressingMode(),
config.addressingMode,
config.ttl, config.protocol31,
config.hostUUID, config.spoof,
config.interval);

View File

@ -256,7 +256,7 @@ public class HugeGraphAuthProxy implements GremlinGraph {
public ContextThreadPoolExecutor(int corePoolSize, int maxPoolSize,
ThreadFactory threadFactory) {
super(corePoolSize, maxPoolSize, 0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(), threadFactory);
new LinkedBlockingQueue<>(), threadFactory);
}
@Override

View File

@ -19,6 +19,7 @@
package com.baidu.hugegraph.auth;
import java.net.InetAddress;
import java.util.HashMap;
import java.util.Map;
@ -112,7 +113,7 @@ public class StandardAuthenticator implements HugeAuthenticator {
}
@Override
public SaslNegotiator newSaslNegotiator() {
public SaslNegotiator newSaslNegotiator(InetAddress remoteAddress) {
throw new NotImplementedException("SaslNegotiator is unsupported");
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>hugegraph</artifactId>
<groupId>com.baidu.hugegraph</groupId>
<version>0.10.3</version>
<version>0.10.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -15,7 +15,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.44.Final</version>
<version>4.1.36.Final</version>
</dependency>
<dependency>
<groupId>com.baidu.hugegraph</groupId>
@ -59,7 +59,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<version>4.0.44.Final</version>
<version>4.1.36.Final</version>
<classifier>linux-x86_64</classifier>
</dependency>
<dependency>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>com.baidu.hugegraph</groupId>
<artifactId>hugegraph</artifactId>
<version>0.10.3</version>
<version>0.10.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>hugegraph-core</artifactId>

View File

@ -23,8 +23,8 @@ import java.util.Iterator;
import java.util.NoSuchElementException;
import com.baidu.hugegraph.backend.query.Query;
import com.baidu.hugegraph.backend.query.QueryResults;
import com.baidu.hugegraph.backend.store.BackendEntry;
import com.baidu.hugegraph.backend.tx.AbstractTransaction.QueryResults;
import com.baidu.hugegraph.exception.NotSupportException;
import com.baidu.hugegraph.iterator.Metadatable;
import com.baidu.hugegraph.util.E;

View File

@ -20,7 +20,6 @@
package com.baidu.hugegraph.backend.page;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@ -30,8 +29,8 @@ import com.baidu.hugegraph.HugeGraph;
import com.baidu.hugegraph.backend.id.Id;
import com.baidu.hugegraph.backend.query.IdQuery;
import com.baidu.hugegraph.backend.query.Query;
import com.baidu.hugegraph.backend.query.QueryResults;
import com.baidu.hugegraph.backend.store.BackendEntry;
import com.baidu.hugegraph.backend.tx.AbstractTransaction.QueryResults;
import com.baidu.hugegraph.config.CoreOptions;
import com.baidu.hugegraph.util.Bytes;
import com.baidu.hugegraph.util.CollectionUtil;
@ -267,7 +266,7 @@ public final class QueryList {
public static class PageIterator {
public static final PageIterator EMPTY = new PageIterator(
Collections.emptyIterator(),
QueryResults.emptyIterator(),
ImmutableList.of(Query.NONE),
PageState.EMPTY);

View File

@ -144,7 +144,7 @@ public final class ConditionQueryFlatten {
assert relation.relation() == Condition.RelationType.NOT_IN;
Object key = relation.key();
@SuppressWarnings("unchecked")
List<Object> values = (List<Object>) relation.value();
List<Object> values = (List<Object>) relation.value();
Condition cond;
Condition conds = null;
for (Object value : values) {

View File

@ -0,0 +1,198 @@
/*
* Copyright 2017 HugeGraph Authors
*
* 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 com.baidu.hugegraph.backend.query;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.function.Function;
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
import com.baidu.hugegraph.backend.id.Id;
import com.baidu.hugegraph.backend.store.BackendEntry;
import com.baidu.hugegraph.iterator.FlatMapperIterator;
import com.baidu.hugegraph.iterator.MapperIterator;
import com.baidu.hugegraph.iterator.Metadatable;
import com.baidu.hugegraph.type.Idfiable;
import com.baidu.hugegraph.util.E;
import com.baidu.hugegraph.util.InsertionOrderUtil;
public class QueryResults {
private static final Iterator<?> EMPTY_ITERATOR = new EmptyIterator<>();
private static final QueryResults EMPTY = new QueryResults(emptyIterator(),
Query.NONE);
private final Iterator<BackendEntry> results;
private final List<Query> queries;
public QueryResults(Iterator<BackendEntry> results, Query query) {
this(results);
this.addQuery(query);
}
public QueryResults(Iterator<BackendEntry> results) {
this.results = results;
this.queries = InsertionOrderUtil.newList();
}
public void setQuery(Query query) {
if (this.queries.size() > 0) {
this.queries.clear();
}
this.addQuery(query);
}
private void addQuery(Query query) {
E.checkNotNull(query, "query");
this.queries.add(query);
}
private void addQueries(List<Query> queries) {
for (Query query : queries) {
this.addQuery(query);
}
}
public Iterator<BackendEntry> iterator() {
return this.results;
}
public List<BackendEntry> list() {
return IteratorUtils.list(this.results);
}
public List<Query> queries() {
return Collections.unmodifiableList(this.queries);
}
public <T extends Idfiable> Iterator<T> keepInputOrderIfNeeded(
Iterator<T> origin) {
if (!origin.hasNext()) {
// None result found
return origin;
}
Set<Id> ids;
if (this.paging() || !this.mustSortByInputIds() ||
(ids = this.queryIds()).size() <= 1) {
/*
* Return the original iterator if it's paging query or if the
* query input is less than one id, or don't have to do sort.
*/
return origin;
}
// Fill map with all elements
Map<Id, T> results = new HashMap<>();
fillMap(origin, results);
return new MapperIterator<>(ids.iterator(), id -> {
return results.get(id);
});
}
private boolean mustSortByInputIds() {
if (this.queries.size() == 1) {
Query query = this.queries.get(0);
if (query instanceof IdQuery) {
return ((IdQuery) query).mustSortByInput();
}
}
return true;
}
private boolean paging() {
for (Query query : this.queries) {
Query origin = query.originQuery();
if (query.paging() || origin != null && origin.paging()) {
return true;
}
}
return false;
}
private Set<Id> queryIds() {
if (this.queries.size() == 1) {
return this.queries.get(0).ids();
}
Set<Id> ids = InsertionOrderUtil.newSet();
for (Query query : this.queries) {
ids.addAll(query.ids());
}
return ids;
}
public static <T extends Idfiable> void fillMap(Iterator<T> iterator,
Map<Id, T> map) {
while (iterator.hasNext()) {
T result = iterator.next();
assert result.id() != null;
map.put(result.id(), result);
}
}
public static <T> QueryResults flatMap(Iterator<T> iterator,
Function<T, QueryResults> func) {
QueryResults[] qr = new QueryResults[1];
qr[0] = new QueryResults(new FlatMapperIterator<>(iterator, i -> {
QueryResults results = func.apply(i);
if (results == null) {
return null;
}
qr[0].addQueries(results.queries());
return results.iterator();
}));
return qr[0];
}
public static QueryResults empty() {
return EMPTY;
}
@SuppressWarnings("unchecked")
public static <T> Iterator<T> emptyIterator() {
return (Iterator<T>) EMPTY_ITERATOR;
}
private static class EmptyIterator<E> implements Iterator<E>,
Metadatable {
@Override
public Object metadata(String meta, Object... args) {
return null;
}
@Override
public boolean hasNext() {
return false;
}
@Override
public E next() {
throw new NoSuchElementException();
}
}
}

View File

@ -276,15 +276,13 @@ public class BinarySerializer extends AbstractSerializer {
HugeEdge edge = new HugeEdge(graph, null, edgeLabel);
edge.name(sk);
edge.vertices(isOutEdge, vertex, otherVertex);
edge.assignId();
if (isOutEdge) {
edge.vertices(vertex, vertex, otherVertex);
edge.assignId();
vertex.addOutEdge(edge);
otherVertex.addInEdge(edge.switchOwner());
} else {
edge.vertices(vertex, otherVertex, vertex);
edge.assignId();
vertex.addInEdge(edge);
otherVertex.addOutEdge(edge.switchOwner());
}

View File

@ -167,15 +167,13 @@ public abstract class TableSerializer extends AbstractSerializer {
HugeEdge edge = new HugeEdge(graph, null, edgeLabel);
edge.name(sortValues);
edge.vertices(isOutEdge, vertex, otherVertex);
edge.assignId();
if (isOutEdge) {
edge.vertices(vertex, vertex, otherVertex);
edge.assignId();
vertex.addOutEdge(edge);
otherVertex.addInEdge(edge.switchOwner());
} else {
edge.vertices(vertex, otherVertex, vertex);
edge.assignId();
vertex.addInEdge(edge);
otherVertex.addOutEdge(edge.switchOwner());
}

View File

@ -187,15 +187,13 @@ public class TextSerializer extends AbstractSerializer {
HugeEdge edge = new HugeEdge(graph, null, label);
edge.name(colParts[2]);
edge.vertices(isOutEdge, vertex, otherVertex);
edge.assignId();
if (isOutEdge) {
edge.vertices(vertex, vertex, otherVertex);
edge.assignId();
vertex.addOutEdge(edge);
otherVertex.addInEdge(edge.switchOwner());
} else {
edge.vertices(vertex, otherVertex, vertex);
edge.assignId();
vertex.addInEdge(edge);
otherVertex.addOutEdge(edge.switchOwner());
}

View File

@ -20,7 +20,6 @@
package com.baidu.hugegraph.backend.store.memory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@ -34,6 +33,7 @@ import com.baidu.hugegraph.backend.query.Condition;
import com.baidu.hugegraph.backend.query.IdPrefixQuery;
import com.baidu.hugegraph.backend.query.IdRangeQuery;
import com.baidu.hugegraph.backend.query.Query;
import com.baidu.hugegraph.backend.query.QueryResults;
import com.baidu.hugegraph.backend.serializer.TextBackendEntry;
import com.baidu.hugegraph.backend.store.BackendEntry;
import com.baidu.hugegraph.backend.store.BackendSession;
@ -143,7 +143,7 @@ public class InMemoryDBTable extends BackendTable<BackendSession,
Iterator<BackendEntry> iterator = rs.values().iterator();
if (query.offset() >= rs.size()) {
return Collections.emptyIterator();
return QueryResults.emptyIterator();
}
iterator = this.skipOffset(iterator, query.offset());

View File

@ -40,6 +40,7 @@ import com.baidu.hugegraph.backend.query.Condition.RangeConditions;
import com.baidu.hugegraph.backend.query.ConditionQuery;
import com.baidu.hugegraph.backend.query.IdQuery;
import com.baidu.hugegraph.backend.query.Query;
import com.baidu.hugegraph.backend.query.QueryResults;
import com.baidu.hugegraph.backend.serializer.TextBackendEntry;
import com.baidu.hugegraph.backend.store.BackendEntry;
import com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn;
@ -289,7 +290,7 @@ public class InMemoryDBTables {
if (count == offset) {
return iter;
} else if (count < offset) {
return Collections.emptyIterator();
return QueryResults.emptyIterator();
}
// Collect edges that are over-skipped
@ -496,7 +497,7 @@ public class InMemoryDBTables {
max = keyMaxEq ? rs.floorKey(max) : rs.lowerKey(max);
if (max == null) {
return Collections.emptyIterator();
return QueryResults.emptyIterator();
}
Map<Id, BackendEntry> results = InsertionOrderUtil.newMap();

View File

@ -19,15 +19,8 @@
package com.baidu.hugegraph.backend.tx;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
import org.slf4j.Logger;
import com.baidu.hugegraph.HugeGraph;
@ -36,19 +29,16 @@ import com.baidu.hugegraph.backend.Transaction;
import com.baidu.hugegraph.backend.id.Id;
import com.baidu.hugegraph.backend.query.IdQuery;
import com.baidu.hugegraph.backend.query.Query;
import com.baidu.hugegraph.backend.query.QueryResults;
import com.baidu.hugegraph.backend.serializer.AbstractSerializer;
import com.baidu.hugegraph.backend.store.BackendEntry;
import com.baidu.hugegraph.backend.store.BackendMutation;
import com.baidu.hugegraph.backend.store.BackendStore;
import com.baidu.hugegraph.exception.NotFoundException;
import com.baidu.hugegraph.iterator.FlatMapperIterator;
import com.baidu.hugegraph.iterator.MapperIterator;
import com.baidu.hugegraph.perf.PerfUtil.Watched;
import com.baidu.hugegraph.type.HugeType;
import com.baidu.hugegraph.type.Idfiable;
import com.baidu.hugegraph.type.define.Action;
import com.baidu.hugegraph.util.E;
import com.baidu.hugegraph.util.InsertionOrderUtil;
import com.baidu.hugegraph.util.Log;
import com.google.common.util.concurrent.RateLimiter;
@ -344,138 +334,4 @@ public abstract class AbstractTransaction implements Transaction {
E.checkNotNull(entry, "entry");
this.mutation.add(entry, action);
}
public static class QueryResults {
private static final QueryResults EMPTY = new QueryResults(
Collections.emptyIterator(),
Query.NONE);
private final Iterator<BackendEntry> results;
private final List<Query> queries;
public QueryResults(Iterator<BackendEntry> results, Query query) {
this(results);
this.addQuery(query);
}
public QueryResults(Iterator<BackendEntry> results) {
this.results = results;
this.queries = InsertionOrderUtil.newList();
}
public void setQuery(Query query) {
if (this.queries.size() > 0) {
this.queries.clear();
}
this.addQuery(query);
}
private void addQuery(Query query) {
E.checkNotNull(query, "query");
this.queries.add(query);
}
private void addQueries(List<Query> queries) {
for (Query query : queries) {
this.addQuery(query);
}
}
public Iterator<BackendEntry> iterator() {
return this.results;
}
public List<BackendEntry> list() {
return IteratorUtils.list(this.results);
}
public List<Query> queries() {
return Collections.unmodifiableList(this.queries);
}
protected <T extends Idfiable> Iterator<T> keepInputOrderIfNeeded(
Iterator<T> origin) {
if (!origin.hasNext()) {
// None result found
return origin;
}
Set<Id> ids;
if (this.paging() || !this.mustSortByInputIds() ||
(ids = this.queryIds()).size() <= 1) {
/*
* Return the original iterator if it's paging query or if the
* query input is less than one id, or don't have to do sort.
*/
return origin;
}
// Fill map with all elements
Map<Id, T> results = new HashMap<>();
fillMap(origin, results);
return new MapperIterator<>(ids.iterator(), id -> {
return results.get(id);
});
}
private boolean mustSortByInputIds() {
if (this.queries.size() == 1) {
Query query = this.queries.get(0);
if (query instanceof IdQuery) {
return ((IdQuery) query).mustSortByInput();
}
}
return true;
}
private boolean paging() {
for (Query query : this.queries) {
Query origin = query.originQuery();
if (query.paging() || origin != null && origin.paging()) {
return true;
}
}
return false;
}
private Set<Id> queryIds() {
if (this.queries.size() == 1) {
return this.queries.get(0).ids();
}
Set<Id> ids = InsertionOrderUtil.newSet();
for (Query query : this.queries) {
ids.addAll(query.ids());
}
return ids;
}
public static <T extends Idfiable> void fillMap(Iterator<T> iterator,
Map<Id, T> map) {
while (iterator.hasNext()) {
T result = iterator.next();
assert result.id() != null;
map.put(result.id(), result);
}
}
public static QueryResults empty() {
return EMPTY;
}
public static <T> QueryResults flatMap(Iterator<T> iterator,
Function<T, QueryResults> func) {
QueryResults[] qr = new QueryResults[1];
qr[0] = new QueryResults(new FlatMapperIterator<>(iterator, i -> {
QueryResults results = func.apply(i);
if (results == null) {
return null;
}
qr[0].addQueries(results.queries());
return results.iterator();
}));
return qr[0];
}
}
}

View File

@ -22,7 +22,6 @@ package com.baidu.hugegraph.backend.tx;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@ -54,6 +53,7 @@ import com.baidu.hugegraph.backend.query.ConditionQuery;
import com.baidu.hugegraph.backend.query.ConditionQueryFlatten;
import com.baidu.hugegraph.backend.query.IdQuery;
import com.baidu.hugegraph.backend.query.Query;
import com.baidu.hugegraph.backend.query.QueryResults;
import com.baidu.hugegraph.backend.store.BackendEntry;
import com.baidu.hugegraph.backend.store.BackendMutation;
import com.baidu.hugegraph.backend.store.BackendStore;
@ -386,8 +386,7 @@ public class GraphTransaction extends IndexableTransaction {
return super.query(query);
}
QueryList queries = new QueryList(this.graph(), query,
q -> super.query(q));
QueryList queries = new QueryList(this.graph(), query, super::query);
for (ConditionQuery cq: ConditionQueryFlatten.flatten(
(ConditionQuery) query)) {
Query q = this.optimizeQuery(cq);
@ -489,7 +488,7 @@ public class GraphTransaction extends IndexableTransaction {
public Iterator<Vertex> queryAdjacentVertices(Iterator<Edge> edges) {
if (!edges.hasNext()) {
return Collections.emptyIterator();
return QueryResults.emptyIterator();
}
List<Id> vertexIds = new ArrayList<>();

View File

@ -25,6 +25,7 @@ import com.baidu.hugegraph.HugeGraph;
import com.baidu.hugegraph.backend.query.ConditionQuery;
import com.baidu.hugegraph.backend.query.IdQuery;
import com.baidu.hugegraph.backend.query.Query;
import com.baidu.hugegraph.backend.query.QueryResults;
import com.baidu.hugegraph.backend.store.BackendEntry;
import com.baidu.hugegraph.backend.store.BackendStore;
import com.baidu.hugegraph.perf.PerfUtil.Watched;

View File

@ -60,6 +60,8 @@ public class HugeGraphSONModule extends TinkerPopJacksonModule {
private static final long serialVersionUID = 6480426922914059122L;
public static boolean OPTIMIZE_SERIALIZE = true;
private static final String TYPE_NAMESPACE = "hugegraph";
@SuppressWarnings("rawtypes")
@ -127,15 +129,15 @@ public class HugeGraphSONModule extends TinkerPopJacksonModule {
addSerializer(EdgeLabel.class, new EdgeLabelSerializer());
addSerializer(IndexLabel.class, new IndexLabelSerializer());
addSerializer(HugeVertex.class, new HugeVertexSerializer());
/*
* Use customized edge serializer need to be compatible with V1 and V2
* Graphson, and seems need to implement edge deserializerit is
* a little complicated.
* Honestly, I don't know why there is no problem with vertex serializer
*/
// addSerializer(HugeEdge.class, new HugeEdgeSerializer());
if (OPTIMIZE_SERIALIZE) {
/*
* Use customized serializer need to be compatible with V1 and V2
* Graphson, and seems need to implement edge deserializerit is
* a little complicated.
*/
addSerializer(HugeVertex.class, new HugeVertexSerializer());
addSerializer(HugeEdge.class, new HugeEdgeSerializer());
}
addSerializer(Shard.class, new ShardSerializer());
}

View File

@ -19,38 +19,51 @@
package com.baidu.hugegraph.plugin;
import java.io.IOException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin;
import org.apache.tinkerpop.gremlin.groovy.plugin.PluginAcceptor;
import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer;
import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer;
import org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin;
import com.baidu.hugegraph.io.HugeGraphIoRegistry;
import com.baidu.hugegraph.traversal.optimize.Text;
import com.google.common.collect.ImmutableSet;
import com.baidu.hugegraph.HugeException;
import com.baidu.hugegraph.util.ReflectionUtil;
import com.google.common.reflect.ClassPath;
@SuppressWarnings("deprecation") // TODO: use new Plugin API
public class HugeGraphGremlinPlugin implements GremlinPlugin {
public class HugeGraphGremlinPlugin extends AbstractGremlinPlugin {
private static final String IMPORT = "import ";
private static final String DOT_STAR = ".*";
private static final String PACKAGE = "com.baidu.hugegraph";
private static final String NAME = "com.baidu.hugegraph";
private static final Set<String> IMPORTS = ImmutableSet.of(
IMPORT + "com.baidu.hugegraph" + DOT_STAR,
IMPORT + HugeGraphIoRegistry.class.getName(),
IMPORT + Text.class.getName());
private static final HugeGraphGremlinPlugin instance;
private static final ImportCustomizer imports;
@Override
public String getName() {
return "com.baidu.hugegraph";
static {
instance = new HugeGraphGremlinPlugin();
Iterator<ClassPath.ClassInfo> classInfos;
try {
classInfos = ReflectionUtil.classes(PACKAGE);
} catch (IOException e) {
throw new HugeException("Failed to scan classes under package %s",
PACKAGE);
}
Set<Class> classes = new HashSet<>();
classInfos.forEachRemaining(classInfo -> classes.add(classInfo.load()));
imports = DefaultImportCustomizer.build()
.addClassImports(classes)
.create();
}
@Override
public void pluginTo(final PluginAcceptor pluginAcceptor) {
pluginAcceptor.addImports(IMPORTS);
public HugeGraphGremlinPlugin() {
super(NAME, imports);
}
@Override
public boolean requireRestart() {
return true;
public static HugeGraphGremlinPlugin instance() {
return instance;
}
}

View File

@ -45,6 +45,10 @@ public class HugeSecurityManager extends SecurityManager {
"org.codehaus.groovy.runtime.callsite.CallSiteClassLoader"
);
private static final Set<String> CAFFEINE_CLASSES = ImmutableSet.of(
"com.github.benmanes.caffeine.cache.BoundedLocalCache"
);
private static final Set<String> WHITE_SYSTEM_PROPERTYS = ImmutableSet.of(
"line.separator",
"file.separator"
@ -132,7 +136,7 @@ public class HugeSecurityManager extends SecurityManager {
@Override
public void checkRead(String file) {
if (callFromGremlin()) {
if (callFromGremlin() && !callFromCaffeine()) {
throw new SecurityException("Not allowed to read file via Gremlin");
}
super.checkRead(file);
@ -314,9 +318,7 @@ public class HugeSecurityManager extends SecurityManager {
}
private static boolean callFromCaffeine() {
String clazz = "com.github.benmanes.caffeine.cache.BoundedLocalCache";
String method = "scheduleDrainBuffers";
return callFromMethod(clazz, method);
return callFromWorkerWithClass(CAFFEINE_CLASSES);
}
private static boolean callFromWorkerWithClass(Set<String> classes) {
@ -334,6 +336,7 @@ public class HugeSecurityManager extends SecurityManager {
return false;
}
@SuppressWarnings("unused")
private static boolean callFromMethod(String clazz, String method) {
Thread curThread = Thread.currentThread();
StackTraceElement[] elements = curThread.getStackTrace();

View File

@ -52,15 +52,16 @@ public class HugeEdge extends HugeElement implements Edge, Cloneable {
protected EdgeLabel label;
protected String name;
// The Vertex who owned me
protected HugeVertex ownerVertex;
protected HugeVertex sourceVertex;
protected HugeVertex targetVertex;
protected boolean isOutEdge;
public HugeEdge(final HugeVertex owner, Id id, EdgeLabel label) {
this(owner.graph(), id, label);
this.ownerVertex = owner;
public HugeEdge(HugeVertex sourceVertex, Id id, EdgeLabel label,
HugeVertex targetVertex) {
this(sourceVertex.graph(), id, label);
this.sourceVertex = sourceVertex;
this.targetVertex = targetVertex;
this.isOutEdge = true;
this.fresh = true;
}
@ -71,17 +72,15 @@ public class HugeEdge extends HugeElement implements Edge, Cloneable {
this.label = label;
this.name = null;
this.ownerVertex = null;
this.sourceVertex = null;
this.targetVertex = null;
this.isOutEdge = true;
}
@Override
public HugeType type() {
// NOTE: we optimize the edge type that let it include direction
return this.ownerVertex == this.sourceVertex ?
HugeType.EDGE_OUT :
HugeType.EDGE_IN;
return this.isOutEdge ? HugeType.EDGE_OUT : HugeType.EDGE_IN;
}
@Override
@ -119,30 +118,25 @@ public class HugeEdge extends HugeElement implements Edge, Cloneable {
return this.label.name();
}
public boolean selfLoop() {
return this.sourceVertex != null &&
this.sourceVertex == this.targetVertex;
}
public Directions direction() {
if (this.ownerVertex == this.sourceVertex) {
return Directions.OUT;
} else {
assert this.ownerVertex == this.targetVertex;
return Directions.IN;
}
return this.isOutEdge ? Directions.OUT : Directions.IN;
}
public boolean matchDirection(Directions direction) {
if (direction == Directions.BOTH) {
if (direction == Directions.BOTH || this.selfLoop()) {
return true;
}
return this.isDirection(direction);
}
public boolean isDirection(Directions direction) {
// NOTE: self-loop edge will match both OUT and IN
if (direction == Directions.OUT) {
return this.ownerVertex == this.sourceVertex;
} else if (direction == Directions.IN) {
return this.ownerVertex == this.targetVertex;
}
return false;
return this.isOutEdge && direction == Directions.OUT ||
!this.isOutEdge && direction == Directions.IN;
}
@Watched(prefix = "edge")
@ -329,30 +323,22 @@ public class HugeEdge extends HugeElement implements Edge, Cloneable {
return this.targetVertex;
}
public void vertices(HugeVertex source, HugeVertex target) {
// The default owner is the source vertex
this.ownerVertex = source;
this.sourceVertex = source;
this.targetVertex = target;
}
public void vertices(HugeVertex owner,
HugeVertex source,
HugeVertex target) {
this.ownerVertex = owner;
this.sourceVertex = source;
this.targetVertex = target;
public void vertices(boolean isOutEdge,
HugeVertex owner,
HugeVertex other) {
this.isOutEdge = isOutEdge;
if (isOutEdge) {
this.sourceVertex = owner;
this.targetVertex = other;
} else {
this.sourceVertex = other;
this.targetVertex = owner;
}
}
public HugeEdge switchOwner() {
HugeEdge edge = this.clone();
if (edge.ownerVertex == edge.sourceVertex) {
edge.ownerVertex = edge.targetVertex;
} else {
assert edge.ownerVertex == this.targetVertex;
edge.ownerVertex = edge.sourceVertex;
}
edge.isOutEdge = !edge.isOutEdge;
edge.assignId();
return edge;
}
@ -365,13 +351,7 @@ public class HugeEdge extends HugeElement implements Edge, Cloneable {
}
public HugeVertex ownerVertex() {
return this.ownerVertex;
}
public void ownerVertex(HugeVertex owner) {
E.checkState(owner == this.sourceVertex || owner == this.targetVertex,
"The owner vertex must be sourceVertex or targetVertex");
this.ownerVertex = owner;
return this.isOutEdge ? this.sourceVertex : this.targetVertex;
}
public HugeVertex sourceVertex() {
@ -421,7 +401,7 @@ public class HugeEdge extends HugeElement implements Edge, Cloneable {
}
public HugeVertex otherVertex() {
return this.otherVertex(this.ownerVertex);
return this.isOutEdge ? this.targetVertex : this.sourceVertex;
}
/**

View File

@ -169,11 +169,6 @@ public class HugeFeatures implements Graph.Features {
public class HugeVertexPropertyFeatures extends HugeDataTypeFeatures
implements VertexPropertyFeatures {
@Override
public boolean supportsAddProperty() {
return true;
}
@Override
public boolean supportsRemoveProperty() {
return true;

View File

@ -287,9 +287,7 @@ public class HugeVertex extends HugeElement implements Vertex, Cloneable {
this.graph().mapPkId2Name(missed));
}
HugeEdge edge = new HugeEdge(this, id, edgeLabel);
edge.vertices(this, targetVertex);
HugeEdge edge = new HugeEdge(this, id, edgeLabel, targetVertex);
// Set properties
ElementHelper.attachProperties(edge, keyValues);
@ -313,7 +311,6 @@ public class HugeVertex extends HugeElement implements Vertex, Cloneable {
public void addOutEdge(HugeEdge edge) {
if (edge.ownerVertex() == null) {
edge.sourceVertex(this);
edge.ownerVertex(this);
}
E.checkState(edge.isDirection(Directions.OUT),
"The owner vertex('%s') of OUT edge '%s' should be '%s'",
@ -328,7 +325,6 @@ public class HugeVertex extends HugeElement implements Vertex, Cloneable {
public void addInEdge(HugeEdge edge) {
if (edge.ownerVertex() == null) {
edge.targetVertex(this);
edge.ownerVertex(this);
}
E.checkState(edge.isDirection(Directions.IN),
"The owner vertex('%s') of IN edge '%s' should be '%s'",

View File

@ -30,6 +30,7 @@ import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
import com.baidu.hugegraph.HugeGraph;
import com.baidu.hugegraph.backend.id.Id;
import com.baidu.hugegraph.backend.query.QueryResults;
import com.baidu.hugegraph.structure.HugeEdge;
import com.baidu.hugegraph.type.define.Directions;
import com.baidu.hugegraph.util.E;
@ -219,7 +220,7 @@ public class ShortestPathTraverser extends HugeTraverser {
edgeList.add(edges.next());
}
if (i >= this.skipDegree) {
return Collections.emptyIterator();
return QueryResults.emptyIterator();
}
}
return edgeList.iterator();

View File

@ -34,6 +34,7 @@ import org.slf4j.Logger;
import com.baidu.hugegraph.HugeGraph;
import com.baidu.hugegraph.backend.query.ConditionQuery;
import com.baidu.hugegraph.backend.query.Query;
import com.baidu.hugegraph.backend.query.QueryResults;
import com.baidu.hugegraph.type.HugeType;
import com.baidu.hugegraph.util.Log;
@ -73,7 +74,11 @@ public final class HugeGraphStep<S, E extends Element>
LOG.debug("HugeGraphStep.vertices(): {}", this);
HugeGraph graph = (HugeGraph) this.getTraversal().getGraph().get();
if (this.ids != null && this.ids.length > 0) {
// g.V().hasId(EMPTY_LIST) will set ids to null
if (this.ids == null) {
return QueryResults.emptyIterator();
}
if (this.ids.length > 0) {
return TraversalUtil.filterResult(this.hasContainers,
graph.vertices(this.ids));
}

View File

@ -51,7 +51,7 @@ public final class HugeVertexStep<E extends Element>
private static final Logger LOG = Log.logger(HugeVertexStep.class);
private final List<HasContainer> hasContainers = new ArrayList<>();;
private final List<HasContainer> hasContainers = new ArrayList<>();
// Store limit/order-by
private final Query queryInfo = new Query(null);

View File

@ -20,6 +20,7 @@
package com.baidu.hugegraph.traversal.optimize;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.function.BiPredicate;
@ -362,7 +363,7 @@ public final class TraversalUtil {
HasContainer has) {
BiPredicate<?, ?> bp = has.getPredicate().getBiPredicate();
assert bp instanceof Contains;
List<?> values = (List<?>) has.getValue();
Collection<?> values = (Collection<?>) has.getValue();
String originKey = has.getKey();
if (values.size() > 1) {
@ -379,24 +380,25 @@ public final class TraversalUtil {
// Ignore
}
List<?> valueList;
if (hugeKey != null) {
values = convSysListValueIfNeeded(graph, type, hugeKey, values);
valueList = convSysListValueIfNeeded(graph, type, hugeKey, values);
switch ((Contains) bp) {
case within:
return Condition.in(hugeKey, values);
return Condition.in(hugeKey, valueList);
case without:
return Condition.nin(hugeKey, values);
return Condition.nin(hugeKey, valueList);
}
} else {
valueList = new ArrayList<>(values);
String key = has.getKey();
PropertyKey pkey = graph.propertyKey(key);
switch ((Contains) bp) {
case within:
return Condition.in(pkey.id(), values);
return Condition.in(pkey.id(), valueList);
case without:
return Condition.nin(pkey.id(), values);
return Condition.nin(pkey.id(), valueList);
}
}
@ -539,7 +541,7 @@ public final class TraversalUtil {
private static List<?> convSysListValueIfNeeded(HugeGraph graph,
HugeType type,
HugeKeys key,
List<?> values) {
Collection<?> values) {
List<Object> newValues = new ArrayList<>(values.size());
for (Object value : values) {
newValues.add(convSysValueIfNeeded(graph, type, key, value));

View File

@ -65,6 +65,10 @@ public final class DateUtil {
return dateFormat.parse(value);
}
public static Date now() {
return new Date();
}
private static SafeDateFormat getDateFormat(String df) {
SafeDateFormat dateFormat = DATE_FORMATS.get(df);
if (dateFormat == null) {

View File

@ -33,9 +33,9 @@ public class CoreVersion {
// The second parameter of Version.of() is for IDE running without JAR
public static final Version VERSION = Version.of(CoreVersion.class,
"0.10.3");
"0.10.4");
public static final String GREMLIN_VERSION = "3.2.5";
public static final String GREMLIN_VERSION = "3.4.3";
public static void check() {
// Check version of hugegraph-common

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>hugegraph</artifactId>
<groupId>com.baidu.hugegraph</groupId>
<version>0.10.3</version>
<version>0.10.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>hugegraph-dist</name>

View File

@ -5,13 +5,19 @@ channelizer: org.apache.tinkerpop.gremlin.server.channel.HttpChannelizer
graphs: {
hugegraph: conf/hugegraph.properties
}
plugins:
- com.baidu.hugegraph
scriptEngines: {
gremlin-groovy: {
imports: [java.lang.Math],
staticImports: [java.lang.Math.PI],
scripts: [scripts/empty-sample.groovy]
plugins: {
com.baidu.hugegraph.plugin.HugeGraphGremlinPlugin: {},
org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {},
org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {
classImports: [java.lang.Math, com.baidu.hugegraph.util.DateUtil],
methodImports: [java.lang.Math#*]
},
org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {
files: [scripts/empty-sample.groovy]
}
}
}
}
serializers:
@ -20,31 +26,31 @@ serializers:
serializeResultToString: false,
ioRegistries: [com.baidu.hugegraph.io.HugeGraphIoRegistry]
}
}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0,
config: {
serializeResultToString: true,
ioRegistries: [com.baidu.hugegraph.io.HugeGraphIoRegistry]
}
}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0,
}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1,
config: {
serializeResultToString: false,
ioRegistries: [com.baidu.hugegraph.io.HugeGraphIoRegistry]
}
}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0,
config: {
serializeResultToString: false,
ioRegistries: [com.baidu.hugegraph.io.HugeGraphIoRegistry]
}
}
}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
config: {
serializeResultToString: false,
ioRegistries: [com.baidu.hugegraph.io.HugeGraphIoRegistry]
}
}
}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV2d0,
config: {
serializeResultToString: false,
ioRegistries: [com.baidu.hugegraph.io.HugeGraphIoRegistry]
}
}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0,
config: {
serializeResultToString: false,
ioRegistries: [com.baidu.hugegraph.io.HugeGraphIoRegistry]
}
}
metrics: {
consoleReporter: {enabled: false, interval: 180000},
csvReporter: {enabled: true, interval: 180000, fileName: /tmp/gremlin-server-metrics.csv},

View File

@ -36,6 +36,9 @@ public class HugeGraphServer {
public HugeGraphServer(String gremlinServerConf, String restServerConf)
throws Exception {
// Only switch on security manager after HugeGremlinServer started
SecurityManager securityManager = System.getSecurityManager();
System.setSecurityManager(null);
try {
// Start GremlinServer
this.gremlinServer = HugeGremlinServer.start(gremlinServerConf);
@ -43,6 +46,8 @@ public class HugeGraphServer {
LOG.error("HugeGremlinServer start error: ", e);
HugeGraph.shutdown(30L);
throw e;
} finally {
System.setSecurityManager(securityManager);
}
try {

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>hugegraph</artifactId>
<groupId>com.baidu.hugegraph</groupId>
<version>0.10.3</version>
<version>0.10.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -39,7 +39,7 @@ public class Example2 {
private static final Logger LOG = Log.logger(Example2.class);
public static void main(String[] args) throws InterruptedException {
public static void main(String[] args) {
LOG.info("Example2 start!");
HugeGraph graph = ExampleUtil.loadGraph();
@ -147,7 +147,7 @@ public class Example2 {
schema.propertyKey("city").asText().ifNotExist().create();
schema.propertyKey("weight").asDouble().ifNotExist().create();
schema.propertyKey("lang").asText().ifNotExist().create();
schema.propertyKey("date").asText().ifNotExist().create();
schema.propertyKey("date").asDate().ifNotExist().create();
schema.propertyKey("price").asInt().ifNotExist().create();
schema.vertexLabel("person")
@ -205,7 +205,7 @@ public class Example2 {
schema.indexLabel("createdByDate")
.onE("created")
.by("date")
.secondary()
.range()
.ifNotExist()
.create();
@ -238,12 +238,12 @@ public class Example2 {
Vertex peter = graph.addVertex(T.label, "person", "name", "peter",
"age", 35, "city", "Shanghai");
marko.addEdge("knows", vadas, "date", "20160110", "weight", 0.5);
marko.addEdge("knows", josh, "date", "20130220", "weight", 1.0);
marko.addEdge("created", lop, "date", "20171210", "weight", 0.4);
josh.addEdge("created", lop, "date", "20091111", "weight", 0.4);
josh.addEdge("created", ripple, "date", "20171210", "weight", 1.0);
peter.addEdge("created", lop, "date", "20170324", "weight", 0.2);
marko.addEdge("knows", vadas, "date", "2016-01-10", "weight", 0.5);
marko.addEdge("knows", josh, "date", "2013-02-20", "weight", 1.0);
marko.addEdge("created", lop, "date", "2017-12-10", "weight", 0.4);
josh.addEdge("created", lop, "date", "2009-11-11", "weight", 0.4);
josh.addEdge("created", ripple, "date", "2017-12-10", "weight", 1.0);
peter.addEdge("created", lop, "date", "2017-03-24", "weight", 0.2);
graph.tx().commit();
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>hugegraph</artifactId>
<groupId>com.baidu.hugegraph</groupId>
<version>0.10.3</version>
<version>0.10.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>hugegraph</artifactId>
<groupId>com.baidu.hugegraph</groupId>
<version>0.10.3</version>
<version>0.10.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>hugegraph</artifactId>
<groupId>com.baidu.hugegraph</groupId>
<version>0.10.3</version>
<version>0.10.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>hugegraph</artifactId>
<groupId>com.baidu.hugegraph</groupId>
<version>0.10.3</version>
<version>0.10.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>hugegraph</artifactId>
<groupId>com.baidu.hugegraph</groupId>
<version>0.10.3</version>
<version>0.10.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>hugegraph</artifactId>
<groupId>com.baidu.hugegraph</groupId>
<version>0.10.3</version>
<version>0.10.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>hugegraph</artifactId>
<groupId>com.baidu.hugegraph</groupId>
<version>0.10.3</version>
<version>0.10.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -66,7 +66,7 @@
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-groovy-test</artifactId>
<version>${tinkerpop.version}</version>
<version>3.2.11</version>
</dependency>
<dependency>
@ -133,6 +133,8 @@
<execution>
<id>tinkerpop-process-test</id>
<configuration>
<!-- Tinkerpop process ReadTest.Traversals.class need write/read disk -->
<argLine>-Dbuild.dir=${project.build.directory}</argLine>
<testSourceDirectory>${basedir}/src/main/java/
</testSourceDirectory>
<testClassesDirectory>${basedir}/target/classes/
@ -142,30 +144,6 @@
</includes>
</configuration>
</execution>
<execution>
<id>tinkerpop-structure-perf-test</id>
<configuration>
<testSourceDirectory>${basedir}/src/main/java/
</testSourceDirectory>
<testClassesDirectory>${basedir}/target/classes/
</testClassesDirectory>
<includes>
<include>**/StructurePerformanceTest.java</include>
</includes>
</configuration>
</execution>
<execution>
<id>tinkerpop-process-perf-test</id>
<configuration>
<testSourceDirectory>${basedir}/src/main/java/
</testSourceDirectory>
<testClassesDirectory>${basedir}/target/classes/
</testClassesDirectory>
<includes>
<include>**/ProcessPerformanceTest.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
@ -192,7 +170,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<version>0.8.4</version>
<configuration>
<excludes>
<exclude>com/baidu/hugegraph/traversal/algorithm/*.class</exclude>

View File

@ -19,6 +19,7 @@
package com.baidu.hugegraph.core;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@ -753,21 +754,28 @@ public class EdgeCoreTest extends BaseCoreTest {
.range(1, 6)
.range(4, 8)
.toList();
// [4, 6)
Assert.assertEquals(2, edges.size());
// [5, 6)
Assert.assertEquals(1, edges.size());
edges = graph.traversal().E()
.range(1, -1)
.range(6, 8)
.toList();
// [6, 8)
// [7, 9)
Assert.assertEquals(2, edges.size());
edges = graph.traversal().E()
.range(1, 6)
.range(6, 8)
.toList();
// [6, 6)
// [7, 6) will be converted to NoneStep by EarlyLimitStrategy
Assert.assertEquals(0, edges.size());
edges = graph.traversal().E()
.range(1, 6)
.range(7, 8)
.toList();
// [8, 6) will be converted to NoneStep by EarlyLimitStrategy
Assert.assertEquals(0, edges.size());
}
@ -791,11 +799,6 @@ public class EdgeCoreTest extends BaseCoreTest {
Assert.assertThrows(IllegalArgumentException.class, () -> {
graph.traversal().E().range(-4, -2).toList();
});
Assert.assertThrows(IllegalArgumentException.class, () -> {
// [7, 6)
graph.traversal().E().range(1, 6).range(7, 8).toList();
});
}
@Test
@ -3869,6 +3872,32 @@ public class EdgeCoreTest extends BaseCoreTest {
});
}
@Test
public void testQueryByHasIdEmptyList() {
HugeGraph graph = graph();
GraphTraversalSource g = graph.traversal();
List<Edge> edges = g.E().hasId(Collections.EMPTY_LIST).toList();
Assert.assertEquals(0, edges.size());
}
@Test
public void testQueryByHasIdEmptyListInPage() {
Assume.assumeTrue("Not support paging",
storeFeatures().supportsQueryByPage());
HugeGraph graph = graph();
GraphTraversalSource g = graph.traversal();
GraphTraversal<Edge, Edge> iter = g.E()
.hasId(Collections.EMPTY_LIST)
.has("~page", "").limit(1);
Assert.assertEquals(0, IteratorUtils.count(iter));
String page = TraversalUtil.page(iter);
Assert.assertNull(page);
}
private void init18Edges() {
this.init18Edges(true);
}

View File

@ -20,6 +20,7 @@
package com.baidu.hugegraph.core;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
@ -996,21 +997,28 @@ public class VertexCoreTest extends BaseCoreTest {
.range(1, 6)
.range(4, 8)
.toList();
// [4, 6)
Assert.assertEquals(2, vertices.size());
// [5, 6)
Assert.assertEquals(1, vertices.size());
vertices = graph.traversal().V()
.range(1, -1)
.range(6, 8)
.toList();
// [6, 8)
// [7, 9)
Assert.assertEquals(2, vertices.size());
vertices = graph.traversal().V()
.range(1, 6)
.range(6, 8)
.toList();
// [6, 6)
// [7, 6) will be converted to NoneStep by EarlyLimitStrategy
Assert.assertEquals(0, vertices.size());
vertices = graph.traversal().V()
.range(1, 6)
.range(7, 8)
.toList();
// [8, 6) will be converted to NoneStep by EarlyLimitStrategy
Assert.assertEquals(0, vertices.size());
}
@ -1034,11 +1042,6 @@ public class VertexCoreTest extends BaseCoreTest {
Assert.assertThrows(IllegalArgumentException.class, () -> {
graph.traversal().V().range(-4, -2).toList();
});
Assert.assertThrows(IllegalArgumentException.class, () -> {
// [7, 6)
graph.traversal().V().range(1, 6).range(7, 8).toList();
});
}
@Test
@ -5549,6 +5552,32 @@ public class VertexCoreTest extends BaseCoreTest {
Assert.assertEquals(0, vertices.size());
}
@Test
public void testQueryByHasIdEmptyList() {
HugeGraph graph = graph();
GraphTraversalSource g = graph.traversal();
List<Vertex> vertices = g.V().hasId(Collections.EMPTY_LIST).toList();
Assert.assertEquals(0, vertices.size());
}
@Test
public void testQueryByHasIdEmptyListInPage() {
Assume.assumeTrue("Not support paging",
storeFeatures().supportsQueryByPage());
HugeGraph graph = graph();
GraphTraversalSource g = graph.traversal();
GraphTraversal<Vertex, Vertex> iter = g.V()
.hasId(Collections.EMPTY_LIST)
.has("~page", "").limit(1);
Assert.assertEquals(0, IteratorUtils.count(iter));
String page = TraversalUtil.page(iter);
Assert.assertNull(page);
}
private void init10Vertices() {
HugeGraph graph = graph();

View File

@ -19,7 +19,6 @@
package com.baidu.hugegraph.tinkerpop;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.tinkerpop.gremlin.AbstractGremlinSuite;
import org.apache.tinkerpop.gremlin.GraphManager;
import org.apache.tinkerpop.gremlin.GraphProvider;
@ -55,11 +54,11 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.FoldTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.IndexTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.LoopsTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.MapKeysTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.MapTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.MapValuesTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.MathTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.MaxTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.MeanTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.MinTest;
@ -68,16 +67,17 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.map.PathTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProjectTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertiesTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.SelectTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.SumTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.UnfoldTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.ValueMapTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.WriteTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.AggregateTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ExplainTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupCountTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTestV3d0;
import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SackTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectCapTest;
@ -90,6 +90,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventS
import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategyProcessTest;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategyProcessTest;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.TranslationStrategyProcessTest;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.EarlyLimitStrategyProcessTest;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.IncidentToAdjacentStrategyProcessTest;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategyProcessTest;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.RunnerBuilder;
@ -102,7 +104,6 @@ import com.baidu.hugegraph.dist.RegisterUtil;
*
* @author Stephen Mallette (http://stephen.genoprime.com)
*/
@SuppressWarnings("deprecation")
public class ProcessBasicSuite extends AbstractGremlinSuite {
/**
* This list of tests in the suite that will be executed
@ -143,11 +144,11 @@ public class ProcessBasicSuite extends AbstractGremlinSuite {
FoldTest.Traversals.class,
GraphTest.Traversals.class,
LoopsTest.Traversals.class,
IndexTest.Traversals.class,
MapTest.Traversals.class,
MapKeysTest.Traversals.class,
MapValuesTest.Traversals.class,
MatchTest.CountMatchTraversals.class,
MatchTest.GreedyMatchTraversals.class,
MathTest.Traversals.class,
MaxTest.Traversals.class,
MeanTest.Traversals.class,
MinTest.Traversals.class,
@ -157,16 +158,17 @@ public class ProcessBasicSuite extends AbstractGremlinSuite {
ProfileTest.Traversals.class,
ProjectTest.Traversals.class,
PropertiesTest.Traversals.class,
ReadTest.Traversals.class,
SelectTest.Traversals.class,
VertexTest.Traversals.class,
UnfoldTest.Traversals.class,
ValueMapTest.Traversals.class,
WriteTest.Traversals.class,
// sideEffect
AggregateTest.Traversals.class,
ExplainTest.Traversals.class,
GroupTest.Traversals.class,
GroupTestV3d0.Traversals.class,
GroupCountTest.Traversals.class,
InjectTest.Traversals.class,
SackTest.Traversals.class,
@ -189,7 +191,11 @@ public class ProcessBasicSuite extends AbstractGremlinSuite {
EventStrategyProcessTest.class,
ReadOnlyStrategyProcessTest.class,
PartitionStrategyProcessTest.class,
SubgraphStrategyProcessTest.class
SubgraphStrategyProcessTest.class,
// optimizations
IncidentToAdjacentStrategyProcessTest.class,
EarlyLimitStrategyProcessTest.class
};
/**
@ -230,10 +236,10 @@ public class ProcessBasicSuite extends AbstractGremlinSuite {
FlatMapTest.class,
FoldTest.class,
LoopsTest.class,
IndexTest.class,
MapTest.class,
MapKeysTest.class,
MapValuesTest.class,
MatchTest.class,
MathTest.class,
MaxTest.class,
MeanTest.class,
MinTest.class,
@ -258,13 +264,12 @@ public class ProcessBasicSuite extends AbstractGremlinSuite {
SideEffectTest.class,
StoreTest.class,
SubgraphTest.class,
TreeTest.class,
TreeTest.class
};
public ProcessBasicSuite(final Class<?> klass,
final RunnerBuilder builder)
throws InitializationError,
ConfigurationException {
throws InitializationError {
super(klass, builder, allTests, testsToEnforce, true,
TraversalEngine.Type.STANDARD);
RegisterUtil.registerBackends();
@ -273,8 +278,7 @@ public class ProcessBasicSuite extends AbstractGremlinSuite {
public ProcessBasicSuite(final Class<?> klass,
final RunnerBuilder builder,
final Class<?>[] testsToExecute)
throws InitializationError,
ConfigurationException {
throws InitializationError {
super(klass, builder, testsToExecute, testsToEnforce, true,
TraversalEngine.Type.STANDARD);
RegisterUtil.registerBackends();

View File

@ -1,83 +0,0 @@
/*
* 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 com.baidu.hugegraph.tinkerpop;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.tinkerpop.gremlin.AbstractGremlinSuite;
import org.apache.tinkerpop.gremlin.GraphManager;
import org.apache.tinkerpop.gremlin.GraphProvider;
import org.apache.tinkerpop.gremlin.process.TraversalPerformanceTest;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.StructureStandardSuite;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.RunnerBuilder;
import org.junit.runners.model.Statement;
import com.baidu.hugegraph.dist.RegisterUtil;
/**
* The {@code ProcessPerformanceSuite} is a JUnit test runner that executes the
* Gremlin Test Suite over a Graph implementation. This suite contains
* "long-run" tests that produce reports on the traversal execution
* performance of a vendor implementation {@link Graph}. Its usage is optional
* to providers as the tests are somewhat redundant to those found elsewhere
* in other required test suites.
* For more information on the usage of this suite,
* please see {@link StructureStandardSuite}.
*
* @author Stephen Mallette (http://stephen.genoprime.com)
* @deprecated As of release 3.2.0-incubating, replaced by gremlin-benchmark.
*/
@Deprecated
public class ProcessPerformanceSuite extends AbstractGremlinSuite {
/**
* This list of tests in the suite that will be executed.
* Gremlin developers should add to this list
* as needed to enforce tests upon implementations.
*/
private static final Class<?>[] allTests = new Class<?>[]{
TraversalPerformanceTest.class
};
public ProcessPerformanceSuite(final Class<?> klass,
final RunnerBuilder builder)
throws InitializationError,
ConfigurationException {
super(klass, builder, allTests, null, true,
TraversalEngine.Type.STANDARD);
RegisterUtil.registerBackends();
}
@Override
protected Statement withAfterClasses(final Statement statement) {
Statement wrappedStatement = new Statement() {
@Override
public void evaluate() throws Throwable {
statement.evaluate();
GraphProvider gp = GraphManager.setGraphProvider(null);
((TestGraphProvider) gp).clear();
GraphManager.setGraphProvider(gp);
}
};
return super.withAfterClasses(wrappedStatement);
}
}

View File

@ -1,31 +0,0 @@
/*
* 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 com.baidu.hugegraph.tinkerpop;
import org.apache.tinkerpop.gremlin.GraphProviderClass;
import org.junit.runner.RunWith;
@RunWith(ProcessPerformanceSuite.class)
@GraphProviderClass(provider = ProcessTestGraphProvider.class,
graph = TestGraph.class)
@SuppressWarnings("deprecation")
public class ProcessPerformanceTest {
}

View File

@ -1,85 +0,0 @@
/*
* 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 com.baidu.hugegraph.tinkerpop;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.tinkerpop.gremlin.AbstractGremlinSuite;
import org.apache.tinkerpop.gremlin.GraphManager;
import org.apache.tinkerpop.gremlin.GraphProvider;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.GraphReadPerformanceTest;
import org.apache.tinkerpop.gremlin.structure.GraphWritePerformanceTest;
import org.apache.tinkerpop.gremlin.structure.StructureStandardSuite;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.RunnerBuilder;
import org.junit.runners.model.Statement;
import com.baidu.hugegraph.dist.RegisterUtil;
/**
* The {@code StructurePerformanceSuite} is a JUnit test runner that executes
* the Gremlin Test Suite over a {@link Graph} implementation. This suite
* contains "long-run" tests that produce reports on the read/write
* performance of a providers implementation {@link Graph}. Its usage is
* optional to providers as the tests are somewhat redundant to those found
* elsewhere in other required test suites.
* For more information on the usage of this suite,
* please see {@link StructureStandardSuite}.
*
* @author Stephen Mallette (http://stephen.genoprime.com)
* @deprecated As of release 3.2.1, replaced by gremlin-benchmark.
*/
@Deprecated
public class StructurePerformanceSuite extends AbstractGremlinSuite {
/**
* This list of tests in the suite that will be executed.
* Gremlin developers should add to this list
* as needed to enforce tests upon implementations.
*/
private static final Class<?>[] allTests = new Class<?>[]{
GraphWritePerformanceTest.class,
GraphReadPerformanceTest.class
};
public StructurePerformanceSuite(final Class<?> klass,
final RunnerBuilder builder)
throws InitializationError,
ConfigurationException {
super(klass, builder, allTests, null, true,
TraversalEngine.Type.STANDARD);
RegisterUtil.registerBackends();
}
@Override
protected Statement withAfterClasses(final Statement statement) {
Statement wrappedStatement = new Statement() {
@Override
public void evaluate() throws Throwable {
statement.evaluate();
GraphProvider gp = GraphManager.setGraphProvider(null);
((TestGraphProvider) gp).clear();
GraphManager.setGraphProvider(gp);
}
};
return super.withAfterClasses(wrappedStatement);
}
}

View File

@ -1,30 +0,0 @@
/*
* 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 com.baidu.hugegraph.tinkerpop;
import org.apache.tinkerpop.gremlin.GraphProviderClass;
import org.junit.runner.RunWith;
@RunWith(StructurePerformanceSuite.class)
@GraphProviderClass(provider = StructureTestGraphProvider.class,
graph = TestGraph.class)
@SuppressWarnings("deprecation")
public class StructurePerformanceTest {
}

View File

@ -36,6 +36,7 @@ import org.apache.tinkerpop.gremlin.structure.io.Io;
import com.baidu.hugegraph.HugeGraph;
import com.baidu.hugegraph.io.HugeGraphIoRegistry;
import com.baidu.hugegraph.io.HugeGraphSONModule;
import com.baidu.hugegraph.perf.PerfUtil.Watched;
import com.baidu.hugegraph.schema.PropertyKey;
import com.baidu.hugegraph.schema.SchemaManager;
@ -231,6 +232,7 @@ public class TestGraph implements Graph {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public <I extends Io> I io(final Io.Builder<I> builder) {
HugeGraphSONModule.OPTIMIZE_SERIALIZE = false;
return (I) builder.graph(this).onMapper(mapper ->
mapper.addRegistry(HugeGraphIoRegistry.instance())
).create();
@ -322,6 +324,10 @@ public class TestGraph implements Graph {
case "String":
schema.propertyKey(key).ifNotExist().create();
break;
case "BooleanArray":
schema.propertyKey(key).asBoolean().valueList()
.ifNotExist().create();
break;
case "IntegerArray":
schema.propertyKey(key).asInt().valueList()
.ifNotExist().create();
@ -352,7 +358,6 @@ public class TestGraph implements Graph {
throw new RuntimeException(
String.format("Wrong type %s for %s", type, key));
}
}
@Watched
@ -430,12 +435,15 @@ public class TestGraph implements Graph {
schema.propertyKey("marko").ifNotExist().create();
schema.propertyKey("ripple").ifNotExist().create();
schema.propertyKey("lop").ifNotExist().create();
schema.propertyKey("test").ifNotExist().create();
switch (idStrategy) {
case AUTOMATIC:
schema.vertexLabel("name")
.ifNotExist().create();
schema.vertexLabel("person")
.properties("name", "age")
.nullableKeys("name", "age")
.properties("name", "age", "test")
.nullableKeys("name", "age", "test")
.ifNotExist().create();
schema.vertexLabel("software")
.properties("name", "lang", "temp")
@ -567,6 +575,8 @@ public class TestGraph implements Graph {
.nullableKeys("weight")
.ifNotExist().create();
schema.indexLabel("vertexByName").onV("vertex").by("name").secondary()
.ifNotExist().create();
schema.indexLabel("vertexByAge").onV("vertex").by("age").range()
.ifNotExist().create();
}
@ -597,6 +607,12 @@ public class TestGraph implements Graph {
schema.propertyKey("double").asDouble().ifNotExist().create();
schema.propertyKey("string").ifNotExist().create();
schema.propertyKey("integer").asInt().ifNotExist().create();
/*
* The method shouldHaveStandardStringRepresentationForEdgeProperty()
* in PropertyTest$BasicPropertyTest need 'short' property with
* datatype String
*/
schema.propertyKey("short").asText().ifNotExist().create();
schema.propertyKey("long").asLong().ifNotExist().create();
schema.propertyKey("x").asInt().ifNotExist().create();
schema.propertyKey("y").asInt().ifNotExist().create();
@ -651,6 +667,7 @@ public class TestGraph implements Graph {
private void initBasicVertexLabelV(IdStrategy idStrategy,
String defaultVL) {
SchemaManager schema = this.graph.schema();
switch (idStrategy) {
case CUSTOMIZE_STRING:
this.isLastIdCustomized = true;
@ -718,21 +735,29 @@ public class TestGraph implements Graph {
SchemaManager schema = this.graph.schema();
schema.vertexLabel("person")
.properties("name")
.nullableKeys("name")
.properties("name", "age")
.nullableKeys("name", "age")
.ifNotExist().create();
schema.vertexLabel("software")
.properties("name", "lang")
.nullableKeys("name", "lang")
.ifNotExist().create();
schema.vertexLabel("thing")
.properties("here")
.nullableKeys("here")
.ifNotExist().create();
schema.vertexLabel("blah")
.properties("test")
.nullableKeys("test")
.ifNotExist().create();
schema.edgeLabel("self").link(defaultVL, defaultVL)
.properties("__id", "test", "name", "some", "acl", "weight",
"here", "to-change", "dropped", "not-dropped", "new",
"to-drop")
"to-drop", "short", "long")
.nullableKeys("__id", "test", "name", "some", "acl", "weight",
"here", "to-change", "dropped", "not-dropped",
"new", "to-drop")
"new", "to-drop", "short", "long")
.ifNotExist().create();
schema.edgeLabel("aTOa").link(defaultVL, defaultVL)
.properties("gremlin.partitionGraphStrategy.partition")
@ -754,15 +779,9 @@ public class TestGraph implements Graph {
.properties("gremlin.partitionGraphStrategy.partition", "every")
.nullableKeys("gremlin.partitionGraphStrategy.partition", "every")
.ifNotExist().create();
schema.edgeLabel("knows").link(defaultVL, defaultVL)
.properties("data", "test", "year", "boolean", "float",
"double", "string", "integer", "long", "weight",
"myEdgeId", "since", "acl", "stars", "aKey",
"gremlin.partitionGraphStrategy.partition")
.nullableKeys("data", "test", "year", "boolean", "float",
"double", "string", "integer", "long", "weight",
"myEdgeId", "since", "acl", "stars", "aKey",
"gremlin.partitionGraphStrategy.partition")
schema.edgeLabel("relatesTo").link(defaultVL, defaultVL)
.properties("gremlin.partitionGraphStrategy.partition", "every")
.nullableKeys("gremlin.partitionGraphStrategy.partition", "every")
.ifNotExist().create();
schema.edgeLabel("test").link(defaultVL, defaultVL)
.properties("test", "xxx", "yyy")
@ -812,10 +831,6 @@ public class TestGraph implements Graph {
.properties("weight")
.nullableKeys("weight")
.ifNotExist().create();
schema.edgeLabel("created").link(defaultVL, defaultVL)
.properties("weight")
.nullableKeys("weight")
.ifNotExist().create();
schema.edgeLabel("next").link(defaultVL, defaultVL)
.ifNotExist().create();
@ -842,4 +857,67 @@ public class TestGraph implements Graph {
.by("gremlin.partitionGraphStrategy.partition")
.ifNotExist().create();
}
public void initEdgeLabelDefaultKnowsDefault(String defaultVL) {
SchemaManager schema = this.graph.schema();
schema.edgeLabel("knows").link(defaultVL, defaultVL)
.properties("data", "test", "year", "boolean", "float",
"double", "string", "integer", "long", "weight",
"myEdgeId", "since", "acl", "stars", "aKey",
"gremlin.partitionGraphStrategy.partition", "color")
.nullableKeys("data", "test", "year", "boolean", "float",
"double", "string", "integer", "long", "weight",
"myEdgeId", "since", "acl", "stars", "aKey",
"gremlin.partitionGraphStrategy.partition", "color")
.ifNotExist().create();
}
public void initEdgeLabelDefaultCreatedDefault(String defaultVL) {
SchemaManager schema = this.graph.schema();
schema.edgeLabel("created").link(defaultVL, defaultVL)
.properties("weight", "color")
.nullableKeys("weight", "color")
.ifNotExist().create();
}
public void initEdgeLabelPersonKnowsPerson() {
SchemaManager schema = this.graph.schema();
schema.edgeLabel("knows").link("person", "person")
.properties("weight")
.nullableKeys("weight")
.ifNotExist().create();
}
public void initEdgeLabelPersonCreatedSoftware() {
SchemaManager schema = this.graph.schema();
schema.edgeLabel("created").link("person", "software")
.properties("weight")
.nullableKeys("weight")
.ifNotExist().create();
}
public void initSinkSchema() {
SchemaManager schema = this.graph.schema();
schema.propertyKey("name").ifNotExist().create();
schema.vertexLabel("message")
.properties("name")
.nullableKeys("name")
.ifNotExist().create();
schema.vertexLabel("loops")
.properties("name")
.nullableKeys("name")
.ifNotExist().create();
schema.edgeLabel("link").link("message", "message")
.ifNotExist().create();
schema.edgeLabel("self").link("loops", "loops")
.ifNotExist().create();
schema.indexLabel("loopsByName").onV("loops")
.secondary().by("name")
.ifNotExist().create();
}
}

View File

@ -283,8 +283,23 @@ public class TestGraphProvider extends AbstractGraphProvider {
testGraph.initPropertyKey("aKey", aKeyType);
}
if (testMethod.equals(
"shouldHaveTruncatedStringRepresentationForEdgeProperty")) {
testGraph.initPropertyKey("long", "String");
} else {
testGraph.initPropertyKey("long", "Long");
}
// Basic schema is initiated by default once a graph is open
testGraph.initBasicSchema(idStrategy(config), TestGraph.DEFAULT_VL);
if (testClass.getName().equals(
"org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadTest$Traversals")) {
testGraph.initEdgeLabelPersonKnowsPerson();
testGraph.initEdgeLabelPersonCreatedSoftware();
} else {
testGraph.initEdgeLabelDefaultKnowsDefault(TestGraph.DEFAULT_VL);
testGraph.initEdgeLabelDefaultCreatedDefault(TestGraph.DEFAULT_VL);
}
testGraph.tx().commit();
testGraph.loadedGraph(getIoType(testClass, testMethod));
@ -392,12 +407,16 @@ public class TestGraphProvider extends AbstractGraphProvider {
break;
case CREW:
break;
case SINK:
testGraph.initSinkSchema();
break;
default:
throw new AssertionError(String.format(
"Only support GRATEFUL, MODERN and CLASSIC " +
"for @LoadGraphWith(), but '%s' is used ",
loadGraphWith));
}
LOG.debug("Load graph with {} schema", loadGraphWith);
testGraph.tx().commit();
}

View File

@ -127,6 +127,28 @@ org.apache.tinkerpop.gremlin.process.traversal.step.ComplexTest.Traversals.class
org.apache.tinkerpop.gremlin.process.traversal.step.ComplexTest.Traversals.playlistPaths: long time
org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.TreeTest.Traversals.g_V_out_out_treeXaX_capXaX: long time
# Unsupported query
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasIdXwithoutXemptyXX_count: Unsupported query 'NOT IN []'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasIdXemptyX_count: Unsupported query 'hasId(EmptyList)'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXname_containingXarkXX: Unsupported predicate 'containing(ark)'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXname_endingWithXasXX: Unsupported predicate 'endingWith(as)'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXname_startingWithXmarXX: Unsupported predicate 'startingWith(mar)'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXage_withoutX27X_count: Unsupported relation 'NEQ'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXperson_name_containingXoX_andXltXmXXX: Unsupported predicate 'containing(o)'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXname_not_startingWithXmarXX: Unsupported predicate 'notStartingWith(mar)'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXname_not_containingXarkXX: Unsupported predicate 'notContaining(ark)'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXname_not_endingWithXasXX: Unsupported predicate 'notEndingWith(as)'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXage_withoutX27_29X_count: Unsupported relation 'NEQ'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXname_gtXmX_andXcontainingXoXXX: Unsupported predicate 'containing(o)'
# Unsupport edge label 'created': 'software' -> 'person', has existed an edgelabel (created: person -> software) in this case
org.apache.tinkerpop.gremlin.process.traversal.step.map.AddEdgeTest.Traversals.g_V_hasXname_markoX_asXaX_outEXcreatedX_asXbX_inV_addEXselectXbX_labelX_toXaX: Unsupport edge from inV to outV
# Can't customize vertex id when id strategy is 'AUTOMATIC': Firstly add vertex without id(id strategy is 'AUTOMATIC'), then write it into file, at last read file, call add vertex with id
org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadTest.Traversals.g_io_read_withXreader_graphmlX: Can't customize vertex id when id strategy is 'AUTOMATIC'
org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadTest.Traversals.g_io_readXxmlX: Can't customize vertex id when id strategy is 'AUTOMATIC'
#################### structure performance suite ####################
org.apache.tinkerpop.gremlin.structure.GraphWritePerformanceTest.WriteToGraph.writeEmptyVertices: Vertices number exceeds 65536, can not delete by vertex label after tests

View File

@ -91,6 +91,28 @@ org.apache.tinkerpop.gremlin.process.traversal.step.map.AddVertexTest.Traversals
org.apache.tinkerpop.gremlin.process.traversal.step.map.AddVertexTest.Traversals.g_addVXanimalX_propertyXname_mateoX_propertyXname_gateoX_propertyXname_cateoX_propertyXage_5X: Expect multi properties after setting single property multi times
org.apache.tinkerpop.gremlin.process.traversal.step.map.AddVertexTest.Traversals.g_V_addVXanimalX_propertyXname_valuesXnameXX_propertyXname_an_animalX_propertyXvaluesXnameX_labelX: Expect multi properties after setting single property multi times
# unsupported predicate
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasIdXwithoutXemptyXX_count: Unsupported query 'NOT IN []'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasIdXemptyX_count: Unsupported query 'hasId(EmptyList)'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXname_containingXarkXX: Unsupported predicate 'containing(ark)'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXname_endingWithXasXX: Unsupported predicate 'endingWith(as)'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXname_startingWithXmarXX: Unsupported predicate 'startingWith(mar)'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXage_withoutX27X_count: Unsupported relation 'NEQ'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXperson_name_containingXoX_andXltXmXXX: Unsupported predicate 'containing(o)'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXname_not_startingWithXmarXX: Unsupported predicate 'notStartingWith(mar)'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXname_not_containingXarkXX: Unsupported predicate 'notContaining(ark)'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXname_not_endingWithXasXX: Unsupported predicate 'notEndingWith(as)'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXage_withoutX27_29X_count: Unsupported relation 'NEQ'
org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasTest.Traversals.g_V_hasXname_gtXmX_andXcontainingXoXXX: Unsupported predicate 'containing(o)'
# Unsupport edge label 'created': 'software' -> 'person', has existed an edgelabel (created: person -> software) in this case
org.apache.tinkerpop.gremlin.process.traversal.step.map.AddEdgeTest.Traversals.g_V_hasXname_markoX_asXaX_outEXcreatedX_asXbX_inV_addEXselectXbX_labelX_toXaX: Unsupport edge from inV to outV
# Can't customize vertex id when id strategy is 'AUTOMATIC': Firstly add vertex without id(id strategy is 'AUTOMATIC'), then write it into file, at last read file, call add vertex with id
org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadTest.Traversals.g_io_read_withXreader_graphmlX: Can't customize vertex id when id strategy is 'AUTOMATIC'
org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadTest.Traversals.g_io_readXxmlX: Can't customize vertex id when id strategy is 'AUTOMATIC'
#################### structure performance suite ####################
org.apache.tinkerpop.gremlin.structure.GraphWritePerformanceTest.WriteToGraph.writeEmptyVertices: Vertices number exceeds 65536, can not delete by vertex label after tests

48
pom.xml
View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.baidu.hugegraph</groupId>
<artifactId>hugegraph</artifactId>
<version>0.10.3</version>
<version>0.10.4</version>
<packaging>pom</packaging>
<prerequisites>
<maven>3.3.9</maven>
@ -98,7 +98,7 @@
<log4j.version>1.2.17</log4j.version>
<log4j2.version>2.8.2</log4j2.version>
<junit.version>4.12</junit.version>
<tinkerpop.version>3.2.5</tinkerpop.version>
<tinkerpop.version>3.4.3</tinkerpop.version>
<commons.io.version>2.4</commons.io.version>
<guava.version>19.0</guava.version>
<httpclient.version>4.5.2</httpclient.version>
@ -205,7 +205,7 @@
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-groovy-test</artifactId>
<version>${tinkerpop.version}</version>
<version>3.2.11</version>
</dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
@ -456,48 +456,6 @@
</plugins>
</build>
</profile>
<profile>
<id>tinkerpop-structure-perf-test</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<executions>
<execution>
<id>tinkerpop-structure-perf-test</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>tinkerpop-process-perf-test</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<executions>
<execution>
<id>tinkerpop-process-perf-test</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release</id>
<build>