From 3061943780f948ad35514a6dade7efbc0b835532 Mon Sep 17 00:00:00 2001 From: M <1216063060@qq.com> Date: Mon, 19 Feb 2024 12:21:12 +0800 Subject: [PATCH] format&clean 62 files in core --- .../hugegraph/task/ServerInfoManager.java | 6 ++-- .../hugegraph/task/StandardTaskScheduler.java | 32 ++++++++--------- .../apache/hugegraph/task/TaskCallable.java | 6 ++-- .../apache/hugegraph/task/TaskManager.java | 16 ++++----- .../apache/hugegraph/task/TaskScheduler.java | 8 ++--- .../org/apache/hugegraph/task/TaskStatus.java | 5 +-- .../traversal/algorithm/CountTraverser.java | 5 ++- .../traversal/algorithm/HugeTraverser.java | 1 + .../algorithm/NeighborRankTraverser.java | 11 +++--- .../traversal/algorithm/OltpTraverser.java | 6 ++-- .../algorithm/PersonalRankTraverser.java | 5 ++- .../algorithm/PredictionTraverser.java | 1 + .../algorithm/ShortestPathTraverser.java | 9 ++--- .../algorithm/records/AbstractRecords.java | 4 +-- .../records/DoubleWayMultiPathsRecords.java | 4 +-- .../algorithm/records/KoutRecords.java | 2 +- .../algorithm/records/record/SyncRecord.java | 2 +- .../traversal/algorithm/steps/EdgeStep.java | 6 ++-- .../algorithm/steps/RepeatEdgeStep.java | 1 + .../algorithm/steps/WeightedEdgeStep.java | 1 + .../strategy/ConcurrentTraverseStrategy.java | 2 +- .../strategy/SingleTraverseStrategy.java | 10 +++--- .../algorithm/strategy/TraverseStrategy.java | 4 +-- .../traversal/optimize/HugeCountStep.java | 8 ++--- .../optimize/HugeCountStepStrategy.java | 20 +++++------ .../traversal/optimize/HugeGraphStep.java | 5 ++- .../optimize/HugeGraphStepStrategy.java | 8 ++--- .../optimize/HugePrimaryKeyStrategy.java | 4 +-- .../optimize/HugeScriptTraversal.java | 4 +-- .../traversal/optimize/HugeVertexStep.java | 24 ++++++------- .../optimize/HugeVertexStepByBatch.java | 11 +++--- .../optimize/HugeVertexStepStrategy.java | 14 ++++---- .../traversal/optimize/QueryHolder.java | 3 +- .../traversal/optimize/TraversalUtil.java | 30 ++++++++-------- .../org/apache/hugegraph/type/Nameable.java | 1 + .../hugegraph/type/define/CollectionType.java | 2 +- .../hugegraph/type/define/DataType.java | 12 +++---- .../hugegraph/type/define/Directions.java | 8 ++--- .../hugegraph/type/define/IndexType.java | 2 +- .../hugegraph/type/define/SerialEnum.java | 1 + .../apache/hugegraph/util/CompressUtil.java | 13 ++++--- .../org/apache/hugegraph/util/ConfigUtil.java | 17 +++++---- .../org/apache/hugegraph/util/Consumers.java | 2 +- .../util/FixedTimerWindowRateLimiter.java | 2 +- .../util/FixedWatchWindowRateLimiter.java | 4 +-- .../org/apache/hugegraph/util/GZipUtil.java | 1 - .../org/apache/hugegraph/util/JsonUtil.java | 11 +++--- .../org/apache/hugegraph/util/KryoUtil.java | 2 +- .../org/apache/hugegraph/util/LockUtil.java | 20 +++++------ .../apache/hugegraph/util/ParameterUtil.java | 2 -- .../apache/hugegraph/util/RateLimiter.java | 3 ++ .../org/apache/hugegraph/util/Reflection.java | 26 +++++++------- .../apache/hugegraph/util/StringEncoding.java | 1 - .../util/collection/CollectionFactory.java | 29 ++++++++------- .../hugegraph/util/collection/IdSet.java | 9 +++-- .../util/collection/Int2IntsMap.java | 2 +- .../util/collection/IntIterator.java | 4 +-- .../hugegraph/util/collection/IntMap.java | 21 ++++++----- .../util/collection/IntMapByDynamicHash.java | 36 +++++++++++-------- .../hugegraph/util/collection/IntSet.java | 11 +++--- .../collection/ObjectIntMappingFactory.java | 11 +++--- .../hugegraph/variables/HugeVariables.java | 15 ++++---- 62 files changed, 274 insertions(+), 272 deletions(-) diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/ServerInfoManager.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/ServerInfoManager.java index bca4e46c35..7290496f42 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/ServerInfoManager.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/ServerInfoManager.java @@ -118,7 +118,7 @@ public synchronized void initServerInfo(GlobalMasterInfo nodeInfo) { while (servers.hasNext()) { existed = servers.next(); E.checkArgument(!existed.role().master() || !existed.alive(), - "Already existed master '%s' in current cluster", + "Already existed master '%s' in current cluster", existed.id()); } if (page != null) { @@ -324,7 +324,7 @@ private int save(Collection serverInfos) { private V call(Callable callable) { assert !Thread.currentThread().getName().startsWith( - "server-info-db-worker") : "can't call by itself"; + "server-info-db-worker") : "can't call by itself"; try { // Pass context for db thread callable = new TaskManager.ContextCallable<>(callable); @@ -391,7 +391,7 @@ protected void updateServerInfos(Collection serverInfos) { protected Collection allServerInfos() { Iterator infos = this.serverInfos(NO_LIMIT, null); try (ListIterator iter = new ListIterator<>( - MAX_SERVERS, infos)) { + MAX_SERVERS, infos)) { return iter.list(); } catch (Exception e) { throw new HugeException("Failed to close server info iterator", e); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/StandardTaskScheduler.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/StandardTaskScheduler.java index bc50fce5b4..48a7508206 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/StandardTaskScheduler.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/StandardTaskScheduler.java @@ -149,7 +149,7 @@ public void restoreTasks() { do { Iterator> iter; for (iter = this.findTask(status, PAGE_SIZE, page); - iter.hasNext();) { + iter.hasNext(); ) { HugeTask task = iter.next(); if (selfServer.equals(task.server())) { taskList.add(task); @@ -160,7 +160,7 @@ public void restoreTasks() { } } while (page != null); } - for (HugeTask task : taskList){ + for (HugeTask task : taskList) { LOG.info("restore task {}", task); this.restore(task); } @@ -328,7 +328,7 @@ protected synchronized void scheduleTasksOnMaster() { } HugeServerInfo server = this.serverManager().pickWorkerNode( - serverInfos, task); + serverInfos, task); if (server == null) { LOG.info("The master can't find suitable servers to " + "execute task '{}', wait for next schedule", @@ -443,7 +443,7 @@ protected void remove(HugeTask task) { HugeTask delTask = this.tasks.remove(task.id()); if (delTask != null && delTask != task) { LOG.warn("Task '{}' may be inconsistent status {}(expect {})", - task.id(), task.status(), delTask.status()); + task.id(), task.status(), delTask.status()); } assert delTask == null || delTask.completed() || delTask.cancelling() || delTask.isCancelled() : delTask; @@ -528,7 +528,7 @@ public Iterator> tasks(TaskStatus status, } public HugeTask findTask(Id id) { - HugeTask result = this.call(() -> { + HugeTask result = this.call(() -> { Iterator vertices = this.tx().queryVertices(id); Vertex vertex = QueryResults.one(vertices); if (vertex == null) { @@ -595,13 +595,13 @@ public HugeTask delete(Id id) { @Override public HugeTask waitUntilTaskCompleted(Id id, long seconds) - throws TimeoutException { + throws TimeoutException { return this.waitUntilTaskCompleted(id, seconds, QUERY_INTERVAL); } @Override public HugeTask waitUntilTaskCompleted(Id id) - throws TimeoutException { + throws TimeoutException { // This method is just used by tests long timeout = this.graph.configuration() .get(CoreOptions.TASK_WAIT_TIMEOUT); @@ -610,10 +610,10 @@ public HugeTask waitUntilTaskCompleted(Id id) private HugeTask waitUntilTaskCompleted(Id id, long seconds, long intervalMs) - throws TimeoutException { + throws TimeoutException { long passes = seconds * 1000 / intervalMs; HugeTask task = null; - for (long pass = 0;; pass++) { + for (long pass = 0; ; pass++) { try { task = this.task(id); } catch (NotFoundException e) { @@ -635,15 +635,15 @@ private HugeTask waitUntilTaskCompleted(Id id, long seconds, sleep(intervalMs); } throw new TimeoutException(String.format( - "Task '%s' was not completed in %s seconds", id, seconds)); + "Task '%s' was not completed in %s seconds", id, seconds)); } @Override public void waitUntilAllTasksCompleted(long seconds) - throws TimeoutException { + throws TimeoutException { long passes = seconds * 1000 / QUERY_INTERVAL; int taskSize; - for (long pass = 0;; pass++) { + for (long pass = 0; ; pass++) { taskSize = this.pendingTasks(); if (taskSize == 0) { sleep(QUERY_INTERVAL); @@ -655,8 +655,8 @@ public void waitUntilAllTasksCompleted(long seconds) sleep(QUERY_INTERVAL); } throw new TimeoutException(String.format( - "There are still %s incomplete tasks after %s seconds", - taskSize, seconds)); + "There are still %s incomplete tasks after %s seconds", + taskSize, seconds)); } @Override @@ -711,7 +711,7 @@ private V call(Runnable runnable) { private V call(Callable callable) { assert !Thread.currentThread().getName().startsWith( - "task-db-worker") : "can't call by itself"; + "task-db-worker") : "can't call by itself"; try { // Pass task context for db thread callable = new ContextCallable<>(callable); @@ -804,7 +804,7 @@ public void initSchema() { private boolean existVertexLabel(String label) { return this.params().schemaTransaction() - .getVertexLabel(label) != null; + .getVertexLabel(label) != null; } private String[] initProperties() { diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/TaskCallable.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/TaskCallable.java index b19fb796da..ec066fbc04 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/TaskCallable.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/TaskCallable.java @@ -21,14 +21,14 @@ import java.util.Set; import java.util.concurrent.Callable; -import org.apache.tinkerpop.gremlin.structure.Transaction; -import org.slf4j.Logger; - import org.apache.hugegraph.HugeException; import org.apache.hugegraph.HugeGraph; import org.apache.hugegraph.HugeGraphParams; import org.apache.hugegraph.util.E; import org.apache.hugegraph.util.Log; +import org.apache.tinkerpop.gremlin.structure.Transaction; +import org.slf4j.Logger; + import com.google.common.collect.ImmutableSet; public abstract class TaskCallable implements Callable { diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/TaskManager.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/TaskManager.java index 14e91d301c..144387949b 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/TaskManager.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/TaskManager.java @@ -45,7 +45,7 @@ public final class TaskManager { public static final String TASK_WORKER = TASK_WORKER_PREFIX + "-%d"; public static final String TASK_DB_WORKER = "task-db-worker-%d"; public static final String SERVER_INFO_DB_WORKER = - "server-info-db-worker-%d"; + "server-info-db-worker-%d"; public static final String TASK_SCHEDULER = "task-scheduler-%d"; protected static final long SCHEDULE_PERIOD = 1000L; // unit ms @@ -73,12 +73,12 @@ private TaskManager(int pool) { this.taskExecutor = ExecutorUtil.newFixedThreadPool(pool, TASK_WORKER); // For save/query task state, just one thread is ok this.taskDbExecutor = ExecutorUtil.newFixedThreadPool( - 1, TASK_DB_WORKER); + 1, TASK_DB_WORKER); this.serverInfoDbExecutor = ExecutorUtil.newFixedThreadPool( - 1, SERVER_INFO_DB_WORKER); + 1, SERVER_INFO_DB_WORKER); // For schedule task to run, just one thread is ok this.schedulerExecutor = ExecutorUtil.newPausableScheduledThreadPool( - 1, TASK_SCHEDULER); + 1, TASK_SCHEDULER); // Start after 10x period time waiting for HugeGraphServer startup this.schedulerExecutor.scheduleWithFixedDelay(this::scheduleOrExecuteJob, 10 * SCHEDULE_PERIOD, @@ -90,8 +90,8 @@ public void addScheduler(HugeGraphParams graph) { E.checkArgumentNotNull(graph, "The graph can't be null"); TaskScheduler scheduler = new StandardTaskScheduler(graph, - this.taskExecutor, this.taskDbExecutor, - this.serverInfoDbExecutor); + this.taskExecutor, this.taskDbExecutor, + this.serverInfoDbExecutor); this.schedulers.put(graph, scheduler); } @@ -171,7 +171,7 @@ public TaskScheduler getScheduler(HugeGraphParams graph) { public ServerInfoManager getServerInfoManager(HugeGraphParams graph) { StandardTaskScheduler scheduler = (StandardTaskScheduler) - this.getScheduler(graph); + this.getScheduler(graph); if (scheduler == null) { return null; } @@ -275,7 +275,7 @@ public void onAsRoleWorker() { protected void notifyNewTask(HugeTask task) { Queue queue = ((ThreadPoolExecutor) this.schedulerExecutor) - .getQueue(); + .getQueue(); if (queue.size() <= 1) { /* * Notify to schedule tasks initiatively when have new task diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/TaskScheduler.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/TaskScheduler.java index c65008d441..28eb232a2f 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/TaskScheduler.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/TaskScheduler.java @@ -22,8 +22,8 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeoutException; -import org.apache.hugegraph.backend.id.Id; import org.apache.hugegraph.HugeGraph; +import org.apache.hugegraph.backend.id.Id; public interface TaskScheduler { @@ -53,13 +53,13 @@ Iterator> tasks(TaskStatus status, boolean close(); HugeTask waitUntilTaskCompleted(Id id, long seconds) - throws TimeoutException; + throws TimeoutException; HugeTask waitUntilTaskCompleted(Id id) - throws TimeoutException; + throws TimeoutException; void waitUntilAllTasksCompleted(long seconds) - throws TimeoutException; + throws TimeoutException; void checkRequirement(String op); } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/TaskStatus.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/TaskStatus.java index 0647f91592..14613ee8c6 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/TaskStatus.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/TaskStatus.java @@ -21,6 +21,7 @@ import java.util.Set; import org.apache.hugegraph.type.define.SerialEnum; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; @@ -41,10 +42,10 @@ public enum TaskStatus implements SerialEnum { // NOTE: order is important(RESTORING > RUNNING > QUEUED) when restoring public static final List PENDING_STATUSES = ImmutableList.of( - TaskStatus.RESTORING, TaskStatus.RUNNING, TaskStatus.QUEUED); + TaskStatus.RESTORING, TaskStatus.RUNNING, TaskStatus.QUEUED); public static final Set COMPLETED_STATUSES = ImmutableSet.of( - TaskStatus.SUCCESS, TaskStatus.CANCELLED, TaskStatus.FAILED); + TaskStatus.SUCCESS, TaskStatus.CANCELLED, TaskStatus.FAILED); private byte status; private String name; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/CountTraverser.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/CountTraverser.java index 3ef81e538c..1b9defac46 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/CountTraverser.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/CountTraverser.java @@ -25,13 +25,12 @@ import org.apache.hugegraph.HugeGraph; import org.apache.hugegraph.backend.id.Id; import org.apache.hugegraph.backend.query.QueryResults; -import org.apache.hugegraph.traversal.algorithm.steps.EdgeStep; -import org.apache.tinkerpop.gremlin.structure.Edge; - import org.apache.hugegraph.iterator.FilterIterator; import org.apache.hugegraph.iterator.FlatMapperIterator; import org.apache.hugegraph.structure.HugeEdge; +import org.apache.hugegraph.traversal.algorithm.steps.EdgeStep; import org.apache.hugegraph.util.E; +import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.util.CloseableIterator; public class CountTraverser extends HugeTraverser { diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/HugeTraverser.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/HugeTraverser.java index 53ced03c67..e75d016359 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/HugeTraverser.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/HugeTraverser.java @@ -947,6 +947,7 @@ public void append(Id current) { } public static class EdgeRecord { + private final Map edgeMap; private final ObjectIntMapping idMapping; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/NeighborRankTraverser.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/NeighborRankTraverser.java index e5f99b4037..3e915c7dd9 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/NeighborRankTraverser.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/NeighborRankTraverser.java @@ -22,17 +22,16 @@ import java.util.Map; import java.util.Set; -import jakarta.ws.rs.core.MultivaluedMap; - import org.apache.hugegraph.HugeGraph; import org.apache.hugegraph.backend.id.Id; +import org.apache.hugegraph.structure.HugeEdge; import org.apache.hugegraph.traversal.algorithm.steps.EdgeStep; import org.apache.hugegraph.type.define.Directions; -import org.apache.tinkerpop.gremlin.structure.Edge; - -import org.apache.hugegraph.structure.HugeEdge; import org.apache.hugegraph.util.E; import org.apache.hugegraph.util.OrderLimitMap; +import org.apache.tinkerpop.gremlin.structure.Edge; + +import jakarta.ws.rs.core.MultivaluedMap; public class NeighborRankTraverser extends HugeTraverser { @@ -162,7 +161,7 @@ private boolean belongToPrevLayers(List ranks, Id target, Ranks prevLayerRanks = ranks.get(i); if (prevLayerRanks.containsKey(target)) { Set nodes = prevLayerNodes.computeIfAbsent( - i, HugeTraverser::newSet); + i, HugeTraverser::newSet); nodes.add(target); return true; } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/OltpTraverser.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/OltpTraverser.java index 40fe914d49..44f9cf8692 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/OltpTraverser.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/OltpTraverser.java @@ -49,7 +49,7 @@ import com.google.common.base.Objects; public abstract class OltpTraverser extends HugeTraverser - implements AutoCloseable { + implements AutoCloseable { private static final String EXECUTOR_NAME = "oltp"; private static Consumers.ExecutorPool executors; @@ -149,7 +149,7 @@ protected void traverseIdsByBfs(Iterator vertices, long capacity, Consumer consumer) { List labels = label == null ? Collections.emptyList() : - Collections.singletonList(label); + Collections.singletonList(label); OneStepEdgeIterConsumer edgeIterConsumer = new OneStepEdgeIterConsumer(consumer, capacity); EdgesIterator edgeIter = edgesOfVertices(vertices, dir, labels, degree); @@ -248,7 +248,7 @@ protected boolean match(Element elem, String key, Object value) { } public static class ConcurrentMultiValuedMap - extends ConcurrentHashMap> { + extends ConcurrentHashMap> { private static final long serialVersionUID = -7249946839643493614L; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/PersonalRankTraverser.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/PersonalRankTraverser.java index 1a1e82cad9..972eff7c7a 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/PersonalRankTraverser.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/PersonalRankTraverser.java @@ -27,11 +27,10 @@ import org.apache.hugegraph.backend.id.Id; import org.apache.hugegraph.schema.EdgeLabel; import org.apache.hugegraph.schema.VertexLabel; -import org.apache.hugegraph.type.define.Directions; -import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; - import org.apache.hugegraph.structure.HugeVertex; +import org.apache.hugegraph.type.define.Directions; import org.apache.hugegraph.util.E; +import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; public class PersonalRankTraverser extends HugeTraverser { diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/PredictionTraverser.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/PredictionTraverser.java index 4a3df4d643..4b2cb69e57 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/PredictionTraverser.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/PredictionTraverser.java @@ -24,6 +24,7 @@ import org.apache.hugegraph.traversal.algorithm.steps.EdgeStep; import org.apache.hugegraph.type.define.Directions; import org.apache.hugegraph.util.E; + import com.google.common.collect.ImmutableList; public class PredictionTraverser extends OltpTraverser { diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/ShortestPathTraverser.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/ShortestPathTraverser.java index 4e9b88ec1b..a34f87289d 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/ShortestPathTraverser.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/ShortestPathTraverser.java @@ -198,8 +198,9 @@ public PathSet forward(boolean all) { this.edgeResults.addEdge(source, target, edge); PathSet paths = this.pathResults.findPath(target, - t -> !this.superNode(t, this.direction), - all, false); + t -> !this.superNode(t, + this.direction), + all, false); if (paths.isEmpty()) { continue; @@ -244,8 +245,8 @@ public PathSet backward(boolean all) { this.edgeResults.addEdge(source, target, edge); PathSet paths = this.pathResults.findPath(target, - t -> !this.superNode(t, opposite), - all, false); + t -> !this.superNode(t, opposite), + all, false); if (paths.isEmpty()) { continue; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/AbstractRecords.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/AbstractRecords.java index 7b94454cb4..74f3db5ffa 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/AbstractRecords.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/AbstractRecords.java @@ -19,12 +19,12 @@ import org.apache.hugegraph.backend.id.Id; import org.apache.hugegraph.backend.id.IdGenerator; -import org.apache.hugegraph.util.collection.ObjectIntMapping; -import org.apache.hugegraph.util.collection.ObjectIntMappingFactory; import org.apache.hugegraph.perf.PerfUtil.Watched; import org.apache.hugegraph.traversal.algorithm.records.record.Record; import org.apache.hugegraph.traversal.algorithm.records.record.RecordFactory; import org.apache.hugegraph.traversal.algorithm.records.record.RecordType; +import org.apache.hugegraph.util.collection.ObjectIntMapping; +import org.apache.hugegraph.util.collection.ObjectIntMappingFactory; public abstract class AbstractRecords implements Records { diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/DoubleWayMultiPathsRecords.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/DoubleWayMultiPathsRecords.java index 4600f0790a..33224dc92c 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/DoubleWayMultiPathsRecords.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/DoubleWayMultiPathsRecords.java @@ -22,14 +22,14 @@ import java.util.Stack; import org.apache.commons.collections.CollectionUtils; - import org.apache.hugegraph.backend.id.Id; -import org.apache.hugegraph.util.collection.IntIterator; import org.apache.hugegraph.perf.PerfUtil.Watched; import org.apache.hugegraph.traversal.algorithm.HugeTraverser.Path; import org.apache.hugegraph.traversal.algorithm.HugeTraverser.PathSet; import org.apache.hugegraph.traversal.algorithm.records.record.Record; import org.apache.hugegraph.traversal.algorithm.records.record.RecordType; +import org.apache.hugegraph.util.collection.IntIterator; + import com.google.common.collect.Lists; public abstract class DoubleWayMultiPathsRecords extends AbstractRecords { diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/KoutRecords.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/KoutRecords.java index f13bcbce6a..bd637ce1d4 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/KoutRecords.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/KoutRecords.java @@ -97,7 +97,7 @@ public void addFullPath(List edges) { if (this.sourceCode == targetCode) { break; } - + this.addPathToRecord(sourceCode, targetCode, record); sourceCode = targetCode; } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/record/SyncRecord.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/record/SyncRecord.java index 4a113fb4ea..c743ed5a49 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/record/SyncRecord.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/record/SyncRecord.java @@ -31,7 +31,7 @@ public SyncRecord(Record record) { public SyncRecord(Record record, Object newLock) { if (record == null) { throw new IllegalArgumentException( - "Cannot create a SyncRecord on a null record"); + "Cannot create a SyncRecord on a null record"); } else { this.record = record; this.lock = newLock == null ? this : newLock; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/steps/EdgeStep.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/steps/EdgeStep.java index 06cfd66066..caff267b7d 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/steps/EdgeStep.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/steps/EdgeStep.java @@ -28,12 +28,12 @@ import org.apache.hugegraph.HugeGraph; import org.apache.hugegraph.backend.id.Id; import org.apache.hugegraph.schema.EdgeLabel; -import org.apache.hugegraph.type.define.Directions; -import org.apache.tinkerpop.gremlin.structure.Edge; - import org.apache.hugegraph.traversal.algorithm.HugeTraverser; import org.apache.hugegraph.traversal.optimize.TraversalUtil; +import org.apache.hugegraph.type.define.Directions; import org.apache.hugegraph.util.E; +import org.apache.tinkerpop.gremlin.structure.Edge; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/steps/RepeatEdgeStep.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/steps/RepeatEdgeStep.java index 29a3572c18..1ab5fb1e0e 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/steps/RepeatEdgeStep.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/steps/RepeatEdgeStep.java @@ -24,6 +24,7 @@ import org.apache.hugegraph.HugeGraph; import org.apache.hugegraph.type.define.Directions; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/steps/WeightedEdgeStep.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/steps/WeightedEdgeStep.java index 81b3cffd33..b288420ff2 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/steps/WeightedEdgeStep.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/steps/WeightedEdgeStep.java @@ -28,6 +28,7 @@ import org.apache.hugegraph.schema.PropertyKey; import org.apache.hugegraph.type.define.Directions; import org.apache.hugegraph.util.E; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/strategy/ConcurrentTraverseStrategy.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/strategy/ConcurrentTraverseStrategy.java index 2110df8f80..235a3c2d98 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/strategy/ConcurrentTraverseStrategy.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/strategy/ConcurrentTraverseStrategy.java @@ -29,7 +29,7 @@ import org.apache.hugegraph.traversal.algorithm.steps.EdgeStep; public class ConcurrentTraverseStrategy extends OltpTraverser - implements TraverseStrategy { + implements TraverseStrategy { public ConcurrentTraverseStrategy(HugeGraph graph) { super(graph); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/strategy/SingleTraverseStrategy.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/strategy/SingleTraverseStrategy.java index a3bb7ada50..8516645cdd 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/strategy/SingleTraverseStrategy.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/strategy/SingleTraverseStrategy.java @@ -22,16 +22,16 @@ import java.util.Set; import java.util.function.BiConsumer; -import jakarta.ws.rs.core.MultivaluedMap; - import org.apache.hugegraph.HugeGraph; import org.apache.hugegraph.backend.id.Id; -import org.apache.hugegraph.traversal.algorithm.steps.EdgeStep; import org.apache.hugegraph.traversal.algorithm.HugeTraverser; import org.apache.hugegraph.traversal.algorithm.OltpTraverser; +import org.apache.hugegraph.traversal.algorithm.steps.EdgeStep; + +import jakarta.ws.rs.core.MultivaluedMap; public class SingleTraverseStrategy extends OltpTraverser - implements TraverseStrategy { + implements TraverseStrategy { public SingleTraverseStrategy(HugeGraph graph) { super(graph); @@ -65,7 +65,7 @@ public void addNode(Map> vertices, Id id, Node node) { public void addNewVerticesToAll(Map> newVertices, Map> targets) { MultivaluedMap vertices = - (MultivaluedMap) targets; + (MultivaluedMap) targets; for (Map.Entry> entry : newVertices.entrySet()) { vertices.addAll(entry.getKey(), entry.getValue()); } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/strategy/TraverseStrategy.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/strategy/TraverseStrategy.java index e3c21cfa63..7440133038 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/strategy/TraverseStrategy.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/strategy/TraverseStrategy.java @@ -24,8 +24,8 @@ import org.apache.hugegraph.HugeGraph; import org.apache.hugegraph.backend.id.Id; -import org.apache.hugegraph.traversal.algorithm.steps.EdgeStep; import org.apache.hugegraph.traversal.algorithm.HugeTraverser; +import org.apache.hugegraph.traversal.algorithm.steps.EdgeStep; public interface TraverseStrategy { @@ -44,6 +44,6 @@ void addNewVerticesToAll(Map> newVertices, static TraverseStrategy create(boolean concurrent, HugeGraph graph) { return concurrent ? new ConcurrentTraverseStrategy(graph) : - new SingleTraverseStrategy(graph); + new SingleTraverseStrategy(graph); } } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeCountStep.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeCountStep.java index 8bf2e84644..403bf5be83 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeCountStep.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeCountStep.java @@ -20,6 +20,7 @@ import java.util.NoSuchElementException; import java.util.Objects; +import org.apache.hugegraph.util.E; import org.apache.tinkerpop.gremlin.process.traversal.Step; import org.apache.tinkerpop.gremlin.process.traversal.Traversal; import org.apache.tinkerpop.gremlin.process.traversal.Traverser.Admin; @@ -27,10 +28,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException; import org.apache.tinkerpop.gremlin.structure.Element; -import org.apache.hugegraph.util.E; - public final class HugeCountStep - extends AbstractStep { + extends AbstractStep { private static final long serialVersionUID = -679873894532085972L; @@ -44,6 +43,7 @@ public HugeCountStep(final Traversal.Admin traversal, this.originGraphStep = originGraphStep; } + @Override public boolean equals(Object obj) { if (!(obj instanceof HugeCountStep)) { return false; @@ -69,7 +69,7 @@ protected Admin processNextStart() throws NoSuchElementException { throw FastNoSuchElementException.instance(); } this.done = true; - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) Step step = (Step) this; return this.getTraversal().getTraverserGenerator() .generate(this.originGraphStep.count(), step, 1L); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeCountStepStrategy.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeCountStepStrategy.java index 4bb3a33c88..ef380d36b2 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeCountStepStrategy.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeCountStepStrategy.java @@ -40,8 +40,8 @@ import org.apache.tinkerpop.gremlin.structure.Element; public final class HugeCountStepStrategy - extends AbstractTraversalStrategy - implements ProviderOptimizationStrategy { + extends AbstractTraversalStrategy + implements ProviderOptimizationStrategy { private static final long serialVersionUID = -3910433925919057771L; @@ -56,13 +56,13 @@ private HugeCountStepStrategy() { } @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) public void apply(Traversal.Admin traversal) { TraversalUtil.convAllHasSteps(traversal); // Extract CountGlobalStep List steps = TraversalHelper.getStepsOfClass( - CountGlobalStep.class, traversal); + CountGlobalStep.class, traversal); if (steps.isEmpty()) { return; } @@ -78,12 +78,12 @@ public void apply(Traversal.Admin traversal) { step instanceof IdentityStep || step instanceof NoOpBarrierStep || step instanceof CollectingBarrierStep) || - (step instanceof TraversalParent && - TraversalHelper.anyStepRecursively(s -> { - return s instanceof SideEffectStep || - s instanceof AggregateGlobalStep || - s instanceof AggregateLocalStep; - }, (TraversalParent) step))) { + (step instanceof TraversalParent && + TraversalHelper.anyStepRecursively(s -> { + return s instanceof SideEffectStep || + s instanceof AggregateGlobalStep || + s instanceof AggregateLocalStep; + }, (TraversalParent) step))) { return; } originSteps.add(step); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeGraphStep.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeGraphStep.java index 21e624e866..bdfb9e0b66 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeGraphStep.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeGraphStep.java @@ -28,6 +28,7 @@ import org.apache.hugegraph.backend.query.Query; import org.apache.hugegraph.backend.query.QueryResults; import org.apache.hugegraph.type.HugeType; +import org.apache.hugegraph.util.Log; import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep; import org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer; import org.apache.tinkerpop.gremlin.structure.Element; @@ -35,10 +36,8 @@ import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; import org.slf4j.Logger; -import org.apache.hugegraph.util.Log; - public final class HugeGraphStep - extends GraphStep implements QueryHolder { + extends GraphStep implements QueryHolder { private static final long serialVersionUID = -679873894532085972L; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeGraphStepStrategy.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeGraphStepStrategy.java index af1511e152..cc3ef3f5ff 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeGraphStepStrategy.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeGraphStepStrategy.java @@ -28,8 +28,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; public final class HugeGraphStepStrategy - extends AbstractTraversalStrategy - implements ProviderOptimizationStrategy { + extends AbstractTraversalStrategy + implements ProviderOptimizationStrategy { private static final long serialVersionUID = -2952498905649139719L; @@ -44,13 +44,13 @@ private HugeGraphStepStrategy() { } @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) public void apply(Traversal.Admin traversal) { TraversalUtil.convAllHasSteps(traversal); // Extract conditions in GraphStep List steps = TraversalHelper.getStepsOfClass( - GraphStep.class, traversal); + GraphStep.class, traversal); for (GraphStep originStep : steps) { TraversalUtil.trySetGraph(originStep, TraversalUtil.tryGetGraph(steps.get(0))); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugePrimaryKeyStrategy.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugePrimaryKeyStrategy.java index 95dc187b5a..e6fa880837 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugePrimaryKeyStrategy.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugePrimaryKeyStrategy.java @@ -33,8 +33,8 @@ import org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality; public class HugePrimaryKeyStrategy - extends AbstractTraversalStrategy - implements ProviderOptimizationStrategy { + extends AbstractTraversalStrategy + implements ProviderOptimizationStrategy { private static final long serialVersionUID = 6307847098226016416L; private static final HugePrimaryKeyStrategy INSTANCE = new HugePrimaryKeyStrategy(); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeScriptTraversal.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeScriptTraversal.java index 66d40e9b29..0ccb48a54a 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeScriptTraversal.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeScriptTraversal.java @@ -36,7 +36,7 @@ /** * ScriptTraversal encapsulates a {@link ScriptEngine} and a script which is * compiled into a {@link Traversal} at {@link Admin#applyStrategies()}. - * + *

* This is useful for serializing traversals as the compilation can happen on * the remote end where the traversal will ultimately be processed. * @@ -101,7 +101,7 @@ public void applyStrategies() throws IllegalStateException { Object result = engine.eval(this.script, bindings); if (result instanceof Admin) { - @SuppressWarnings({ "unchecked"}) + @SuppressWarnings({"unchecked"}) Admin traversal = (Admin) result; traversal.getSideEffects().mergeInto(this.sideEffects); traversal.getSteps().forEach(this::addStep); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeVertexStep.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeVertexStep.java index 1132bc83fa..1a3fc58bea 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeVertexStep.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeVertexStep.java @@ -30,6 +30,7 @@ import org.apache.hugegraph.backend.query.QueryResults; import org.apache.hugegraph.backend.tx.GraphTransaction; import org.apache.hugegraph.type.define.Directions; +import org.apache.hugegraph.util.Log; import org.apache.tinkerpop.gremlin.process.traversal.Traverser; import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep; import org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer; @@ -39,10 +40,8 @@ import org.apache.tinkerpop.gremlin.structure.util.StringFactory; import org.slf4j.Logger; -import org.apache.hugegraph.util.Log; - public class HugeVertexStep - extends VertexStep implements QueryHolder { + extends VertexStep implements QueryHolder { private static final long serialVersionUID = -7850636388424382454L; @@ -124,7 +123,7 @@ protected Iterator queryEdges(Query query) { } protected ConditionQuery constructEdgesQuery( - Traverser.Admin traverser) { + Traverser.Admin traverser) { HugeGraph graph = TraversalUtil.getGraph(this); // Query for edge with conditions(else conditions for vertex) @@ -140,7 +139,7 @@ protected ConditionQuery constructEdgesQuery( vertex, direction, edgeLabels, this.hasContainers); ConditionQuery query = GraphTransaction.constructEdgesQuery( - vertex, direction, edgeLabels); + vertex, direction, edgeLabels); // Query by sort-keys if (withEdgeCond && edgeLabels.length == 1) { TraversalUtil.fillConditionQuery(query, this.hasContainers, graph); @@ -173,8 +172,8 @@ protected ConditionQuery constructEdgesQuery( */ if (withEdgeCond || withVertexCond) { org.apache.hugegraph.util.E.checkArgument(!this.queryInfo().paging(), - "Can't query by paging " + - "and filtering"); + "Can't query by paging " + + "and filtering"); this.queryInfo().limit(Query.NO_LIMIT); } @@ -198,11 +197,11 @@ public String toString() { } return StringFactory.stepString( - this, - getDirection(), - Arrays.asList(getEdgeLabels()), - getReturnClass().getSimpleName(), - this.hasContainers); + this, + getDirection(), + Arrays.asList(getEdgeLabels()), + getReturnClass().getSimpleName(), + this.hasContainers); } @Override @@ -229,6 +228,7 @@ public Iterator lastTimeResults() { return this.iterator; } + @Override public boolean equals(Object obj) { if (!(obj instanceof HugeVertexStep)) { return false; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeVertexStepByBatch.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeVertexStepByBatch.java index a1bc02ca02..9517847331 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeVertexStepByBatch.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeVertexStepByBatch.java @@ -23,6 +23,7 @@ import org.apache.hugegraph.backend.query.BatchConditionQuery; import org.apache.hugegraph.backend.query.ConditionQuery; import org.apache.hugegraph.backend.query.Query; +import org.apache.hugegraph.iterator.BatchMapperIterator; import org.apache.hugegraph.type.HugeType; import org.apache.hugegraph.type.define.HugeKeys; import org.apache.tinkerpop.gremlin.process.traversal.Traverser; @@ -33,10 +34,8 @@ import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.structure.util.CloseableIterator; -import org.apache.hugegraph.iterator.BatchMapperIterator; - public class HugeVertexStepByBatch - extends HugeVertexStep { + extends HugeVertexStep { private static final long serialVersionUID = -3609787815053052222L; @@ -57,7 +56,7 @@ protected Traverser.Admin processNextStart() { if (this.batchIterator == null) { int batchSize = (int) Query.QUERY_BATCH; this.batchIterator = new BatchMapperIterator<>( - batchSize, this.starts, this::flatMap); + batchSize, this.starts, this::flatMap); } if (this.batchIterator.hasNext()) { @@ -110,7 +109,7 @@ private Iterator flatMap(List> traversers) { } private Iterator vertices( - List> traversers) { + List> traversers) { assert traversers.size() > 0; Iterator edges = this.edges(traversers); @@ -121,7 +120,7 @@ private Iterator edges(List> traversers) { assert traversers.size() > 0; BatchConditionQuery batchQuery = new BatchConditionQuery( - HugeType.EDGE, traversers.size()); + HugeType.EDGE, traversers.size()); for (Traverser.Admin traverser : traversers) { ConditionQuery query = this.constructEdgesQuery(traverser); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeVertexStepStrategy.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeVertexStepStrategy.java index a01b1ed238..a7dd687348 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeVertexStepStrategy.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeVertexStepStrategy.java @@ -31,8 +31,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; public final class HugeVertexStepStrategy - extends AbstractTraversalStrategy - implements ProviderOptimizationStrategy { + extends AbstractTraversalStrategy + implements ProviderOptimizationStrategy { private static final long serialVersionUID = 491355700217483162L; @@ -47,12 +47,12 @@ private HugeVertexStepStrategy() { } @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) public void apply(final Traversal.Admin traversal) { TraversalUtil.convAllHasSteps(traversal); List steps = TraversalHelper.getStepsOfClass( - VertexStep.class, traversal); + VertexStep.class, traversal); boolean batchOptimize = false; if (!steps.isEmpty()) { @@ -92,12 +92,13 @@ public void apply(final Traversal.Admin traversal) { /** * Does a Traversal contain any Path step + * * @param traversal * @return the traversal or its parents contain at least one Path step */ protected static boolean containsPath(Traversal.Admin traversal) { boolean hasPath = TraversalHelper.getStepsOfClass( - PathStep.class, traversal).size() > 0; + PathStep.class, traversal).size() > 0; if (hasPath) { return true; } else if (traversal instanceof EmptyTraversal) { @@ -110,12 +111,13 @@ protected static boolean containsPath(Traversal.Admin traversal) { /** * Does a Traversal contain any Tree step + * * @param traversal * @return the traversal or its parents contain at least one Tree step */ protected static boolean containsTree(Traversal.Admin traversal) { boolean hasTree = TraversalHelper.getStepsOfClass( - TreeStep.class, traversal).size() > 0; + TreeStep.class, traversal).size() > 0; if (hasTree) { return true; } else if (traversal instanceof EmptyTraversal) { diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/QueryHolder.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/QueryHolder.java index 322744ac2e..917f777b95 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/QueryHolder.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/QueryHolder.java @@ -21,11 +21,10 @@ import org.apache.hugegraph.backend.query.Aggregate; import org.apache.hugegraph.backend.query.Query; +import org.apache.hugegraph.iterator.Metadatable; import org.apache.tinkerpop.gremlin.process.traversal.Order; import org.apache.tinkerpop.gremlin.process.traversal.step.HasContainerHolder; -import org.apache.hugegraph.iterator.Metadatable; - public interface QueryHolder extends HasContainerHolder, Metadatable { String SYSPROP_PAGE = "~page"; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/TraversalUtil.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/TraversalUtil.java index 204c47807a..11a5c0cee4 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/TraversalUtil.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/TraversalUtil.java @@ -243,7 +243,7 @@ public static void extractRange(Step newStep, long limit = holder.setRange(range.getLowRange(), range.getHighRange()); RangeGlobalStep newRange = new RangeGlobalStep<>( - traversal, 0, limit); + traversal, 0, limit); TraversalHelper.replaceStep(range, newRange, traversal); } } @@ -311,9 +311,9 @@ public static void extractAggregateFunc(Step newStep, } public static ConditionQuery fillConditionQuery( - ConditionQuery query, - List hasContainers, - HugeGraph graph) { + ConditionQuery query, + List hasContainers, + HugeGraph graph) { HugeType resultType = query.resultType(); for (HasContainer has : hasContainers) { @@ -550,7 +550,7 @@ public static Condition convContains2Relation(HugeGraph graph, // Convert contains-key or contains-value BiPredicate bp = has.getPredicate().getBiPredicate(); E.checkArgument(bp == Compare.eq, "CONTAINS query with relation " + - "'%s' is not supported", bp); + "'%s' is not supported", bp); HugeKeys key = token2HugeKey(has.getKey()); E.checkNotNull(key, "token key"); @@ -602,8 +602,8 @@ public static boolean keyForContainsValue(String key) { @SuppressWarnings("unchecked") public static Iterator filterResult( - List hasContainers, - Iterator iterator) { + List hasContainers, + Iterator iterator) { if (hasContainers.isEmpty()) { return (Iterator) iterator; } @@ -626,8 +626,8 @@ public static void convAllHasSteps(Traversal.Admin traversal) { // Extract all has steps in traversal @SuppressWarnings("rawtypes") List steps = - TraversalHelper.getStepsOfAssignableClassRecursively( - HasStep.class, traversal); + TraversalHelper.getStepsOfAssignableClassRecursively( + HasStep.class, traversal); if (steps.isEmpty()) { return; @@ -644,8 +644,8 @@ public static void convAllHasSteps(Traversal.Admin traversal) { } Optional parentGraph = ((Traversal) traversal.getParent()) - .asAdmin() - .getGraph(); + .asAdmin() + .getGraph(); if (parentGraph.filter(g -> !(g instanceof EmptyGraph)).isPresent()) { traversal.setGraph(parentGraph.get()); } @@ -980,7 +980,7 @@ private static Number predicateNumber(String value) { } throw new HugeException( - "Invalid value '%s', expect a number", e, value); + "Invalid value '%s', expect a number", e, value); } } @@ -1005,7 +1005,7 @@ private static Number[] predicateNumbers(String value, int count) { continue; } throw new HugeException( - "Invalid value '%s', expect a list of number", value); + "Invalid value '%s', expect a list of number", value); } return values.toArray(new Number[0]); } @@ -1016,7 +1016,7 @@ private static V predicateArg(String value) { return (V) JsonUtil.fromJson(value, Object.class); } catch (Exception e) { throw new HugeException( - "Invalid value '%s', expect a single value", e, value); + "Invalid value '%s', expect a single value", e, value); } } @@ -1026,7 +1026,7 @@ private static List predicateArgs(String value) { return JsonUtil.fromJson("[" + value + "]", List.class); } catch (Exception e) { throw new HugeException( - "Invalid value '%s', expect a list", e, value); + "Invalid value '%s', expect a list", e, value); } } } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/Nameable.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/Nameable.java index f14c19dd25..cf8e71e6d7 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/Nameable.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/Nameable.java @@ -20,6 +20,7 @@ * @author Matthias Broecheler (me@matthiasb.com) */ public interface Nameable { + /** * Returns the unique name of this entity. * diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/CollectionType.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/CollectionType.java index 52d7a3ba1b..e8a4cd3547 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/CollectionType.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/CollectionType.java @@ -60,7 +60,7 @@ public static CollectionType fromCode(byte code) { return FU; default: throw new AssertionError( - "Unsupported collection code: " + code); + "Unsupported collection code: " + code); } } } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/DataType.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/DataType.java index 69ebdbb643..2bfa93e7d7 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/DataType.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/DataType.java @@ -22,9 +22,9 @@ import java.util.List; import java.util.UUID; -import org.apache.hugegraph.util.Blob; import org.apache.hugegraph.HugeException; import org.apache.hugegraph.backend.serializer.BytesBuffer; +import org.apache.hugegraph.util.Blob; import org.apache.hugegraph.util.Bytes; import org.apache.hugegraph.util.DateUtil; import org.apache.hugegraph.util.JsonUtil; @@ -132,13 +132,13 @@ public Number valueToNumber(V value) { break; default: throw new AssertionError(String.format( - "Number type only contains Byte, Integer, " + - "Long, Float, Double, but got %s", this.clazz())); + "Number type only contains Byte, Integer, " + + "Long, Float, Double, but got %s", this.clazz())); } } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format( - "Can't read '%s' as %s: %s", - value, this.name, e.getMessage())); + "Can't read '%s' as %s: %s", + value, this.name, e.getMessage())); } return number; } @@ -199,7 +199,7 @@ public Blob valueToBlob(V value) { bytes[i] = ((Number) v).byteValue(); } else { throw new IllegalArgumentException(String.format( - "expect byte or int value, but got '%s'", v)); + "expect byte or int value, but got '%s'", v)); } } return Blob.wrap(bytes); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/Directions.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/Directions.java index b2e18373b5..1309cd89df 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/Directions.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/Directions.java @@ -60,7 +60,7 @@ public HugeType type() { return HugeType.EDGE_IN; default: throw new IllegalArgumentException(String.format( - "Can't convert direction '%s' to HugeType", this)); + "Can't convert direction '%s' to HugeType", this)); } } @@ -82,7 +82,7 @@ public Direction direction() { return Direction.BOTH; default: throw new AssertionError(String.format( - "Unrecognized direction: '%s'", this)); + "Unrecognized direction: '%s'", this)); } } @@ -96,7 +96,7 @@ public static Directions convert(Direction direction) { return BOTH; default: throw new AssertionError(String.format( - "Unrecognized direction: '%s'", direction)); + "Unrecognized direction: '%s'", direction)); } } @@ -108,7 +108,7 @@ public static Directions convert(HugeType edgeType) { return IN; default: throw new IllegalArgumentException(String.format( - "Can't convert type '%s' to Direction", edgeType)); + "Can't convert type '%s' to Direction", edgeType)); } } } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/IndexType.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/IndexType.java index 4019a34787..019ac98df9 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/IndexType.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/IndexType.java @@ -82,7 +82,7 @@ public HugeType type() { return HugeType.UNIQUE_INDEX; default: throw new AssertionError(String.format( - "Unknown index type '%s'", this)); + "Unknown index type '%s'", this)); } } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/SerialEnum.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/SerialEnum.java index 8a115bf05b..471c0c2d70 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/SerialEnum.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/SerialEnum.java @@ -21,6 +21,7 @@ import org.apache.hugegraph.type.HugeType; import org.apache.hugegraph.util.CollectionUtil; import org.apache.hugegraph.util.E; + import com.google.common.collect.HashBasedTable; import com.google.common.collect.Table; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/CompressUtil.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/CompressUtil.java index d8ff9e2998..0d41a70959 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/CompressUtil.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/CompressUtil.java @@ -45,7 +45,6 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.io.output.NullOutputStream; - import org.apache.hugegraph.backend.store.raft.RaftContext; import net.jpountz.lz4.LZ4BlockInputStream; @@ -76,12 +75,12 @@ public static void compressTar(String inputDir, String outputFile, } private static void tarDir(Path source, TarArchiveOutputStream tos) - throws IOException { + throws IOException { Files.walkFileTree(source, new SimpleFileVisitor() { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) - throws IOException { + throws IOException { String entryName = buildTarEntryName(source, dir); if (!entryName.isEmpty()) { TarArchiveEntry entry = new TarArchiveEntry(dir.toFile(), @@ -95,7 +94,7 @@ public FileVisitResult preVisitDirectory(Path dir, @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attributes) - throws IOException { + throws IOException { // Only copy files, no symbolic links if (attributes.isSymbolicLink()) { return FileVisitResult.CONTINUE; @@ -127,7 +126,7 @@ public static void decompressTar(String sourceFile, String outputDir, Path target = Paths.get(outputDir); if (Files.notExists(source)) { throw new IOException(String.format( - "The source file %s doesn't exists", source)); + "The source file %s doesn't exists", source)); } LZ4Factory factory = LZ4Factory.fastestInstance(); LZ4FastDecompressor decompressor = factory.fastDecompressor(); @@ -160,7 +159,7 @@ public static void decompressTar(String sourceFile, String outputDir, } private static Path zipSlipProtect(ArchiveEntry entry, Path targetDir) - throws IOException { + throws IOException { Path targetDirResolved = targetDir.resolve(entry.getName()); /* * Make sure normalized file still has targetDir as its prefix, @@ -183,7 +182,7 @@ public static void compressZip(String inputDir, String outputFile, public static void compressZip(String rootDir, String sourceDir, String outputFile, Checksum checksum) - throws IOException { + throws IOException { try (FileOutputStream fos = new FileOutputStream(outputFile); CheckedOutputStream cos = new CheckedOutputStream(fos, checksum); BufferedOutputStream bos = new BufferedOutputStream(cos); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/ConfigUtil.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/ConfigUtil.java index b8cb06e243..15d3f63c08 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/ConfigUtil.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/ConfigUtil.java @@ -36,11 +36,10 @@ import org.apache.commons.configuration2.tree.NodeModel; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; - import org.apache.hugegraph.HugeException; import org.apache.hugegraph.HugeFactory; import org.apache.hugegraph.config.HugeConfig; +import org.slf4j.Logger; public final class ConfigUtil { @@ -55,13 +54,13 @@ public static void checkGremlinConfig(String conf) { try { FileBasedConfigurationBuilder builder = - new FileBasedConfigurationBuilder(YAMLConfiguration.class) - .configure(params.fileBased().setFileName(conf)); + new FileBasedConfigurationBuilder(YAMLConfiguration.class) + .configure(params.fileBased().setFileName(conf)); YAMLConfiguration config = (YAMLConfiguration) builder.getConfiguration(); List> nodes = - config.childConfigurationsAt( - NODE_GRAPHS); + config.childConfigurationsAt( + NODE_GRAPHS); if (nodes == null || nodes.isEmpty()) { return; } @@ -74,9 +73,9 @@ public static void checkGremlinConfig(String conf) { for (HierarchicalConfiguration node : nodes) { NodeModel nodeModel = node.getNodeModel(); E.checkArgument(nodeModel != null && - (nodeHandler = nodeModel.getNodeHandler()) != null && - (root = nodeHandler.getRootNode()) != null, - "Node '%s' must contain root", node); + (nodeHandler = nodeModel.getNodeHandler()) != null && + (root = nodeHandler.getRootNode()) != null, + "Node '%s' must contain root", node); } } catch (ConfigurationException e) { throw new HugeException("Failed to load yaml config file '%s'", diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/Consumers.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/Consumers.java index 00c6655a39..daa54ee958 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/Consumers.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/Consumers.java @@ -254,7 +254,7 @@ public static void executeOncePerThread(ExecutorService executor, int totalThreads, Runnable callback, long invokeTimeout) - throws InterruptedException { + throws InterruptedException { // Ensure callback execute at least once for every thread final Map threadsTimes = new ConcurrentHashMap<>(); final List> tasks = new ArrayList<>(); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/FixedTimerWindowRateLimiter.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/FixedTimerWindowRateLimiter.java index 5fff4b4e8b..0163656d5b 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/FixedTimerWindowRateLimiter.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/FixedTimerWindowRateLimiter.java @@ -24,7 +24,7 @@ /** * This class is used for fixed window to limit request per second * The different with stopwatch is to use timer for reducing count times - * + *

* TODO: Move to common module */ public class FixedTimerWindowRateLimiter implements RateLimiter { diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/FixedWatchWindowRateLimiter.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/FixedWatchWindowRateLimiter.java index 8d93abd2da..620571b621 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/FixedWatchWindowRateLimiter.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/FixedWatchWindowRateLimiter.java @@ -25,10 +25,10 @@ /** * This class is used for fixed watch-window to rate limit request * Now just simplify for performance, don't need lock stop watch - * + *

* Note: This class is not thread safe * TODO: Move to common module - * */ + */ public class FixedWatchWindowRateLimiter implements RateLimiter { private final LongAdder count; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/GZipUtil.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/GZipUtil.java index 8ffef5d17b..962d4a33a1 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/GZipUtil.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/GZipUtil.java @@ -22,7 +22,6 @@ import java.util.zip.Inflater; import org.apache.commons.codec.digest.DigestUtils; - import org.apache.hugegraph.backend.BackendException; import org.apache.hugegraph.backend.serializer.BytesBuffer; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/JsonUtil.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/JsonUtil.java index aa3b491c24..7e634c7781 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/JsonUtil.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/JsonUtil.java @@ -20,6 +20,8 @@ import java.io.IOException; import java.util.Date; +import org.apache.hugegraph.HugeException; +import org.apache.hugegraph.io.HugeGraphSONModule; import org.apache.tinkerpop.shaded.jackson.core.JsonGenerator; import org.apache.tinkerpop.shaded.jackson.core.JsonProcessingException; import org.apache.tinkerpop.shaded.jackson.core.type.TypeReference; @@ -30,8 +32,6 @@ import org.apache.tinkerpop.shaded.jackson.databind.module.SimpleModule; import org.apache.tinkerpop.shaded.jackson.databind.ser.std.StdSerializer; -import org.apache.hugegraph.HugeException; -import org.apache.hugegraph.io.HugeGraphSONModule; import com.google.common.collect.ImmutableSet; public final class JsonUtil { @@ -91,9 +91,10 @@ public static T fromJson(String json, TypeReference typeRef) { /** * Number collection will be parsed to Double Collection via fromJson, * this method used to cast element in collection to original number type - * @param object original number - * @param clazz target type - * @return target number + * + * @param object original number + * @param clazz target type + * @return target number */ public static Object castNumber(Object object, Class clazz) { if (object instanceof Number) { diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/KryoUtil.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/KryoUtil.java index 87df7c688d..ce789c6d8d 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/KryoUtil.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/KryoUtil.java @@ -74,7 +74,7 @@ public static byte[] toKryoWithType(Object value) { @SuppressWarnings("unchecked") public static T fromKryoWithType(byte[] value) { - E.checkState(value != null, "Kryo value can't be null for object"); + E.checkState(value != null, "Kryo value can't be null for object"); return (T) kryo().readClassAndObject(new Input(value)); } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/LockUtil.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/LockUtil.java index 842b590f16..fd4e6814d6 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/LockUtil.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/LockUtil.java @@ -29,14 +29,14 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; -import org.apache.hugegraph.backend.id.Id; -import org.slf4j.Logger; - import org.apache.hugegraph.HugeException; +import org.apache.hugegraph.backend.id.Id; import org.apache.hugegraph.concurrent.KeyLock; import org.apache.hugegraph.concurrent.LockManager; import org.apache.hugegraph.concurrent.RowLock; import org.apache.hugegraph.type.HugeType; +import org.slf4j.Logger; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; @@ -109,8 +109,8 @@ private static Lock lockRead(String group, String lock) { lock, group); if (!readLock.tryLock()) { throw new HugeException( - "Lock [%s:%s] is locked by other operation", - group, lock); + "Lock [%s:%s] is locked by other operation", + group, lock); } LOG.debug("Got the read lock '{}' of LockGroup '{}'", lock, group); return readLock; @@ -125,8 +125,8 @@ private static Lock lockWrite(String group, String lock, long time) { try { if (!writeLock.tryLock(time, TimeUnit.SECONDS)) { throw new HugeException( - "Lock [%s:%s] is locked by other operation", - group, lock); + "Lock [%s:%s] is locked by other operation", + group, lock); } break; } catch (InterruptedException ignore) { @@ -197,8 +197,8 @@ public static List lock(String... locks) { break; default: throw new IllegalArgumentException(String.format( - "Invalid args '%s' at position '%s', " + - "expect 'write' or 'read'", locks[i], i)); + "Invalid args '%s' at position '%s', " + + "expect 'write' or 'read'", locks[i], i)); } } return lockList; @@ -216,7 +216,7 @@ public static String hugeType2Group(HugeType type) { return INDEX_LABEL_ADD_UPDATE; default: throw new AssertionError(String.format( - "Invalid HugeType '%s'", type)); + "Invalid HugeType '%s'", type)); } } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/ParameterUtil.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/ParameterUtil.java index 4eb81a8b15..3dbbff6b9d 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/ParameterUtil.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/ParameterUtil.java @@ -17,8 +17,6 @@ package org.apache.hugegraph.util; -import org.apache.hugegraph.util.E; - import java.util.Map; public class ParameterUtil { diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/RateLimiter.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/RateLimiter.java index 990a03a7ee..e5a9d47643 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/RateLimiter.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/RateLimiter.java @@ -34,6 +34,9 @@ public interface RateLimiter { * * @param ratePerSecond the rate of the returned RateLimiter, measured in * how many permits become available per second + *

+ *

+ *

* * TODO: refactor it to make method unchangeable */ diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/Reflection.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/Reflection.java index 456ec9a223..150fb2949d 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/Reflection.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/Reflection.java @@ -17,14 +17,14 @@ package org.apache.hugegraph.util; -import org.apache.hugegraph.HugeException; -import org.apache.hugegraph.exception.NotSupportException; -import org.slf4j.Logger; - import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Arrays; +import org.apache.hugegraph.HugeException; +import org.apache.hugegraph.exception.NotSupportException; +import org.slf4j.Logger; + public class Reflection { private static final Logger LOG = Log.logger(Reflection.class); @@ -34,9 +34,9 @@ public class Reflection { private static final Method REGISTER_METHODS_TO_FILTER_MOTHOD; public static final String JDK_INTERNAL_REFLECT_REFLECTION = - "jdk.internal.reflect.Reflection"; + "jdk.internal.reflect.Reflection"; public static final String SUN_REFLECT_REFLECTION = - "sun.reflect.Reflection"; + "sun.reflect.Reflection"; static { Method registerFieldsToFilterMethodTemp = null; @@ -44,7 +44,7 @@ public class Reflection { Class reflectionClazzTemp = null; try { reflectionClazzTemp = Class.forName( - JDK_INTERNAL_REFLECT_REFLECTION); + JDK_INTERNAL_REFLECT_REFLECTION); } catch (ClassNotFoundException e) { try { reflectionClazzTemp = Class.forName(SUN_REFLECT_REFLECTION); @@ -80,7 +80,7 @@ public static void registerFieldsToFilter(Class containingClass, String... fieldNames) { if (REGISTER_FILEDS_TO_FILTER_METHOD == null) { throw new NotSupportException( - "Reflection.registerFieldsToFilter()"); + "Reflection.registerFieldsToFilter()"); } try { @@ -89,8 +89,8 @@ public static void registerFieldsToFilter(Class containingClass, containingClass, fieldNames); } catch (IllegalAccessException | InvocationTargetException e) { throw new HugeException( - "Failed to register class '%s' fields to filter: %s", - containingClass, Arrays.toString(fieldNames)); + "Failed to register class '%s' fields to filter: %s", + containingClass, Arrays.toString(fieldNames)); } } @@ -98,7 +98,7 @@ public static void registerMethodsToFilter(Class containingClass, String... methodNames) { if (REGISTER_METHODS_TO_FILTER_MOTHOD == null) { throw new NotSupportException( - "Reflection.registerMethodsToFilterMethod()"); + "Reflection.registerMethodsToFilterMethod()"); } try { @@ -107,8 +107,8 @@ public static void registerMethodsToFilter(Class containingClass, containingClass, methodNames); } catch (IllegalAccessException | InvocationTargetException e) { throw new HugeException( - "Failed to register class '%s' methods to filter: %s", - containingClass, Arrays.toString(methodNames)); + "Failed to register class '%s' methods to filter: %s", + containingClass, Arrays.toString(methodNames)); } } } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java index 16bf3207a3..c8d831c9cc 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java @@ -14,7 +14,6 @@ package org.apache.hugegraph.util; -import java.io.IOException; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/CollectionFactory.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/CollectionFactory.java index d600145906..eba9d4fa6e 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/CollectionFactory.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/CollectionFactory.java @@ -26,6 +26,8 @@ import java.util.Set; import org.apache.hugegraph.backend.id.Id; +import org.apache.hugegraph.type.define.CollectionType; +import org.apache.hugegraph.util.E; import org.eclipse.collections.api.map.primitive.IntObjectMap; import org.eclipse.collections.api.map.primitive.MutableIntObjectMap; import org.eclipse.collections.impl.list.mutable.FastList; @@ -33,9 +35,6 @@ import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap; import org.eclipse.collections.impl.set.mutable.UnifiedSet; -import org.apache.hugegraph.type.define.CollectionType; -import org.apache.hugegraph.util.E; - import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; @@ -74,7 +73,7 @@ public static List newList(CollectionType type) { return new ObjectArrayList<>(); default: throw new AssertionError( - "Unsupported collection type: " + type); + "Unsupported collection type: " + type); } } @@ -89,7 +88,7 @@ public static List newList(CollectionType type, return new ObjectArrayList<>(initialCapacity); default: throw new AssertionError( - "Unsupported collection type: " + type); + "Unsupported collection type: " + type); } } @@ -104,7 +103,7 @@ public static List newList(CollectionType type, return new ObjectArrayList<>(collection); default: throw new AssertionError( - "Unsupported collection type: " + type); + "Unsupported collection type: " + type); } } @@ -130,7 +129,7 @@ public static Set newSet(CollectionType type) { return new ObjectOpenHashSet<>(); default: throw new AssertionError( - "Unsupported collection type: " + type); + "Unsupported collection type: " + type); } } @@ -145,7 +144,7 @@ public static Set newSet(CollectionType type, return new ObjectOpenHashSet<>(initialCapacity); default: throw new AssertionError( - "Unsupported collection type: " + type); + "Unsupported collection type: " + type); } } @@ -160,7 +159,7 @@ public static Set newSet(CollectionType type, return new ObjectOpenHashSet<>(collection); default: throw new AssertionError( - "Unsupported collection type: " + type); + "Unsupported collection type: " + type); } } @@ -190,7 +189,7 @@ public static Map newMap(CollectionType type) { return new Object2ObjectOpenHashMap<>(); default: throw new AssertionError( - "Unsupported collection type: " + type); + "Unsupported collection type: " + type); } } @@ -205,7 +204,7 @@ public static Map newMap(CollectionType type, return new Object2ObjectOpenHashMap<>(initialCapacity); default: throw new AssertionError( - "Unsupported collection type: " + type); + "Unsupported collection type: " + type); } } @@ -220,7 +219,7 @@ public static Map newMap(CollectionType type, return new Object2ObjectOpenHashMap<>(map); default: throw new AssertionError( - "Unsupported collection type: " + type); + "Unsupported collection type: " + type); } } @@ -229,18 +228,18 @@ public static MutableIntObjectMap newIntObjectMap() { } public static MutableIntObjectMap newIntObjectMap( - int initialCapacity) { + int initialCapacity) { return new IntObjectHashMap<>(initialCapacity); } public static MutableIntObjectMap newIntObjectMap( - IntObjectMap map) { + IntObjectMap map) { return new IntObjectHashMap<>(map); } @SuppressWarnings("unchecked") public static MutableIntObjectMap newIntObjectMap( - Object... objects) { + Object... objects) { IntObjectHashMap map = IntObjectHashMap.newMap(); E.checkArgument(objects.length % 2 == 0, "Must provide even arguments for " + diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IdSet.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IdSet.java index d3d06c223c..57f3b12021 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IdSet.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IdSet.java @@ -23,11 +23,10 @@ import org.apache.hugegraph.backend.id.Id; import org.apache.hugegraph.backend.id.IdGenerator; -import org.eclipse.collections.api.iterator.MutableLongIterator; -import org.eclipse.collections.impl.set.mutable.primitive.LongHashSet; - import org.apache.hugegraph.iterator.ExtendableIterator; import org.apache.hugegraph.type.define.CollectionType; +import org.eclipse.collections.api.iterator.MutableLongIterator; +import org.eclipse.collections.impl.set.mutable.primitive.LongHashSet; public class IdSet extends AbstractSet { @@ -65,8 +64,8 @@ public boolean contains(Object object) { @Override public Iterator iterator() { return new ExtendableIterator<>( - this.nonNumberIds.iterator(), - new EcLongIdIterator(this.numberIds.longIterator())); + this.nonNumberIds.iterator(), + new EcLongIdIterator(this.numberIds.longIterator())); } @Override diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/Int2IntsMap.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/Int2IntsMap.java index 654f7bbf50..3786119bb1 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/Int2IntsMap.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/Int2IntsMap.java @@ -177,7 +177,7 @@ public String toString() { int capacity = (this.size() + 1) * 64; StringBuilder sb = new StringBuilder(capacity); sb.append("{"); - for (IntIterator iter = this.keys(); iter.hasNext();) { + for (IntIterator iter = this.keys(); iter.hasNext(); ) { if (sb.length() > 1) { sb.append(", "); } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IntIterator.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IntIterator.java index 9dd50b4c49..96d616a964 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IntIterator.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IntIterator.java @@ -47,7 +47,7 @@ public Integer next() { } static IntIterator wrap( - org.eclipse.collections.api.iterator.IntIterator iter) { + org.eclipse.collections.api.iterator.IntIterator iter) { return new EcIntIterator(iter); } @@ -64,7 +64,7 @@ final class EcIntIterator implements IntIterator { private final org.eclipse.collections.api.iterator.IntIterator iterator; public EcIntIterator(org.eclipse.collections.api.iterator.IntIterator - iterator) { + iterator) { this.iterator = iterator; } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IntMap.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IntMap.java index 2ce53d99c8..fe8f20b78e 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IntMap.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IntMap.java @@ -22,12 +22,11 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; -import org.eclipse.collections.api.map.primitive.MutableIntIntMap; -import org.eclipse.collections.impl.map.mutable.primitive.IntIntHashMap; - import org.apache.hugegraph.util.E; import org.apache.hugegraph.util.collection.IntIterator.IntIterators; import org.apache.hugegraph.util.collection.IntIterator.MapperInt2IntIterator; +import org.eclipse.collections.api.map.primitive.MutableIntIntMap; +import org.eclipse.collections.impl.map.mutable.primitive.IntIntHashMap; import sun.misc.Unsafe; @@ -70,13 +69,13 @@ final class IntMapBySegments implements IntMap { private static final int DEFAULT_SEGMENTS = (IntSet.CPUS + 8) * 32; private static final Function DEFAULT_CREATOR = - size -> new IntMapByFixedAddr(size); + size -> new IntMapByFixedAddr(size); @SuppressWarnings("static-access") private static final int BASE_OFFSET = UNSAFE.ARRAY_OBJECT_BASE_OFFSET; @SuppressWarnings("static-access") private static final int SHIFT = 31 - Integer.numberOfLeadingZeros( - UNSAFE.ARRAY_OBJECT_INDEX_SCALE); + UNSAFE.ARRAY_OBJECT_INDEX_SCALE); public IntMapBySegments(int capacity) { this(capacity, DEFAULT_SEGMENTS, DEFAULT_CREATOR); @@ -243,7 +242,7 @@ private IntMap segmentAt(int index) { * NOTE: IntMapByFixedAddr is: * - faster 3x than ec IntIntHashMap for single thread; * - faster 8x than ec IntIntHashMap for 4 threads, 4x operations - * with 0.5x cost; + * with 0.5x cost; */ final class IntMapByFixedAddr implements IntMap { @@ -260,7 +259,7 @@ final class IntMapByFixedAddr implements IntMap { private static final int BASE_OFFSET = UNSAFE.ARRAY_INT_BASE_OFFSET; @SuppressWarnings("static-access") private static final int MUL4 = 31 - Integer.numberOfLeadingZeros( - UNSAFE.ARRAY_INT_INDEX_SCALE); + UNSAFE.ARRAY_INT_INDEX_SCALE); public IntMapByFixedAddr(int capacity) { this.capacity = capacity; @@ -280,9 +279,9 @@ public IntMapByFixedAddr(int capacity) { this.indexBlockSize = IntSet.segmentSize(capacity, this.indexBlocksNum); this.indexBlockSizeShift = Integer.numberOfTrailingZeros( - this.indexBlockSize); + this.indexBlockSize); this.indexBlocksSet = new IntSet.IntSetByFixedAddr4Unsigned( - this.indexBlocksNum); + this.indexBlocksNum); this.clear(); } @@ -441,7 +440,7 @@ public boolean hasNext() { } } this.indexOfBlock = indexBlocksSet.nextKey( - this.indexOfBlock + 1); + this.indexOfBlock + 1); this.indexInBlock = 0; } assert !this.fetched; @@ -487,7 +486,7 @@ public boolean hasNext() { } } this.indexOfBlock = indexBlocksSet.nextKey( - this.indexOfBlock + 1); + this.indexOfBlock + 1); this.indexInBlock = 0; } return false; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IntMapByDynamicHash.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IntMapByDynamicHash.java index 0e761b9113..52aac88da9 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IntMapByDynamicHash.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IntMapByDynamicHash.java @@ -49,8 +49,9 @@ public class IntMapByDynamicHash implements IntMap { private static final int NULL_VALUE = Integer.MIN_VALUE; private static final AtomicReferenceFieldUpdater - TABLE_UPDATER = - AtomicReferenceFieldUpdater.newUpdater(IntMapByDynamicHash.class, Entry[].class, "table"); + TABLE_UPDATER = + AtomicReferenceFieldUpdater.newUpdater(IntMapByDynamicHash.class, Entry[].class, + "table"); private volatile Entry[] table; @@ -94,7 +95,7 @@ public IntMapByDynamicHash(int initialCapacity) { // we want 7 extra slots, and 64 bytes for each slot int are 4 bytes, // so 64 bytes are 16 ints. this.partitionedSize = - new int[SIZE_BUCKETS * 16]; + new int[SIZE_BUCKETS * 16]; } // The end index is for resizeContainer this.table = new Entry[cap + 1]; @@ -203,7 +204,7 @@ private int slowPut(int key, int value, Entry[] currentTable) { int oldVal = e.getValue(); // Key found, replace the entry Entry newEntry = - new Entry(key, value, this.createReplacementChainForRemoval(o, e)); + new Entry(key, value, this.createReplacementChainForRemoval(o, e)); if (IntMapByDynamicHash.casTableAt(currentTable, index, o, newEntry)) { return oldVal; } @@ -385,8 +386,8 @@ public void clear() { Entry o = (Entry) IntMapByDynamicHash.tableAt(currentArray, i); if (o == RESIZED || o == RESIZING) { resizeContainer = - (ResizeContainer) IntMapByDynamicHash.tableAt(currentArray, - currentArray.length - 1); + (ResizeContainer) IntMapByDynamicHash.tableAt(currentArray, + currentArray.length - 1); } else if (o != null) { Entry e = o; if (IntMapByDynamicHash.casTableAt(currentArray, i, o, null)) { @@ -645,7 +646,8 @@ private void transfer(Entry[] src, ResizeContainer resizeContainer) { */ private Entry[] helpWithResize(Entry[] currentArray) { ResizeContainer resizeContainer = - (ResizeContainer) IntMapByDynamicHash.tableAt(currentArray, currentArray.length - 1); + (ResizeContainer) IntMapByDynamicHash.tableAt(currentArray, + currentArray.length - 1); Entry[] newTable = resizeContainer.nextArray; if (resizeContainer.getQueuePosition() > ResizeContainer.QUEUE_INCREMENT) { resizeContainer.incrementResizer(); @@ -714,8 +716,8 @@ private void unconditionalCopy(Entry[] dest, Entry toCopyEntry) { Entry o = (Entry) IntMapByDynamicHash.tableAt(currentArray, index); if (o == RESIZED || o == RESIZING) { currentArray = - ((ResizeContainer) IntMapByDynamicHash.tableAt(currentArray, - length - 1)).nextArray; + ((ResizeContainer) IntMapByDynamicHash.tableAt(currentArray, + length - 1)).nextArray; } else { Entry newEntry; if (o == null) { @@ -743,8 +745,8 @@ private void unconditionalCopy(Entry[] dest, Entry toCopyEntry) { private static final class ResizeContainer extends Entry { private static final int QUEUE_INCREMENT = - Math.min(1 << 10, - Integer.highestOneBit(IntSet.CPUS) << 4); + Math.min(1 << 10, + Integer.highestOneBit(IntSet.CPUS) << 4); private final AtomicInteger resizers = new AtomicInteger(1); private final Entry[] nextArray; private final AtomicInteger queuePosition; @@ -868,6 +870,7 @@ public String toString() { /* ---------------- Iterator -------------- */ private static final class IteratorState { + private Entry[] currentTable; private int start; private int end; @@ -913,11 +916,12 @@ protected HashIterator() { private void findNext() { while (this.index < this.currentState.end) { Entry o = - (Entry) IntMapByDynamicHash.tableAt(this.currentState.currentTable, this.index); + (Entry) IntMapByDynamicHash.tableAt(this.currentState.currentTable, + this.index); if (o == RESIZED || o == RESIZING) { Entry[] nextArray = - IntMapByDynamicHash.this.helpWithResizeWhileCurrentIndex( - this.currentState.currentTable, this.index); + IntMapByDynamicHash.this.helpWithResizeWhileCurrentIndex( + this.currentState.currentTable, this.index); int endResized = this.index + 1; while (endResized < this.currentState.end) { if (IntMapByDynamicHash.tableAt(this.currentState.currentTable, @@ -931,7 +935,7 @@ private void findNext() { } if (endResized < this.currentState.end) { this.todo.add(new IteratorState( - this.currentState.currentTable, endResized, this.currentState.end)); + this.currentState.currentTable, endResized, this.currentState.end)); } int powerTwoLength = this.currentState.currentTable.length - 1; this.todo.add(new IteratorState(nextArray, this.index + powerTwoLength, @@ -974,6 +978,7 @@ final Entry nextEntry() { } private final class ValueIterator extends HashIterator { + @Override public int next() { return this.nextEntry().getValue(); @@ -981,6 +986,7 @@ public int next() { } private final class KeyIterator extends HashIterator { + @Override public int next() { return this.nextEntry().getKey(); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IntSet.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IntSet.java index 3431247c40..ce37bda8ef 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IntSet.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IntSet.java @@ -21,11 +21,10 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; +import org.apache.hugegraph.util.E; import org.eclipse.collections.api.collection.primitive.MutableIntCollection; import org.eclipse.collections.impl.set.mutable.primitive.IntHashSet; -import org.apache.hugegraph.util.E; - import io.netty.util.internal.shaded.org.jctools.util.UnsafeAccess; public interface IntSet { @@ -59,13 +58,13 @@ final class IntSetBySegments implements IntSet { private static final int DEFAULT_SEGMENTS = IntSet.CPUS * 100; private static final Function DEFAULT_CREATOR = - size -> new IntSetByFixedAddr4Unsigned(size); + size -> new IntSetByFixedAddr4Unsigned(size); @SuppressWarnings("static-access") private static final int BASE_OFFSET = UNSAFE.ARRAY_OBJECT_BASE_OFFSET; @SuppressWarnings("static-access") private static final int SHIFT = 31 - Integer.numberOfLeadingZeros( - UNSAFE.ARRAY_OBJECT_INDEX_SCALE); + UNSAFE.ARRAY_OBJECT_INDEX_SCALE); public IntSetBySegments(int capacity) { this(capacity, DEFAULT_SEGMENTS, DEFAULT_CREATOR); @@ -195,7 +194,7 @@ private IntSet segmentAt(int index) { * NOTE: IntSetByFixedAddr is: * - faster 3x than ec IntIntHashSet for single thread; * - faster 6x than ec IntIntHashSet for 4 threads, 4x operations - * with 0.67x cost; + * with 0.67x cost; * - faster 20x than ec IntIntHashSet-segment-lock for 4 threads; * - faster 60x than ec IntIntHashSet-global-lock for 4 threads; */ @@ -302,7 +301,7 @@ final class IntSetByFixedAddr4Unsigned implements IntSet { private static final int BASE_OFFSET = UNSAFE.ARRAY_LONG_BASE_OFFSET; @SuppressWarnings("static-access") private static final int MUL8 = 31 - Integer.numberOfLeadingZeros( - UNSAFE.ARRAY_LONG_INDEX_SCALE); + UNSAFE.ARRAY_LONG_INDEX_SCALE); public IntSetByFixedAddr4Unsigned(int numBits) { this.numBits = numBits; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/ObjectIntMappingFactory.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/ObjectIntMappingFactory.java index 56e9683097..832ed680bc 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/ObjectIntMappingFactory.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/ObjectIntMappingFactory.java @@ -17,10 +17,9 @@ package org.apache.hugegraph.util.collection; -import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap; - import org.apache.hugegraph.HugeException; import org.apache.hugegraph.perf.PerfUtil.Watched; +import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap; public class ObjectIntMappingFactory { @@ -29,13 +28,13 @@ public static ObjectIntMapping newObjectIntMapping() { } public static ObjectIntMapping newObjectIntMapping( - boolean concurrent) { + boolean concurrent) { return concurrent ? new ConcurrentObjectIntMapping<>() : - new SingleThreadObjectIntMapping<>(); + new SingleThreadObjectIntMapping<>(); } public static final class SingleThreadObjectIntMapping - implements ObjectIntMapping { + implements ObjectIntMapping { private static final int MAGIC = 1 << 16; private static final int MAX_OFFSET = 10; @@ -103,7 +102,7 @@ public String toString() { } public static final class ConcurrentObjectIntMapping - implements ObjectIntMapping { + implements ObjectIntMapping { private final SingleThreadObjectIntMapping objectIntMapping; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/variables/HugeVariables.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/variables/HugeVariables.java index 9dc8515e33..fa3c733cc5 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/variables/HugeVariables.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/variables/HugeVariables.java @@ -38,10 +38,12 @@ import org.apache.hugegraph.schema.PropertyKey; import org.apache.hugegraph.schema.SchemaManager; import org.apache.hugegraph.schema.VertexLabel; +import org.apache.hugegraph.structure.HugeVertex; import org.apache.hugegraph.type.HugeType; import org.apache.hugegraph.type.define.Cardinality; import org.apache.hugegraph.type.define.DataType; import org.apache.hugegraph.type.define.HugeKeys; +import org.apache.hugegraph.util.Log; import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.structure.Graph.Hidden; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -49,9 +51,6 @@ import org.apache.tinkerpop.gremlin.structure.util.StringFactory; import org.slf4j.Logger; -import org.apache.hugegraph.structure.HugeVertex; -import org.apache.hugegraph.util.Log; - public class HugeVariables implements Graph.Variables { private static final Logger LOG = Log.logger(HugeVariables.class); @@ -216,7 +215,7 @@ public Optional get(String key) { String type = vertex.value(Hidden.hide(VARIABLE_TYPE)); if (!Arrays.asList(TYPES).contains(Hidden.hide(type))) { throw Graph.Variables.Exceptions - .dataTypeOfVariableValueNotSupported(type); + .dataTypeOfVariableValueNotSupported(type); } // The value of key VARIABLE_TYPE is the name of variable value return Optional.of(vertex.value(Hidden.hide(type))); @@ -262,7 +261,7 @@ public Map asMap() { String type = vertex.value(Hidden.hide(VARIABLE_TYPE)); if (!Arrays.asList(TYPES).contains(Hidden.hide(type))) { throw Graph.Variables.Exceptions - .dataTypeOfVariableValueNotSupported(type); + .dataTypeOfVariableValueNotSupported(type); } Object value = vertex.value(Hidden.hide(type)); variables.put(key, value); @@ -322,7 +321,7 @@ private void setProperty(HugeVertex vertex, String key, Object value) { vertex.property(Hidden.hide(VARIABLE_TYPE), STRING_VALUE + suffix); } else { throw Graph.Variables.Exceptions - .dataTypeOfVariableValueNotSupported(value); + .dataTypeOfVariableValueNotSupported(value); } } @@ -335,7 +334,7 @@ private void createVariableVertex(String key, Object value) { this.setProperty(vertex, key, value); } catch (IllegalArgumentException e) { throw Graph.Variables.Exceptions - .dataTypeOfVariableValueNotSupported(value, e); + .dataTypeOfVariableValueNotSupported(value, e); } // PrimaryKey id vertex.assignId(null); @@ -367,7 +366,7 @@ private ConditionQuery createVariableQuery(String name) { query.eq(HugeKeys.LABEL, vl.id()); if (name != null) { PropertyKey pkey = this.params.graph().propertyKey( - Hidden.hide(VARIABLE_KEY)); + Hidden.hide(VARIABLE_KEY)); query.query(Condition.eq(pkey.id(), name)); } query.showHidden(true);