diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 1d4b13bc5b..5bcfa103cb 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -37,7 +37,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v1 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -48,7 +48,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v1 # ℹī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -62,4 +62,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v1 diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/auth/AccessAPI.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/auth/AccessAPI.java index 5bf9c223b5..7e9b61e2e9 100644 --- a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/auth/AccessAPI.java +++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/auth/AccessAPI.java @@ -21,7 +21,6 @@ import java.util.List; -import io.swagger.annotations.Api; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.ws.rs.Consumes; import jakarta.ws.rs.DELETE; diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/gremlin/CypherAPI.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/gremlin/CypherAPI.java index 15a0ca1884..d3626a259e 100644 --- a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/gremlin/CypherAPI.java +++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/gremlin/CypherAPI.java @@ -28,7 +28,6 @@ public class CypherAPI extends GremlinQueryAPI { private static final Logger LOG = Log.logger(CypherAPI.class); - @GET @Timed @CompressInterceptor.Compress(buffer = (1024 * 40)) @@ -63,11 +62,11 @@ private Response queryByCypher(String graph, LOG.debug("translated gremlin is {}", gremlin); String auth = headers.getHeaderString(HttpHeaders.AUTHORIZATION); - String request = "{" - + "\"gremlin\":\"" + gremlin + "\"," - + "\"bindings\":{}," - + "\"language\":\"gremlin-groovy\"," - + "\"aliases\":{\"g\":\"__g_" + graph + "\"}}"; + String request = "{" + + "\"gremlin\":\"" + gremlin + "\"," + + "\"bindings\":{}," + + "\"language\":\"gremlin-groovy\"," + + "\"aliases\":{\"g\":\"__g_" + graph + "\"}}"; Response response = this.client().doPostRequest(auth, request); return transformResponseIfNeeded(response); diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/gremlin/GremlinAPI.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/gremlin/GremlinAPI.java index 8f1e8504a9..f1283f8f59 100644 --- a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/gremlin/GremlinAPI.java +++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/gremlin/GremlinAPI.java @@ -19,9 +19,6 @@ package com.baidu.hugegraph.api.gremlin; -import java.util.Map; -import java.util.Set; - import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.ws.rs.Consumes; import jakarta.ws.rs.GET; @@ -30,22 +27,15 @@ import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.Context; import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.MultivaluedMap; import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.UriInfo; -import com.baidu.hugegraph.api.API; import com.baidu.hugegraph.api.filter.CompressInterceptor.Compress; import com.baidu.hugegraph.config.HugeConfig; -import com.baidu.hugegraph.config.ServerOptions; -import com.baidu.hugegraph.exception.HugeGremlinException; import com.baidu.hugegraph.metrics.MetricsUtil; import com.codahale.metrics.Histogram; import com.codahale.metrics.annotation.Timed; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import jakarta.inject.Provider; import jakarta.inject.Singleton; @Path("gremlin") @@ -58,7 +48,6 @@ public class GremlinAPI extends GremlinQueryAPI { private static final Histogram GREMLIN_OUTPUT_HISTOGRAM = MetricsUtil.registerHistogram(GremlinAPI.class, "gremlin-output"); - @POST @Timed @Compress diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/JaccardSimilarityAPI.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/JaccardSimilarityAPI.java index fbe09c9a3c..d8ec29562c 100644 --- a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/JaccardSimilarityAPI.java +++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/traversers/JaccardSimilarityAPI.java @@ -86,8 +86,8 @@ public String get(@Context GraphManager manager, double similarity; try (JaccardSimilarTraverser traverser = new JaccardSimilarTraverser(g)) { - similarity = traverser.jaccardSimilarity(sourceId, targetId, dir, - edgeLabel, maxDegree); + similarity = traverser.jaccardSimilarity(sourceId, targetId, dir, + edgeLabel, maxDegree); } return JsonUtil.toJson(ImmutableMap.of("jaccard_similarity", similarity)); diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/auth/HugeAuthenticator.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/auth/HugeAuthenticator.java index b6369b3552..88c5c78705 100644 --- a/hugegraph-api/src/main/java/com/baidu/hugegraph/auth/HugeAuthenticator.java +++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/auth/HugeAuthenticator.java @@ -43,36 +43,33 @@ public interface HugeAuthenticator extends Authenticator { - public static final String KEY_USERNAME = - CredentialGraphTokens.PROPERTY_USERNAME; - public static final String KEY_PASSWORD = - CredentialGraphTokens.PROPERTY_PASSWORD; - public static final String KEY_TOKEN = "token"; - public static final String KEY_ROLE = "role"; - public static final String KEY_ADDRESS = "address"; - public static final String KEY_PATH = "path"; + String KEY_USERNAME = CredentialGraphTokens.PROPERTY_USERNAME; + String KEY_PASSWORD = CredentialGraphTokens.PROPERTY_PASSWORD; + String KEY_TOKEN = "token"; + String KEY_ROLE = "role"; + String KEY_ADDRESS = "address"; + String KEY_PATH = "path"; - public static final String USER_SYSTEM = "system"; - public static final String USER_ADMIN = "admin"; - public static final String USER_ANONY = AuthenticatedUser.ANONYMOUS_USERNAME; + String USER_SYSTEM = "system"; + String USER_ADMIN = "admin"; + String USER_ANONY = AuthenticatedUser.ANONYMOUS_USERNAME; - public static final RolePermission ROLE_NONE = RolePermission.none(); - public static final RolePermission ROLE_ADMIN = RolePermission.admin(); + RolePermission ROLE_NONE = RolePermission.none(); + RolePermission ROLE_ADMIN = RolePermission.admin(); - public static final String VAR_PREFIX = "$"; - public static final String KEY_OWNER = VAR_PREFIX + "owner"; - public static final String KEY_DYNAMIC = VAR_PREFIX + "dynamic"; - public static final String KEY_ACTION = VAR_PREFIX + "action"; + String VAR_PREFIX = "$"; + String KEY_OWNER = VAR_PREFIX + "owner"; + String KEY_DYNAMIC = VAR_PREFIX + "dynamic"; + String KEY_ACTION = VAR_PREFIX + "action"; - public void setup(HugeConfig config); + void setup(HugeConfig config); - public UserWithRole authenticate(String username, String password, - String token); + UserWithRole authenticate(String username, String password, String token); - public AuthManager authManager(); + AuthManager authManager(); @Override - public default void setup(final Map config) { + default void setup(final Map config) { E.checkState(config != null, "Must provide a 'config' in the 'authentication'"); String path = (String) config.get("tokens"); @@ -83,8 +80,9 @@ public default void setup(final Map config) { } @Override - public default User authenticate(final Map credentials) - throws AuthenticationException { + default User authenticate(final Map credentials) + throws AuthenticationException { + HugeGraphAuthProxy.resetContext(); User user = User.ANONYMOUS; @@ -115,11 +113,11 @@ public default User authenticate(final Map credentials) } @Override - public default boolean requireAuthentication() { + default boolean requireAuthentication() { return true; } - public default boolean verifyRole(RolePermission role) { + default boolean verifyRole(RolePermission role) { if (role == ROLE_NONE || role == null) { return false; } else { @@ -127,9 +125,9 @@ public default boolean verifyRole(RolePermission role) { } } - public void initAdminUser(String password) throws Exception; + void initAdminUser(String password) throws Exception; - public static HugeAuthenticator loadAuthenticator(HugeConfig conf) { + static HugeAuthenticator loadAuthenticator(HugeConfig conf) { String authClass = conf.get(ServerOptions.AUTHENTICATOR); if (authClass.isEmpty()) { return null; @@ -150,7 +148,7 @@ public static HugeAuthenticator loadAuthenticator(HugeConfig conf) { return authenticator; } - public static class User extends AuthenticatedUser { + class User extends AuthenticatedUser { public static final User ADMIN = new User(USER_ADMIN, ROLE_ADMIN); public static final User ANONYMOUS = new User(USER_ANONY, ROLE_ADMIN); @@ -255,7 +253,7 @@ public static class UserJson { } } - public static class RolePerm { + class RolePerm { @JsonProperty("roles") // graph -> action -> resource private Map> roles; @@ -395,7 +393,7 @@ public static boolean match(Object role, RolePermission grant, } } - public static class RequiredPerm { + class RequiredPerm { @JsonProperty("owner") private String owner; diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/auth/HugeGraphAuthProxy.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/auth/HugeGraphAuthProxy.java index 6de446df86..8ca26fab9a 100644 --- a/hugegraph-api/src/main/java/com/baidu/hugegraph/auth/HugeGraphAuthProxy.java +++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/auth/HugeGraphAuthProxy.java @@ -1791,17 +1791,17 @@ public String toString() { private static final ThreadLocal CONTEXTS = new InheritableThreadLocal<>(); - protected static final Context setContext(Context context) { + protected static Context setContext(Context context) { Context old = CONTEXTS.get(); CONTEXTS.set(context); return old; } - protected static final void resetContext() { + protected static void resetContext() { CONTEXTS.remove(); } - protected static final Context getContext() { + protected static Context getContext() { // Return task context first String taskContext = TaskManager.getContext(); User user = User.fromJson(taskContext); @@ -1812,7 +1812,7 @@ protected static final Context getContext() { return CONTEXTS.get(); } - protected static final String getContextString() { + protected static String getContextString() { Context context = getContext(); if (context == null) { return null; @@ -1820,7 +1820,7 @@ protected static final String getContextString() { return context.user().toJson(); } - protected static final void logUser(User user, String path) { + protected static void logUser(User user, String path) { LOG.info("User '{}' login from client [{}] with path '{}'", user.username(), user.client(), path); } diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/auth/WsAndHttpBasicAuthHandler.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/auth/WsAndHttpBasicAuthHandler.java index 514d8e03db..580173bd9e 100644 --- a/hugegraph-api/src/main/java/com/baidu/hugegraph/auth/WsAndHttpBasicAuthHandler.java +++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/auth/WsAndHttpBasicAuthHandler.java @@ -150,10 +150,10 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) { } } - private void sendError(ChannelHandlerContext ctx, Object msg) { + private void sendError(ChannelHandlerContext context, Object msg) { // Close the connection as soon as the error message is sent. - ctx.writeAndFlush(new DefaultFullHttpResponse(HTTP_1_1, UNAUTHORIZED)) - .addListener(ChannelFutureListener.CLOSE); + context.writeAndFlush(new DefaultFullHttpResponse(HTTP_1_1, UNAUTHORIZED)) + .addListener(ChannelFutureListener.CLOSE); ReferenceCountUtil.release(msg); } } diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/define/Checkable.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/define/Checkable.java index e4246955fb..71f1d43f73 100644 --- a/hugegraph-api/src/main/java/com/baidu/hugegraph/define/Checkable.java +++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/define/Checkable.java @@ -2,9 +2,9 @@ public interface Checkable { - public void checkCreate(boolean isBatch); + void checkCreate(boolean isBatch); - public default void checkUpdate() { + default void checkUpdate() { this.checkCreate(false); } } diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/serializer/Serializer.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/serializer/Serializer.java index a7544d0368..e5b1c1bcea 100644 --- a/hugegraph-api/src/main/java/com/baidu/hugegraph/serializer/Serializer.java +++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/serializer/Serializer.java @@ -42,65 +42,60 @@ public interface Serializer { - public String writeMap(Map map); + String writeMap(Map map); - public String writeList(String label, Collection list); + String writeList(String label, Collection list); - public String writePropertyKey(PropertyKey propertyKey); + String writePropertyKey(PropertyKey propertyKey); - public String writePropertyKeys(List propertyKeys); + String writePropertyKeys(List propertyKeys); - public String writeVertexLabel(VertexLabel vertexLabel); + String writeVertexLabel(VertexLabel vertexLabel); - public String writeVertexLabels(List vertexLabels); + String writeVertexLabels(List vertexLabels); - public String writeEdgeLabel(EdgeLabel edgeLabel); + String writeEdgeLabel(EdgeLabel edgeLabel); - public String writeEdgeLabels(List edgeLabels); + String writeEdgeLabels(List edgeLabels); - public String writeIndexlabel(IndexLabel indexLabel); + String writeIndexlabel(IndexLabel indexLabel); - public String writeIndexlabels(List indexLabels); + String writeIndexlabels(List indexLabels); - public String writeTaskWithSchema(SchemaElement.TaskWithSchema tws); + String writeTaskWithSchema(SchemaElement.TaskWithSchema tws); - public String writeVertex(Vertex v); + String writeVertex(Vertex v); - public String writeVertices(Iterator vertices, boolean paging); + String writeVertices(Iterator vertices, boolean paging); - public String writeEdge(Edge e); + String writeEdge(Edge e); - public String writeEdges(Iterator edges, boolean paging); + String writeEdges(Iterator edges, boolean paging); - public String writeIds(List ids); + String writeIds(List ids); - public String writeAuthElement(AuthElement elem); + String writeAuthElement(AuthElement elem); - public String writeAuthElements(String label, - List users); + String writeAuthElements(String label, List users); - public String writePaths(String name, Collection paths, - boolean withCrossPoint, Iterator vertices); + String writePaths(String name, Collection paths, + boolean withCrossPoint, Iterator vertices); - public default String writePaths(String name, - Collection paths, - boolean withCrossPoint) { + default String writePaths(String name, Collection paths, + boolean withCrossPoint) { return this.writePaths(name, paths, withCrossPoint, null); } - public String writeCrosspoints(CrosspointsPaths paths, - Iterator iterator, boolean withPath); + String writeCrosspoints(CrosspointsPaths paths, Iterator iterator, + boolean withPath); - public String writeSimilars(SimilarsMap similars, - Iterator vertices); + String writeSimilars(SimilarsMap similars, Iterator vertices); - public String writeWeightedPath(NodeWithWeight path, - Iterator vertices); + String writeWeightedPath(NodeWithWeight path, Iterator vertices); - public String writeWeightedPaths(WeightedPaths paths, - Iterator vertices); + String writeWeightedPaths(WeightedPaths paths, Iterator vertices); - public String writeNodesWithPath(String name, List nodes, long size, - Collection paths, - Iterator vertices); + String writeNodesWithPath(String name, List nodes, long size, + Collection paths, + Iterator vertices); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/analyzer/Analyzer.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/analyzer/Analyzer.java index 52ce194eed..8cc1372219 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/analyzer/Analyzer.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/analyzer/Analyzer.java @@ -23,5 +23,5 @@ public interface Analyzer { - public Set segment(String text); + Set segment(String text); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/Transaction.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/Transaction.java index b3c066b1ec..bbf20a2b38 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/Transaction.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/Transaction.java @@ -21,13 +21,13 @@ public interface Transaction { - public void commit() throws BackendException; + void commit() throws BackendException; - public void commitIfGtSize(int size) throws BackendException; + void commitIfGtSize(int size) throws BackendException; - public void rollback() throws BackendException; + void rollback() throws BackendException; - public boolean autoCommit(); + boolean autoCommit(); - public void close(); + void close(); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/Cache.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/Cache.java index 7212a4b7f4..f7f98efcd7 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/Cache.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/Cache.java @@ -24,48 +24,48 @@ public interface Cache { - public static final String ACTION_INVALID = "invalid"; - public static final String ACTION_CLEAR = "clear"; - public static final String ACTION_INVALIDED = "invalided"; - public static final String ACTION_CLEARED = "cleared"; + String ACTION_INVALID = "invalid"; + String ACTION_CLEAR = "clear"; + String ACTION_INVALIDED = "invalided"; + String ACTION_CLEARED = "cleared"; - public V get(K id); + V get(K id); - public V getOrFetch(K id, Function fetcher); + V getOrFetch(K id, Function fetcher); - public boolean containsKey(K id); + boolean containsKey(K id); - public boolean update(K id, V value); + boolean update(K id, V value); - public boolean update(K id, V value, long timeOffset); + boolean update(K id, V value, long timeOffset); - public boolean updateIfAbsent(K id, V value); + boolean updateIfAbsent(K id, V value); - public boolean updateIfPresent(K id, V value); + boolean updateIfPresent(K id, V value); - public void invalidate(K id); + void invalidate(K id); - public void traverse(Consumer consumer); + void traverse(Consumer consumer); - public void clear(); + void clear(); - public void expire(long ms); + void expire(long ms); - public long expire(); + long expire(); - public long tick(); + long tick(); - public long capacity(); + long capacity(); - public long size(); + long size(); - public boolean enableMetrics(boolean enabled); + boolean enableMetrics(boolean enabled); - public long hits(); + long hits(); - public long miss(); + long miss(); - public T attachment(T object); + T attachment(T object); - public T attachment(); + T attachment(); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CacheNotifier.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CacheNotifier.java index 39154807a0..784d8e6917 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CacheNotifier.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CacheNotifier.java @@ -24,15 +24,15 @@ public interface CacheNotifier extends AutoCloseable { - public void invalid(HugeType type, Id id); + void invalid(HugeType type, Id id); - public void invalid2(HugeType type, Object[] ids); + void invalid2(HugeType type, Object[] ids); - public void clear(HugeType type); + void clear(HugeType type); - public void reload(); + void reload(); - public interface GraphCacheNotifier extends CacheNotifier {} + interface GraphCacheNotifier extends CacheNotifier {} - public interface SchemaCacheNotifier extends CacheNotifier {} + interface SchemaCacheNotifier extends CacheNotifier {} } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedGraphTransaction.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedGraphTransaction.java index fed55dc8f7..6ba16dca96 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedGraphTransaction.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedGraphTransaction.java @@ -235,7 +235,7 @@ private boolean needCacheVertex(HugeVertex vertex) { @Override @Watched(prefix = "graphcache") - protected final Iterator queryVerticesFromBackend(Query query) { + protected Iterator queryVerticesFromBackend(Query query) { if (this.enableCacheVertex() && query.idsSize() > 0 && query.conditionsSize() == 0) { return this.queryVerticesByIds((IdQuery) query); @@ -307,7 +307,7 @@ private Iterator queryVerticesByIds(IdQuery query) { @Override @Watched(prefix = "graphcache") - protected final Iterator queryEdgesFromBackend(Query query) { + protected Iterator queryEdgesFromBackend(Query query) { RamTable ramtable = this.params().ramtable(); if (ramtable != null && ramtable.matched(query)) { return ramtable.query(query); @@ -362,7 +362,7 @@ protected final Iterator queryEdgesFromBackend(Query query) { @Override @Watched(prefix = "graphcache") - protected final void commitMutation2Backend(BackendMutation... mutations) { + protected void commitMutation2Backend(BackendMutation... mutations) { // Collect changes before commit Collection updates = this.verticesInTxUpdated(); Collection deletions = this.verticesInTxRemoved(); @@ -414,7 +414,7 @@ protected final void commitMutation2Backend(BackendMutation... mutations) { } @Override - public final void removeIndex(IndexLabel indexLabel) { + public void removeIndex(IndexLabel indexLabel) { try { super.removeIndex(indexLabel); } finally { diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java index 331b038df8..a145b53fad 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java @@ -137,22 +137,22 @@ private void unlistenChanges() { schemaEventHub.unlisten(Events.CACHE, this.cacheEventListener); } - private final void notifyChanges(String action, HugeType type, Id id) { + private void notifyChanges(String action, HugeType type, Id id) { EventHub graphEventHub = this.params().schemaEventHub(); graphEventHub.notify(Events.CACHE, action, type, id); } - private final void notifyChanges(String action, HugeType type) { + private void notifyChanges(String action, HugeType type) { EventHub graphEventHub = this.params().schemaEventHub(); graphEventHub.notify(Events.CACHE, action, type); } - private final void resetCachedAll(HugeType type) { + private void resetCachedAll(HugeType type) { // Set the cache all flag of the schema type to false this.cachedTypes().put(type, false); } - private final void resetCachedAllIfReachedCapacity() { + private void resetCachedAllIfReachedCapacity() { if (this.idCache.size() >= this.idCache.capacity()) { LOG.warn("Schema cache reached capacity({}): {}", this.idCache.capacity(), this.idCache.size()); @@ -160,11 +160,11 @@ private final void resetCachedAllIfReachedCapacity() { } } - private final CachedTypes cachedTypes() { + private CachedTypes cachedTypes() { return this.arrayCaches.cachedTypes(); } - private final void clearCache(boolean notify) { + private void clearCache(boolean notify) { this.idCache.clear(); this.nameCache.clear(); this.arrayCaches.clear(); @@ -174,7 +174,7 @@ private final void clearCache(boolean notify) { } } - private final void updateCache(SchemaElement schema) { + private void updateCache(SchemaElement schema) { this.resetCachedAllIfReachedCapacity(); // update id cache @@ -189,7 +189,7 @@ private final void updateCache(SchemaElement schema) { this.arrayCaches.updateIfNeeded(schema); } - private final void invalidateCache(HugeType type, Id id) { + private void invalidateCache(HugeType type, Id id) { // remove from id cache and name cache Id prefixedId = generateId(type, id); Object value = this.idCache.get(prefixedId); diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/OffheapCache.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/OffheapCache.java index 993809750b..cc3ccf05c9 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/OffheapCache.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/OffheapCache.java @@ -346,7 +346,7 @@ private HugeException unsupported(Object value) { } } - private static enum ValueType { + private enum ValueType { UNKNOWN, LIST, @@ -365,11 +365,11 @@ private static enum ValueType { private DataType dataType; - private ValueType() { + ValueType() { this(DataType.UNKNOWN); } - private ValueType(DataType dataType) { + ValueType(DataType dataType) { this.dataType = dataType; } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/id/Id.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/id/Id.java index 78afad4823..06cf053cfe 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/id/Id.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/id/Id.java @@ -23,37 +23,37 @@ public interface Id extends Comparable { - public static final int UUID_LENGTH = 16; + int UUID_LENGTH = 16; - public Object asObject(); + Object asObject(); - public String asString(); + String asString(); - public long asLong(); + long asLong(); - public byte[] asBytes(); + byte[] asBytes(); - public int length(); + int length(); - public IdType type(); + IdType type(); - public default boolean number() { + default boolean number() { return this.type() == IdType.LONG; } - public default boolean uuid() { + default boolean uuid() { return this.type() == IdType.UUID; } - public default boolean string() { + default boolean string() { return this.type() == IdType.STRING; } - public default boolean edge() { + default boolean edge() { return this.type() == IdType.EDGE; } - public enum IdType { + enum IdType { UNKNOWN, LONG, diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/id/IdGenerator.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/id/IdGenerator.java index 3ab42ee77e..a6b0b829b1 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/id/IdGenerator.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/id/IdGenerator.java @@ -121,7 +121,7 @@ public static final IdType idType(Id id) { return IdType.UNKNOWN; } - private static final int compareType(Id id1, Id id2) { + private static int compareType(Id id1, Id id2) { return idType(id1).ordinal() - idType(id2).ordinal(); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/page/QueryList.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/page/QueryList.java index 4e20945863..a72ef072d5 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/page/QueryList.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/page/QueryList.java @@ -130,7 +130,7 @@ private interface FlattenQuery { * For non-paging situation * @return BackendEntry iterator */ - public QueryResults iterator(); + QueryResults iterator(); /** * For paging situation @@ -139,9 +139,9 @@ private interface FlattenQuery { * @param pageSize set query page size * @return BackendEntry iterator with page */ - public PageResults iterator(int index, String page, long pageSize); + PageResults iterator(int index, String page, long pageSize); - public int total(); + int total(); } /** diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/query/Aggregate.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/query/Aggregate.java index a9a0439a1e..a5e5041e30 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/query/Aggregate.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/query/Aggregate.java @@ -60,7 +60,7 @@ public String toString() { this.column == null ? "*" : this.column); } - public static enum AggregateFunc { + public enum AggregateFunc { COUNT("count", 0L, NumberHelper::add), MAX("max", -Double.MAX_VALUE, NumberHelper::max), @@ -72,8 +72,8 @@ public static enum AggregateFunc { private final Number defaultValue; private final BiFunction merger; - private AggregateFunc(String name, Number defaultValue, - BiFunction merger) { + AggregateFunc(String name, Number defaultValue, + BiFunction merger) { this.name = name; this.defaultValue = defaultValue; this.merger = merger; diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/query/ConditionQuery.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/query/ConditionQuery.java index 7deb444bc2..6ccfbc025d 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/query/ConditionQuery.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/query/ConditionQuery.java @@ -875,8 +875,8 @@ public Id indexField() { } } - public static interface ResultsFilter { + public interface ResultsFilter { - public boolean test(HugeElement element); + boolean test(HugeElement element); } } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/query/Query.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/query/Query.java index 49e1fd8f41..397b313b52 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/query/Query.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/query/Query.java @@ -577,7 +577,7 @@ public static final void checkForceCapacity(long count) } } - public static enum Order { + public enum Order { ASC, DESC; } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/AbstractBackendStoreProvider.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/AbstractBackendStoreProvider.java index 71075a31d2..c94a25fcde 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/AbstractBackendStoreProvider.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/AbstractBackendStoreProvider.java @@ -26,7 +26,6 @@ import org.slf4j.Logger; import com.alipay.remoting.rpc.RpcServer; -import com.baidu.hugegraph.HugeGraph; import com.baidu.hugegraph.backend.BackendException; import com.baidu.hugegraph.backend.store.raft.StoreSnapshotFile; import com.baidu.hugegraph.config.CoreOptions; diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/BackendFeatures.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/BackendFeatures.java index cef6523e36..c1dac27803 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/BackendFeatures.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/BackendFeatures.java @@ -21,57 +21,57 @@ public interface BackendFeatures { - public default boolean supportsPersistence() { + default boolean supportsPersistence() { return true; } - public default boolean supportsSharedStorage() { + default boolean supportsSharedStorage() { return true; } - public default boolean supportsSnapshot() { + default boolean supportsSnapshot() { return false; } - public boolean supportsScanToken(); + boolean supportsScanToken(); - public boolean supportsScanKeyPrefix(); + boolean supportsScanKeyPrefix(); - public boolean supportsScanKeyRange(); + boolean supportsScanKeyRange(); - public boolean supportsQuerySchemaByName(); + boolean supportsQuerySchemaByName(); - public boolean supportsQueryByLabel(); + boolean supportsQueryByLabel(); - public boolean supportsQueryWithInCondition(); + boolean supportsQueryWithInCondition(); - public boolean supportsQueryWithRangeCondition(); + boolean supportsQueryWithRangeCondition(); - public boolean supportsQueryWithContains(); + boolean supportsQueryWithContains(); - public boolean supportsQueryWithContainsKey(); + boolean supportsQueryWithContainsKey(); - public boolean supportsQueryWithOrderBy(); + boolean supportsQueryWithOrderBy(); - public boolean supportsQueryByPage(); + boolean supportsQueryByPage(); - public boolean supportsQuerySortByInputIds(); + boolean supportsQuerySortByInputIds(); - public boolean supportsDeleteEdgeByLabel(); + boolean supportsDeleteEdgeByLabel(); - public boolean supportsUpdateVertexProperty(); + boolean supportsUpdateVertexProperty(); - public boolean supportsMergeVertexProperty(); + boolean supportsMergeVertexProperty(); - public boolean supportsUpdateEdgeProperty(); + boolean supportsUpdateEdgeProperty(); - public boolean supportsTransaction(); + boolean supportsTransaction(); - public boolean supportsNumberType(); + boolean supportsNumberType(); - public boolean supportsAggregateProperty(); + boolean supportsAggregateProperty(); - public boolean supportsTtl(); + boolean supportsTtl(); - public boolean supportsOlapProperties(); + boolean supportsOlapProperties(); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/BackendMetrics.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/BackendMetrics.java index e621c2e440..1a103f154f 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/BackendMetrics.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/BackendMetrics.java @@ -23,27 +23,27 @@ public interface BackendMetrics { - public String BACKEND = "backend"; + String BACKEND = "backend"; - public String NODES = "nodes"; - public String CLUSTER_ID = "cluster_id"; - public String SERVERS = "servers"; - public String SERVER_LOCAL = "local"; - public String SERVER_CLUSTER = "cluster"; + String NODES = "nodes"; + String CLUSTER_ID = "cluster_id"; + String SERVERS = "servers"; + String SERVER_LOCAL = "local"; + String SERVER_CLUSTER = "cluster"; // Memory related metrics - public String MEM_USED = "mem_used"; - public String MEM_COMMITTED = "mem_committed"; - public String MEM_MAX = "mem_max"; - public String MEM_UNIT = "mem_unit"; + String MEM_USED = "mem_used"; + String MEM_COMMITTED = "mem_committed"; + String MEM_MAX = "mem_max"; + String MEM_UNIT = "mem_unit"; // Data load related metrics - public String DISK_USAGE = "disk_usage"; - public String DISK_UNIT = "disk_unit"; + String DISK_USAGE = "disk_usage"; + String DISK_UNIT = "disk_unit"; - public String READABLE = "_readable"; + String READABLE = "_readable"; - public String EXCEPTION = "exception"; + String EXCEPTION = "exception"; - public Map metrics(); + Map metrics(); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/raft/RaftGroupManager.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/raft/RaftGroupManager.java index c15ca4e89d..7a786863bd 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/raft/RaftGroupManager.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/raft/RaftGroupManager.java @@ -23,17 +23,17 @@ public interface RaftGroupManager { - public String group(); + String group(); - public List listPeers(); + List listPeers(); - public String getLeader(); + String getLeader(); - public String transferLeaderTo(String endpoint); + String transferLeaderTo(String endpoint); - public String setLeader(String endpoint); + String setLeader(String endpoint); - public String addPeer(String endpoint); + String addPeer(String endpoint); - public String removePeer(String endpoint); + String removePeer(String endpoint); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/ram/RamMap.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/ram/RamMap.java index 62c72a4c0c..456f97e58d 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/ram/RamMap.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/ram/RamMap.java @@ -25,11 +25,11 @@ public interface RamMap { - public void clear(); + void clear(); - public long size(); + long size(); - public void writeTo(DataOutputStream buffer) throws IOException; + void writeTo(DataOutputStream buffer) throws IOException; - public void readFrom(DataInputStream buffer) throws IOException; + void readFrom(DataInputStream buffer) throws IOException; } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/job/Job.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/job/Job.java index 3b7063d4b5..32325a96f9 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/job/Job.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/job/Job.java @@ -21,7 +21,7 @@ public interface Job { - public String type(); + String type(); - public V execute() throws Exception; + V execute() throws Exception; } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/job/computer/Computer.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/job/computer/Computer.java index 5d9521754e..f735796593 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/job/computer/Computer.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/job/computer/Computer.java @@ -25,11 +25,11 @@ public interface Computer { - public String name(); + String name(); - public String category(); + String category(); - public Object call(Job job, Map parameters); + Object call(Job job, Map parameters); - public void checkParameters(Map parameters); + void checkParameters(Map parameters); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/plugin/HugeGraphPlugin.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/plugin/HugeGraphPlugin.java index c0897eab8e..742e56ef46 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/plugin/HugeGraphPlugin.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/plugin/HugeGraphPlugin.java @@ -26,27 +26,27 @@ public interface HugeGraphPlugin { - public String name(); + String name(); - public void register(); + void register(); - public String supportsMinVersion(); + String supportsMinVersion(); - public String supportsMaxVersion(); + String supportsMaxVersion(); - public static void registerOptions(String name, String classPath) { + static void registerOptions(String name, String classPath) { OptionSpace.register(name, classPath); } - public static void registerBackend(String name, String classPath) { + static void registerBackend(String name, String classPath) { BackendProviderFactory.register(name, classPath); } - public static void registerSerializer(String name, String classPath) { + static void registerSerializer(String name, String classPath) { SerializerFactory.register(name, classPath); } - public static void registerAnalyzer(String name, String classPath) { + static void registerAnalyzer(String name, String classPath) { AnalyzerFactory.register(name, classPath); } } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/rpc/RpcServiceConfig4Client.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/rpc/RpcServiceConfig4Client.java index 13cfca96f0..0833980d9d 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/rpc/RpcServiceConfig4Client.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/rpc/RpcServiceConfig4Client.java @@ -21,17 +21,17 @@ public interface RpcServiceConfig4Client { - public T serviceProxy(String interfaceId); + T serviceProxy(String interfaceId); - public T serviceProxy(String graph, String interfaceId); + T serviceProxy(String graph, String interfaceId); - public default T serviceProxy(Class clazz) { + default T serviceProxy(Class clazz) { return this.serviceProxy(clazz.getName()); } - public default T serviceProxy(String graph, Class clazz) { + default T serviceProxy(String graph, Class clazz) { return this.serviceProxy(graph, clazz.getName()); } - public void removeAllServiceProxy(); + void removeAllServiceProxy(); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/rpc/RpcServiceConfig4Server.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/rpc/RpcServiceConfig4Server.java index 7139073cf3..23541e3137 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/rpc/RpcServiceConfig4Server.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/rpc/RpcServiceConfig4Server.java @@ -21,12 +21,12 @@ public interface RpcServiceConfig4Server { - public String addService(Class clazz, S serviceImpl); + String addService(Class clazz, S serviceImpl); - public String addService(String graph, - Class clazz, S serviceImpl); + String addService(String graph, Class clazz, + S serviceImpl); - public void removeService(String serviceId); + void removeService(String serviceId); - public void removeAllService(); + void removeAllService(); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/SchemaBuilder.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/SchemaBuilder.java index 8f0b74e78f..f09d4644a5 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/SchemaBuilder.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/SchemaBuilder.java @@ -24,19 +24,19 @@ public interface SchemaBuilder { - public SchemaBuilder id(long id); + SchemaBuilder id(long id); - public T build(); + T build(); - public T create(); + T create(); - public T append(); + T append(); - public T eliminate(); + T eliminate(); - public Id remove(); + Id remove(); - public SchemaBuilder ifNotExist(); + SchemaBuilder ifNotExist(); - public SchemaBuilder checkExist(boolean checkExist); + SchemaBuilder checkExist(boolean checkExist); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/task/TaskManager.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/task/TaskManager.java index 8d9040fa64..723391e0bc 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/task/TaskManager.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/task/TaskManager.java @@ -324,15 +324,15 @@ private void scheduleOrExecuteJobForGraph(StandardTaskScheduler scheduler) { private static final ThreadLocal CONTEXTS = new ThreadLocal<>(); - protected static final void setContext(String context) { + protected static void setContext(String context) { CONTEXTS.set(context); } - protected static final void resetContext() { + protected static void resetContext() { CONTEXTS.remove(); } - public static final String getContext() { + public static String getContext() { return CONTEXTS.get(); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/records/Records.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/records/Records.java index 405ed933eb..d5444cd82c 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/records/Records.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/records/Records.java @@ -26,16 +26,16 @@ public interface Records { - public void startOneLayer(boolean forward); + void startOneLayer(boolean forward); - public void finishOneLayer(); + void finishOneLayer(); - public boolean hasNextKey(); + boolean hasNextKey(); - public Id nextKey(); + Id nextKey(); - public PathSet findPath(Id target, Function filter, - boolean all, boolean ring); + PathSet findPath(Id target, Function filter, boolean all, + boolean ring); - public long accessed(); + long accessed(); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/records/record/Record.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/records/record/Record.java index f138243fe4..0f50fa7b1a 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/records/record/Record.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/records/record/Record.java @@ -23,15 +23,15 @@ public interface Record { - public IntIterator keys(); + IntIterator keys(); - public boolean containsKey(int node); + boolean containsKey(int node); - public IntIterator get(int node); + IntIterator get(int node); - public void addPath(int node, int parent); + void addPath(int node, int parent); - public int size(); + int size(); - public boolean concurrent(); + boolean concurrent(); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/strategy/TraverseStrategy.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/strategy/TraverseStrategy.java index 9bfc2759ba..9d69e5cb5a 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/strategy/TraverseStrategy.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/strategy/TraverseStrategy.java @@ -31,22 +31,20 @@ public interface TraverseStrategy { - public abstract void traverseOneLayer( - Map> vertices, - EdgeStep step, BiConsumer consumer); + void traverseOneLayer(Map> vertices, + EdgeStep step, BiConsumer consumer); - public abstract Map> newMultiValueMap(); + Map> newMultiValueMap(); - public abstract Set newPathSet(); + Set newPathSet(); - public abstract void addNode(Map> vertices, - Id id, HugeTraverser.Node node); + void addNode(Map> vertices, Id id, + HugeTraverser.Node node); - public abstract void addNewVerticesToAll( - Map> newVertices, - Map> targets); + void addNewVerticesToAll(Map> newVertices, + Map> targets); - public static TraverseStrategy create(boolean concurrent, HugeGraph graph) { + static TraverseStrategy create(boolean concurrent, HugeGraph graph) { return concurrent ? new ConcurrentTraverseStrategy(graph) : new SingleTraverseStrategy(graph); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/QueryHolder.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/QueryHolder.java index 4cb3442545..7584e4c554 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/QueryHolder.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/QueryHolder.java @@ -30,12 +30,12 @@ public interface QueryHolder extends HasContainerHolder, Metadatable { - public static final String SYSPROP_PAGE = "~page"; + String SYSPROP_PAGE = "~page"; - public Iterator lastTimeResults(); + Iterator lastTimeResults(); @Override - public default Object metadata(String meta, Object... args) { + default Object metadata(String meta, Object... args) { Iterator results = this.lastTimeResults(); if (results instanceof Metadatable) { return ((Metadatable) results).metadata(meta, args); @@ -43,30 +43,30 @@ public default Object metadata(String meta, Object... args) { throw new IllegalStateException("Original results is not Metadatable"); } - public Query queryInfo(); + Query queryInfo(); - public default void orderBy(String key, Order order) { + default void orderBy(String key, Order order) { this.queryInfo().order(TraversalUtil.string2HugeKey(key), TraversalUtil.convOrder(order)); } - public default long setRange(long start, long end) { + default long setRange(long start, long end) { return this.queryInfo().range(start, end); } - public default void setPage(String page) { + default void setPage(String page) { this.queryInfo().page(page); } - public default void setCount() { + default void setCount() { this.queryInfo().capacity(Query.NO_CAPACITY); } - public default void setAggregate(AggregateFunc func, String key) { + default void setAggregate(AggregateFunc func, String key) { this.queryInfo().aggregate(func, key); } - public default Q injectQueryInfo(Q query) { + default Q injectQueryInfo(Q query) { query.copyBasic(this.queryInfo()); return query; } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Idfiable.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Idfiable.java index 62e40c0879..d2ab141e82 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Idfiable.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Idfiable.java @@ -23,5 +23,5 @@ public interface Idfiable { - public Id id(); + Id id(); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Indexable.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Indexable.java index 6085e52353..08cb386f92 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Indexable.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Indexable.java @@ -25,5 +25,5 @@ public interface Indexable { - public Set indexLabels(); + Set indexLabels(); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Nameable.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Nameable.java index 8d4ba418c2..eb8e474e4f 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Nameable.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Nameable.java @@ -25,6 +25,6 @@ public interface Nameable { * * @return Name of this entity. */ - public String name(); + String name(); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Propertiable.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Propertiable.java index 666633b1a7..4ca8df77b2 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Propertiable.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Propertiable.java @@ -25,5 +25,5 @@ public interface Propertiable { - public Set properties(); + Set properties(); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Typeable.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Typeable.java index c807857327..fb569fd027 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Typeable.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/type/Typeable.java @@ -22,5 +22,5 @@ public interface Typeable { // Return schema/data type - public HugeType type(); + HugeType type(); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/type/define/GraphMode.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/type/define/GraphMode.java index 97e5d143ae..906051fe51 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/type/define/GraphMode.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/type/define/GraphMode.java @@ -50,7 +50,7 @@ public enum GraphMode { private final byte code; private final String name; - private GraphMode(int code, String name) { + GraphMode(int code, String name) { assert code < 256; this.code = (byte) code; this.name = name; diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/type/define/GraphReadMode.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/type/define/GraphReadMode.java index 5fe85368eb..6c1b70d7ed 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/type/define/GraphReadMode.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/type/define/GraphReadMode.java @@ -30,7 +30,7 @@ public enum GraphReadMode { private final byte code; private final String name; - private GraphReadMode(int code, String name) { + GraphReadMode(int code, String name) { assert code < 256; this.code = (byte) code; this.name = name; diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/type/define/NodeRole.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/type/define/NodeRole.java index 645854dc44..c824b022a9 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/type/define/NodeRole.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/type/define/NodeRole.java @@ -30,7 +30,7 @@ public enum NodeRole implements SerialEnum { private final byte code; private final String name; - private NodeRole(int code, String name) { + NodeRole(int code, String name) { assert code < 256; this.code = (byte) code; this.name = name; diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/util/RateLimiter.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/util/RateLimiter.java index a1bd4952d2..c2983da684 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/util/RateLimiter.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/util/RateLimiter.java @@ -24,15 +24,13 @@ // TODO: Move to common module (concurrent package) public interface RateLimiter { - public final Logger LOG = Log.logger(RateLimiter.class); - - public final long RESET_PERIOD = 1000L; + long RESET_PERIOD = 1000L; /** * Acquires one permit from RateLimiter if it can be acquired immediately * without delay. */ - public boolean tryAcquire(); + boolean tryAcquire(); /** * Create a RateLimiter with specified rate, to keep compatible with @@ -43,7 +41,7 @@ public interface RateLimiter { * * TODO: refactor it to make method unchangeable */ - public static RateLimiter create(double ratePerSecond) { + static RateLimiter create(double ratePerSecond) { return new FixedTimerWindowRateLimiter((int) ratePerSecond); } } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/util/collection/IntIterator.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/util/collection/IntIterator.java index 7f9f52f2f3..e780dd56a6 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/util/collection/IntIterator.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/util/collection/IntIterator.java @@ -26,14 +26,14 @@ public interface IntIterator { - public final int[] EMPTY_INTS = new int[0]; - public final IntIterator EMPTY = new EmptyIntIterator(); + int[] EMPTY_INTS = new int[0]; + IntIterator EMPTY = new EmptyIntIterator(); - public boolean hasNext(); + boolean hasNext(); - public int next(); + int next(); - public default Iterator asIterator() { + default Iterator asIterator() { return new Iterator() { @Override @@ -48,20 +48,20 @@ public Integer next() { }; } - public static IntIterator wrap( + static IntIterator wrap( org.eclipse.collections.api.iterator.IntIterator iter) { return new EcIntIterator(iter); } - public static IntIterator wrap(int[] values) { + static IntIterator wrap(int[] values) { return new ArrayIntIterator(values); } - public static IntIterator wrap(int value) { + static IntIterator wrap(int value) { return new ArrayIntIterator(new int[]{value}); } - public final class EcIntIterator implements IntIterator { + final class EcIntIterator implements IntIterator { private final org.eclipse.collections.api.iterator.IntIterator iterator; @@ -81,7 +81,7 @@ public boolean hasNext() { } } - public final class ArrayIntIterator implements IntIterator { + final class ArrayIntIterator implements IntIterator { private final int[] array; private int index; @@ -102,7 +102,7 @@ public boolean hasNext() { } } - public final class EmptyIntIterator implements IntIterator { + final class EmptyIntIterator implements IntIterator { @Override public boolean hasNext() { @@ -115,7 +115,7 @@ public int next() { } } - public final class IntIterators implements IntIterator { + final class IntIterators implements IntIterator { private final List iters; private int currentIndex; @@ -158,7 +158,7 @@ public int next() { } } - public final class MapperInt2IntIterator implements IntIterator { + final class MapperInt2IntIterator implements IntIterator { private final IntIterator originIter; private final IntMapper intMapper; @@ -180,11 +180,11 @@ public int next() { public interface IntMapper { - public int map(int key); + int map(int key); } } - public final class MapperInt2ObjectIterator implements Iterator { + final class MapperInt2ObjectIterator implements Iterator { private final IntIterator originIter; private final IntMapper intMapper; @@ -207,7 +207,7 @@ public T next() { public interface IntMapper { - public T map(int key); + T map(int key); } } } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/util/collection/IntMap.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/util/collection/IntMap.java index 3bd5a14199..5d624d5beb 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/util/collection/IntMap.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/util/collection/IntMap.java @@ -199,7 +199,7 @@ public boolean concurrent() { return true; } - private final IntMap segment(int key) { + private IntMap segment(int key) { long ukey = key + this.unsignedSize; if (ukey >= this.capacity || ukey < 0L) { E.checkArgument(false, @@ -233,7 +233,7 @@ private final IntMap segment(int key) { } } - private final IntMap segmentAt(int index) { + private IntMap segmentAt(int index) { // volatile get this.maps[index] long offset = (index << SHIFT) + BASE_OFFSET; IntMap map = (IntMap) UNSAFE.getObjectVolatile(this.maps, offset); @@ -247,7 +247,7 @@ private final IntMap segmentAt(int index) { * - faster 8x than ec IntIntHashMap for 4 threads, 4x operations * with 0.5x cost; */ - public static final class IntMapByFixedAddr implements IntMap { + final class IntMapByFixedAddr implements IntMap { private final int[] values; private final int capacity; @@ -397,7 +397,7 @@ public boolean concurrent() { return true; } - private final long offset(int key) { + private long offset(int key) { if (key >= this.capacity || key < 0) { E.checkArgument(false, "The key %s is out of bound %s", key, this.capacity); @@ -509,7 +509,7 @@ public int next() { } } - public static final class IntMapByEcSegment implements IntMap { + final class IntMapByEcSegment implements IntMap { private final MutableIntIntMap[] maps; private final int segmentMask; @@ -529,7 +529,7 @@ public IntMapByEcSegment(int segments) { } } - private final MutableIntIntMap map(int key) { + private MutableIntIntMap map(int key) { // NOTE '%' is slower 20% ~ 50% than '&': key % this.maps.length; int index = key & this.segmentMask; return this.maps[index]; @@ -597,6 +597,6 @@ public boolean concurrent() { } } - public static final int NULL_VALUE = Integer.MIN_VALUE; - public static final Unsafe UNSAFE = IntSet.UNSAFE; + int NULL_VALUE = Integer.MIN_VALUE; + Unsafe UNSAFE = IntSet.UNSAFE; } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/util/collection/IntSet.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/util/collection/IntSet.java index 5a070f1ea9..82f56a0a64 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/util/collection/IntSet.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/util/collection/IntSet.java @@ -151,7 +151,7 @@ public boolean concurrent() { return true; } - private final IntSet segment(int key) { + private IntSet segment(int key) { long ukey = key + this.unsignedSize; if (ukey >= this.capacity || ukey < 0L) { E.checkArgument(false, @@ -185,7 +185,7 @@ private final IntSet segment(int key) { } } - private final IntSet segmentAt(int index) { + private IntSet segmentAt(int index) { // volatile get this.sets[index] long offset = (index << SHIFT) + BASE_OFFSET; IntSet set = (IntSet) UNSAFE.getObjectVolatile(this.sets, offset); @@ -201,7 +201,7 @@ private final IntSet segmentAt(int index) { * - faster 20x than ec IntIntHashSet-segment-lock for 4 threads; * - faster 60x than ec IntIntHashSet-global-lock for 4 threads; */ - public static final class IntSetByFixedAddr implements IntSet { + final class IntSetByFixedAddr implements IntSet { private final long[] bits; private final long numBits; @@ -284,7 +284,7 @@ public boolean concurrent() { return true; } - private final long offset(long key) { + private long offset(long key) { long ukey = key + this.numBitsUnsigned; if (ukey >= this.numBits || ukey < 0L) { E.checkArgument(false, "The key %s is out of bound %s", @@ -294,7 +294,7 @@ private final long offset(long key) { } } - public static final class IntSetByFixedAddr4Unsigned implements IntSet { + final class IntSetByFixedAddr4Unsigned implements IntSet { private final long[] bits; private final int numBits; @@ -422,7 +422,7 @@ public int nextKey(int key) { return key; } - private final long offset(int key) { + private long offset(int key) { if (key >= this.numBits || key < 0) { E.checkArgument(false, "The key %s is out of bound %s", key, this.numBits); @@ -430,7 +430,7 @@ private final long offset(int key) { return bitOffsetToByteOffset(key); } - private static final long bitOffsetToByteOffset(long key) { + private static long bitOffsetToByteOffset(long key) { // bits to long offset long index = key >> DIV64; // long offset to byte offset @@ -440,14 +440,14 @@ private static final long bitOffsetToByteOffset(long key) { return offset; } - private static final long bitmaskOfKey(long key) { + private static long bitmaskOfKey(long key) { long bitIndex = key & MOD64; long bitmask = 1L << bitIndex; return bitmask; } } - public static final class IntSetByEcSegment implements IntSet { + final class IntSetByEcSegment implements IntSet { private final MutableIntCollection[] sets; private final int segmentMask; @@ -467,7 +467,7 @@ public IntSetByEcSegment(int segments) { } } - private final MutableIntCollection set(int key) { + private MutableIntCollection set(int key) { // NOTE '%' is slower 20% ~ 50% than '&': key % this.sets.length; int index = key & this.segmentMask; return this.sets[index]; @@ -510,7 +510,7 @@ public boolean concurrent() { } } - public static final class IntSetByFixedAddrByHppc implements IntSet { + final class IntSetByFixedAddrByHppc implements IntSet { private final com.carrotsearch.hppc.BitSet bits; @@ -551,13 +551,13 @@ public boolean concurrent() { } } - public static final int CPUS = Runtime.getRuntime().availableProcessors(); - public static final sun.misc.Unsafe UNSAFE = UnsafeAccess.UNSAFE; + int CPUS = Runtime.getRuntime().availableProcessors(); + sun.misc.Unsafe UNSAFE = UnsafeAccess.UNSAFE; - public static final long MOD64 = 0x3fL; - public static final int DIV64 = 6; + long MOD64 = 0x3fL; + int DIV64 = 6; - public static int segmentSize(long capacity, int segments) { + static int segmentSize(long capacity, int segments) { long eachSize = capacity / segments; eachSize = IntSet.sizeToPowerOf2Size((int) eachSize); /* @@ -571,7 +571,7 @@ public static int segmentSize(long capacity, int segments) { return (int) eachSize; } - public static int sizeToPowerOf2Size(int size) { + static int sizeToPowerOf2Size(int size) { if (size < 1) { size = 1; } @@ -587,7 +587,7 @@ public static int sizeToPowerOf2Size(int size) { return size; } - public static int bits2words(long numBits) { + static int bits2words(long numBits) { return (int) ((numBits - 1) >>> DIV64) + 1; } } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/util/collection/ObjectIntMapping.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/util/collection/ObjectIntMapping.java index 21737092df..072439b80e 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/util/collection/ObjectIntMapping.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/util/collection/ObjectIntMapping.java @@ -21,9 +21,9 @@ public interface ObjectIntMapping { - public int object2Code(Object object); + int object2Code(Object object); - public V code2Object(int code); + V code2Object(int code); - public void clear(); + void clear(); } diff --git a/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseSessions.java b/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseSessions.java index 35d8e051c5..03d0d5596e 100644 --- a/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseSessions.java +++ b/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseSessions.java @@ -231,7 +231,7 @@ public void createTable(String table, List cfs) throws IOException { } } - public void createPreSplitTable(String table, List cfs, + public void createPreSplitTable(String table, List cfs, short numOfPartitions) throws IOException { TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder( TableName.valueOf(this.namespace, table)); @@ -331,20 +331,20 @@ public interface HbaseSession { /** * Add a row record to a table */ - public abstract void put(String table, byte[] family, byte[] rowkey, - Collection columns); + void put(String table, byte[] family, byte[] rowkey, + Collection columns); /** * Add a row record to a table(can be used when adding an index) */ - public abstract void put(String table, byte[] family, - byte[] rowkey, byte[] qualifier, byte[] value); + void put(String table, byte[] family, byte[] rowkey, byte[] qualifier, + byte[] value); /** * Delete a record by rowkey and qualifier from a table */ - public default void remove(String table, byte[] family, - byte[] rowkey, byte[] qualifier) { + default void remove(String table, byte[] family, byte[] rowkey, + byte[] qualifier) { this.remove(table, family, rowkey, qualifier, false); } @@ -352,34 +352,33 @@ public default void remove(String table, byte[] family, * Delete a record by rowkey and qualifier from a table, * just delete the latest version of the specified column if need */ - public void remove(String table, byte[] family, byte[] rowkey, - byte[] qualifier, boolean latestVersion); + void remove(String table, byte[] family, byte[] rowkey, + byte[] qualifier, boolean latestVersion); /** * Delete a record by rowkey from a table */ - public void delete(String table, byte[] family, byte[] rowkey); + void delete(String table, byte[] family, byte[] rowkey); /** * Get a record by rowkey and qualifier from a table */ - public R get(String table, byte[] family, byte[] rowkey, - byte[] qualifier); + R get(String table, byte[] family, byte[] rowkey, byte[] qualifier); /** * Get a record by rowkey from a table */ - public R get(String table, byte[] family, byte[] rowkey); + R get(String table, byte[] family, byte[] rowkey); /** * Get multi records by rowkeys from a table */ - public R get(String table, byte[] family, Set rowkeys); + R get(String table, byte[] family, Set rowkeys); /** * Scan all records from a table */ - public default R scan(String table, long limit) { + default R scan(String table, long limit) { Scan scan = new Scan(); if (limit >= 0) { scan.setFilter(new PageFilter(limit)); @@ -390,14 +389,14 @@ public default R scan(String table, long limit) { /** * Scan records by rowkey prefix from a table */ - public default R scan(String table, byte[] prefix) { + default R scan(String table, byte[] prefix) { return this.scan(table, prefix, true, prefix); } /** * Scan records by multi rowkey prefixes from a table */ - public default R scan(String table, Set prefixes) { + default R scan(String table, Set prefixes) { FilterList orFilters = new FilterList(Operator.MUST_PASS_ONE); for (byte[] prefix : prefixes) { FilterList andFilters = new FilterList(Operator.MUST_PASS_ALL); @@ -416,8 +415,8 @@ public default R scan(String table, Set prefixes) { /** * Scan records by rowkey start and prefix from a table */ - public default R scan(String table, byte[] startRow, - boolean inclusiveStart, byte[] prefix) { + default R scan(String table, byte[] startRow, boolean inclusiveStart, + byte[] prefix) { Scan scan = new Scan().withStartRow(startRow, inclusiveStart) .setFilter(new PrefixFilter(prefix)); return this.scan(table, scan); @@ -426,16 +425,15 @@ public default R scan(String table, byte[] startRow, /** * Scan records by rowkey range from a table */ - public default R scan(String table, byte[] startRow, byte[] stopRow) { + default R scan(String table, byte[] startRow, byte[] stopRow) { return this.scan(table, startRow, true, stopRow, false); } /** * Scan records by rowkey range from a table */ - public default R scan(String table, - byte[] startRow, boolean inclusiveStart, - byte[] stopRow, boolean inclusiveStop) { + default R scan(String table, byte[] startRow, boolean inclusiveStart, + byte[] stopRow, boolean inclusiveStop) { Scan scan = new Scan().withStartRow(startRow, inclusiveStart); if (stopRow != null) { scan.withStopRow(stopRow, inclusiveStop); @@ -446,20 +444,20 @@ public default R scan(String table, /** * Inner scan: send scan request to HBase and get iterator */ - public R scan(String table, Scan scan); + R scan(String table, Scan scan); /** * Increase a counter by rowkey and qualifier to a table */ - public long increase(String table, byte[] family, - byte[] rowkey, byte[] qualifier, long value); + long increase(String table, byte[] family, byte[] rowkey, + byte[] qualifier, long value); } /** * Session implement for HBase */ public class Session extends AbstractBackendSession - implements HbaseSession { + implements HbaseSession { private final Map> batch; @@ -485,7 +483,7 @@ private int batchSize() { } private void checkBatchResults(Object[] results, List rows) - throws Throwable { + throws Throwable { assert rows.size() == results.length; for (int i = 0; i < results.length; i++) { Object result = results[i]; @@ -554,7 +552,7 @@ public Integer commit() { } catch (Throwable e) { // TODO: Mark and delete committed records throw new BackendException("Failed to commit, " + - "there may be inconsistent states for HBase", e); + "there may be inconsistent states for HBase", e); } } @@ -809,7 +807,7 @@ private void dump(String table, Scan scan) throws IOException { byte[] key = CellUtil.cloneQualifier(cell); byte[] val = CellUtil.cloneValue(cell); LOG.info(" {}={}", StringEncoding.format(key), - StringEncoding.format(val)); + StringEncoding.format(val)); } } } diff --git a/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseStore.java b/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseStore.java index 9cd5c233a4..7256dd830c 100644 --- a/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseStore.java +++ b/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseStore.java @@ -440,7 +440,7 @@ public void rollbackTx() { session.rollback(); } - private final void checkConnectionOpened() { + private void checkConnectionOpened() { E.checkState(this.sessions != null && this.sessions.opened(), "HBase store has not been initialized"); } diff --git a/hugegraph-rocksdb/src/main/java/com/baidu/hugegraph/backend/store/rocksdb/RocksDBSessions.java b/hugegraph-rocksdb/src/main/java/com/baidu/hugegraph/backend/store/rocksdb/RocksDBSessions.java index 2d56a35a08..ad74bc6abb 100644 --- a/hugegraph-rocksdb/src/main/java/com/baidu/hugegraph/backend/store/rocksdb/RocksDBSessions.java +++ b/hugegraph-rocksdb/src/main/java/com/baidu/hugegraph/backend/store/rocksdb/RocksDBSessions.java @@ -133,6 +133,6 @@ public static boolean matchScanType(int expected, int actual) { public interface Countable { - public long count(); + long count(); } } diff --git a/hugegraph-rocksdb/src/main/java/com/baidu/hugegraph/backend/store/rocksdb/RocksDBStore.java b/hugegraph-rocksdb/src/main/java/com/baidu/hugegraph/backend/store/rocksdb/RocksDBStore.java index 467d4c4618..c55d92e331 100644 --- a/hugegraph-rocksdb/src/main/java/com/baidu/hugegraph/backend/store/rocksdb/RocksDBStore.java +++ b/hugegraph-rocksdb/src/main/java/com/baidu/hugegraph/backend/store/rocksdb/RocksDBStore.java @@ -797,13 +797,13 @@ public void resumeSnapshot(String snapshotPrefix, boolean deleteSnapshot) { } } - private final void useSessions() { + private void useSessions() { for (RocksDBSessions sessions : this.sessions()) { sessions.useSession(); } } - private final void closeSessions() { + private void closeSessions() { Iterator> iter = this.dbs.entrySet() .iterator(); while (iter.hasNext()) { @@ -816,7 +816,7 @@ private final void closeSessions() { } } - private final List session() { + private List session() { this.checkOpened(); if (this.tableDiskMapping.isEmpty()) { @@ -832,12 +832,13 @@ private final List session() { return list; } - private final Collection sessions() { + private Collection sessions() { return this.dbs.values(); } - private final void parseTableDiskMapping(Map disks, - String dataPath) { + private void parseTableDiskMapping(Map disks, + String dataPath) { + this.tableDiskMapping.clear(); for (Map.Entry disk : disks.entrySet()) { // The format of `disk` like: `graph/vertex: /path/to/disk1` @@ -884,7 +885,7 @@ private String findDiskTableKeyByPath(String diskPath) { return diskTableKey; } - private final void checkDbOpened() { + private void checkDbOpened() { E.checkState(this.sessions != null && !this.sessions.closed(), "RocksDB has not been opened"); } diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/UnitTestSuite.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/UnitTestSuite.java index fe8f0d14da..c95aaf6007 100644 --- a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/UnitTestSuite.java +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/UnitTestSuite.java @@ -66,7 +66,6 @@ import com.baidu.hugegraph.unit.serializer.TextBackendEntryTest; import com.baidu.hugegraph.unit.util.CompressUtilTest; import com.baidu.hugegraph.unit.util.JsonUtilTest; -import com.baidu.hugegraph.unit.util.RateLimiterTest; import com.baidu.hugegraph.unit.util.StringEncodingTest; import com.baidu.hugegraph.unit.util.VersionTest; import com.baidu.hugegraph.unit.util.collection.CollectionFactoryTest; diff --git a/style/checkstyle.xml b/style/checkstyle.xml index acc4c40d95..7ba1a4a75e 100644 --- a/style/checkstyle.xml +++ b/style/checkstyle.xml @@ -36,6 +36,10 @@ + + + @@ -198,7 +202,6 @@ -