fix redundant Checkstyle (#1896)

* add redundant

* add redundant check

* merge line

* update alignment

* delete duplicates check MissingSwitchDefault

* update wrap line

* update code style

* merge dev

* merge master
This commit is contained in:
seagle 2022-10-30 16:16:21 +08:00 committed by GitHub
parent 3a22263621
commit cc80d27745
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
58 changed files with 367 additions and 391 deletions

View File

@ -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

View File

@ -21,7 +21,6 @@ package com.baidu.hugegraph.api.auth;
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;

View File

@ -47,7 +47,6 @@ public class CypherAPI extends GremlinQueryAPI {
private static final Logger LOG = Log.logger(CypherAPI.class);
@GET
@Timed
@CompressInterceptor.Compress(buffer = (1024 * 40))
@ -82,11 +81,11 @@ public class CypherAPI extends GremlinQueryAPI {
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);

View File

@ -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.Path;
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

View File

@ -86,8 +86,8 @@ public class JaccardSimilarityAPI extends TraverserAPI {
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));

View File

@ -43,36 +43,33 @@ import com.baidu.hugegraph.util.JsonUtil;
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<String, Object> config) {
default void setup(final Map<String, Object> config) {
E.checkState(config != null,
"Must provide a 'config' in the 'authentication'");
String path = (String) config.get("tokens");
@ -83,8 +80,9 @@ public interface HugeAuthenticator extends Authenticator {
}
@Override
public default User authenticate(final Map<String, String> credentials)
throws AuthenticationException {
default User authenticate(final Map<String, String> credentials)
throws AuthenticationException {
HugeGraphAuthProxy.resetContext();
User user = User.ANONYMOUS;
@ -115,11 +113,11 @@ public interface HugeAuthenticator extends Authenticator {
}
@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 interface HugeAuthenticator extends Authenticator {
}
}
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 interface HugeAuthenticator extends Authenticator {
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 interface HugeAuthenticator extends Authenticator {
}
}
public static class RolePerm {
class RolePerm {
@JsonProperty("roles") // graph -> action -> resource
private Map<String, Map<HugePermission, Object>> roles;
@ -395,7 +393,7 @@ public interface HugeAuthenticator extends Authenticator {
}
}
public static class RequiredPerm {
class RequiredPerm {
@JsonProperty("owner")
private String owner;

View File

@ -1790,17 +1790,17 @@ public final class HugeGraphAuthProxy implements HugeGraph {
private static final ThreadLocal<Context> 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);
@ -1811,7 +1811,7 @@ public final class HugeGraphAuthProxy implements HugeGraph {
return CONTEXTS.get();
}
protected static final String getContextString() {
protected static String getContextString() {
Context context = getContext();
if (context == null) {
return null;
@ -1819,7 +1819,7 @@ public final class HugeGraphAuthProxy implements HugeGraph {
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);
}

View File

@ -150,10 +150,10 @@ public class WsAndHttpBasicAuthHandler extends SaslAuthenticationHandler {
}
}
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);
}
}

View File

@ -21,9 +21,9 @@ package com.baidu.hugegraph.define;
public interface Checkable {
public void checkCreate(boolean isBatch);
void checkCreate(boolean isBatch);
public default void checkUpdate() {
default void checkUpdate() {
this.checkCreate(false);
}
}

View File

@ -42,65 +42,60 @@ import com.baidu.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser
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<PropertyKey> propertyKeys);
String writePropertyKeys(List<PropertyKey> propertyKeys);
public String writeVertexLabel(VertexLabel vertexLabel);
String writeVertexLabel(VertexLabel vertexLabel);
public String writeVertexLabels(List<VertexLabel> vertexLabels);
String writeVertexLabels(List<VertexLabel> vertexLabels);
public String writeEdgeLabel(EdgeLabel edgeLabel);
String writeEdgeLabel(EdgeLabel edgeLabel);
public String writeEdgeLabels(List<EdgeLabel> edgeLabels);
String writeEdgeLabels(List<EdgeLabel> edgeLabels);
public String writeIndexlabel(IndexLabel indexLabel);
String writeIndexlabel(IndexLabel indexLabel);
public String writeIndexlabels(List<IndexLabel> indexLabels);
String writeIndexlabels(List<IndexLabel> 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<Vertex> vertices, boolean paging);
String writeVertices(Iterator<Vertex> vertices, boolean paging);
public String writeEdge(Edge e);
String writeEdge(Edge e);
public String writeEdges(Iterator<Edge> edges, boolean paging);
String writeEdges(Iterator<Edge> edges, boolean paging);
public String writeIds(List<Id> ids);
String writeIds(List<Id> ids);
public String writeAuthElement(AuthElement elem);
String writeAuthElement(AuthElement elem);
public <V extends AuthElement> String writeAuthElements(String label,
List<V> users);
<V extends AuthElement> String writeAuthElements(String label, List<V> users);
public String writePaths(String name, Collection<HugeTraverser.Path> paths,
boolean withCrossPoint, Iterator<Vertex> vertices);
String writePaths(String name, Collection<HugeTraverser.Path> paths,
boolean withCrossPoint, Iterator<Vertex> vertices);
public default String writePaths(String name,
Collection<HugeTraverser.Path> paths,
boolean withCrossPoint) {
default String writePaths(String name, Collection<HugeTraverser.Path> paths,
boolean withCrossPoint) {
return this.writePaths(name, paths, withCrossPoint, null);
}
public String writeCrosspoints(CrosspointsPaths paths,
Iterator<Vertex> iterator, boolean withPath);
String writeCrosspoints(CrosspointsPaths paths, Iterator<Vertex> iterator,
boolean withPath);
public String writeSimilars(SimilarsMap similars,
Iterator<Vertex> vertices);
String writeSimilars(SimilarsMap similars, Iterator<Vertex> vertices);
public String writeWeightedPath(NodeWithWeight path,
Iterator<Vertex> vertices);
String writeWeightedPath(NodeWithWeight path, Iterator<Vertex> vertices);
public String writeWeightedPaths(WeightedPaths paths,
Iterator<Vertex> vertices);
String writeWeightedPaths(WeightedPaths paths, Iterator<Vertex> vertices);
public String writeNodesWithPath(String name, List<Id> nodes, long size,
Collection<HugeTraverser.Path> paths,
Iterator<Vertex> vertices);
String writeNodesWithPath(String name, List<Id> nodes, long size,
Collection<HugeTraverser.Path> paths,
Iterator<Vertex> vertices);
}

View File

@ -23,5 +23,5 @@ import java.util.Set;
public interface Analyzer {
public Set<String> segment(String text);
Set<String> segment(String text);
}

View File

@ -21,13 +21,13 @@ package com.baidu.hugegraph.backend;
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();
}

View File

@ -24,48 +24,48 @@ import java.util.function.Function;
public interface Cache<K, V> {
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<K, V> fetcher);
V getOrFetch(K id, Function<K, V> 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<V> consumer);
void traverse(Consumer<V> 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> T attachment(T object);
<T> T attachment(T object);
public <T> T attachment();
<T> T attachment();
}

View File

@ -24,15 +24,15 @@ import com.baidu.hugegraph.type.HugeType;
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 {}
}

View File

@ -235,7 +235,7 @@ public final class CachedGraphTransaction extends GraphTransaction {
@Override
@Watched(prefix = "graphcache")
protected final Iterator<HugeVertex> queryVerticesFromBackend(Query query) {
protected Iterator<HugeVertex> queryVerticesFromBackend(Query query) {
if (this.enableCacheVertex() &&
query.idsSize() > 0 && query.conditionsSize() == 0) {
return this.queryVerticesByIds((IdQuery) query);
@ -307,7 +307,7 @@ public final class CachedGraphTransaction extends GraphTransaction {
@Override
@Watched(prefix = "graphcache")
protected final Iterator<HugeEdge> queryEdgesFromBackend(Query query) {
protected Iterator<HugeEdge> queryEdgesFromBackend(Query query) {
RamTable ramtable = this.params().ramtable();
if (ramtable != null && ramtable.matched(query)) {
return ramtable.query(query);
@ -362,7 +362,7 @@ public final class CachedGraphTransaction extends GraphTransaction {
@Override
@Watched(prefix = "graphcache")
protected final void commitMutation2Backend(BackendMutation... mutations) {
protected void commitMutation2Backend(BackendMutation... mutations) {
// Collect changes before commit
Collection<HugeVertex> updates = this.verticesInTxUpdated();
Collection<HugeVertex> deletions = this.verticesInTxRemoved();
@ -414,7 +414,7 @@ public final class CachedGraphTransaction extends GraphTransaction {
}
@Override
public final void removeIndex(IndexLabel indexLabel) {
public void removeIndex(IndexLabel indexLabel) {
try {
super.removeIndex(indexLabel);
} finally {

View File

@ -137,22 +137,22 @@ public final class CachedSchemaTransaction extends SchemaTransaction {
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 @@ public final class CachedSchemaTransaction extends SchemaTransaction {
}
}
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 @@ public final class CachedSchemaTransaction extends SchemaTransaction {
}
}
private final void updateCache(SchemaElement schema) {
private void updateCache(SchemaElement schema) {
this.resetCachedAllIfReachedCapacity();
// update id cache
@ -189,7 +189,7 @@ public final class CachedSchemaTransaction extends SchemaTransaction {
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);

View File

@ -346,7 +346,7 @@ public class OffheapCache extends AbstractCache<Id, Object> {
}
}
private static enum ValueType {
private enum ValueType {
UNKNOWN,
LIST,
@ -365,11 +365,11 @@ public class OffheapCache extends AbstractCache<Id, Object> {
private DataType dataType;
private ValueType() {
ValueType() {
this(DataType.UNKNOWN);
}
private ValueType(DataType dataType) {
ValueType(DataType dataType) {
this.dataType = dataType;
}

View File

@ -23,37 +23,37 @@ import com.baidu.hugegraph.util.E;
public interface Id extends Comparable<Id> {
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,

View File

@ -121,7 +121,7 @@ public abstract class IdGenerator {
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();
}

View File

@ -130,7 +130,7 @@ public final class QueryList<R> {
* For non-paging situation
* @return BackendEntry iterator
*/
public QueryResults<R> iterator();
QueryResults<R> iterator();
/**
* For paging situation
@ -139,9 +139,9 @@ public final class QueryList<R> {
* @param pageSize set query page size
* @return BackendEntry iterator with page
*/
public PageResults<R> iterator(int index, String page, long pageSize);
PageResults<R> iterator(int index, String page, long pageSize);
public int total();
int total();
}
/**

View File

@ -60,7 +60,7 @@ public class Aggregate {
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 class Aggregate {
private final Number defaultValue;
private final BiFunction<Number, Number, Number> merger;
private AggregateFunc(String name, Number defaultValue,
BiFunction<Number, Number, Number> merger) {
AggregateFunc(String name, Number defaultValue,
BiFunction<Number, Number, Number> merger) {
this.name = name;
this.defaultValue = defaultValue;
this.merger = merger;

View File

@ -875,8 +875,8 @@ public class ConditionQuery extends IdQuery {
}
}
public static interface ResultsFilter {
public interface ResultsFilter {
public boolean test(HugeElement element);
boolean test(HugeElement element);
}
}

View File

@ -577,7 +577,7 @@ public class Query implements Cloneable {
}
}
public static enum Order {
public enum Order {
ASC,
DESC;
}

View File

@ -26,7 +26,6 @@ import java.util.concurrent.Future;
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;

View File

@ -21,57 +21,57 @@ package com.baidu.hugegraph.backend.store;
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();
}

View File

@ -23,27 +23,27 @@ import java.util.Map;
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<String, Object> metrics();
Map<String, Object> metrics();
}

View File

@ -23,17 +23,17 @@ import java.util.List;
public interface RaftGroupManager {
public String group();
String group();
public List<String> listPeers();
List<String> 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);
}

View File

@ -25,11 +25,11 @@ import java.io.IOException;
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;
}

View File

@ -21,7 +21,7 @@ package com.baidu.hugegraph.job;
public interface Job<V> {
public String type();
String type();
public V execute() throws Exception;
V execute() throws Exception;
}

View File

@ -25,11 +25,11 @@ import com.baidu.hugegraph.job.Job;
public interface Computer {
public String name();
String name();
public String category();
String category();
public Object call(Job<Object> job, Map<String, Object> parameters);
Object call(Job<Object> job, Map<String, Object> parameters);
public void checkParameters(Map<String, Object> parameters);
void checkParameters(Map<String, Object> parameters);
}

View File

@ -26,27 +26,27 @@ import com.baidu.hugegraph.config.OptionSpace;
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);
}
}

View File

@ -21,17 +21,17 @@ package com.baidu.hugegraph.rpc;
public interface RpcServiceConfig4Client {
public <T> T serviceProxy(String interfaceId);
<T> T serviceProxy(String interfaceId);
public <T> T serviceProxy(String graph, String interfaceId);
<T> T serviceProxy(String graph, String interfaceId);
public default <T> T serviceProxy(Class<T> clazz) {
default <T> T serviceProxy(Class<T> clazz) {
return this.serviceProxy(clazz.getName());
}
public default <T> T serviceProxy(String graph, Class<T> clazz) {
default <T> T serviceProxy(String graph, Class<T> clazz) {
return this.serviceProxy(graph, clazz.getName());
}
public void removeAllServiceProxy();
void removeAllServiceProxy();
}

View File

@ -21,12 +21,12 @@ package com.baidu.hugegraph.rpc;
public interface RpcServiceConfig4Server {
public <T, S extends T> String addService(Class<T> clazz, S serviceImpl);
<T, S extends T> String addService(Class<T> clazz, S serviceImpl);
public <T, S extends T> String addService(String graph,
Class<T> clazz, S serviceImpl);
<T, S extends T> String addService(String graph, Class<T> clazz,
S serviceImpl);
public void removeService(String serviceId);
void removeService(String serviceId);
public void removeAllService();
void removeAllService();
}

View File

@ -24,19 +24,19 @@ import com.baidu.hugegraph.schema.SchemaElement;
public interface SchemaBuilder<T extends SchemaElement> {
public SchemaBuilder<T> id(long id);
SchemaBuilder<T> 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<T> ifNotExist();
SchemaBuilder<T> ifNotExist();
public SchemaBuilder<T> checkExist(boolean checkExist);
SchemaBuilder<T> checkExist(boolean checkExist);
}

View File

@ -324,15 +324,15 @@ public final class TaskManager {
private static final ThreadLocal<String> 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();
}

View File

@ -26,16 +26,16 @@ import com.baidu.hugegraph.traversal.algorithm.HugeTraverser.PathSet;
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<Id, Boolean> filter,
boolean all, boolean ring);
PathSet findPath(Id target, Function<Id, Boolean> filter, boolean all,
boolean ring);
public long accessed();
long accessed();
}

View File

@ -23,15 +23,15 @@ import com.baidu.hugegraph.util.collection.IntIterator;
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();
}

View File

@ -31,22 +31,20 @@ import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
public interface TraverseStrategy {
public abstract void traverseOneLayer(
Map<Id, List<HugeTraverser.Node>> vertices,
EdgeStep step, BiConsumer<Id, EdgeStep> consumer);
void traverseOneLayer(Map<Id, List<HugeTraverser.Node>> vertices,
EdgeStep step, BiConsumer<Id, EdgeStep> consumer);
public abstract Map<Id, List<HugeTraverser.Node>> newMultiValueMap();
Map<Id, List<HugeTraverser.Node>> newMultiValueMap();
public abstract Set<HugeTraverser.Path> newPathSet();
Set<HugeTraverser.Path> newPathSet();
public abstract void addNode(Map<Id, List<HugeTraverser.Node>> vertices,
Id id, HugeTraverser.Node node);
void addNode(Map<Id, List<HugeTraverser.Node>> vertices, Id id,
HugeTraverser.Node node);
public abstract void addNewVerticesToAll(
Map<Id, List<HugeTraverser.Node>> newVertices,
Map<Id, List<HugeTraverser.Node>> targets);
void addNewVerticesToAll(Map<Id, List<HugeTraverser.Node>> newVertices,
Map<Id, List<HugeTraverser.Node>> targets);
public static TraverseStrategy create(boolean concurrent, HugeGraph graph) {
static TraverseStrategy create(boolean concurrent, HugeGraph graph) {
return concurrent ? new ConcurrentTraverseStrategy(graph) :
new SingleTraverseStrategy(graph);
}

View File

@ -30,12 +30,12 @@ import com.baidu.hugegraph.iterator.Metadatable;
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 interface QueryHolder extends HasContainerHolder, Metadatable {
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 extends Query> Q injectQueryInfo(Q query) {
default <Q extends Query> Q injectQueryInfo(Q query) {
query.copyBasic(this.queryInfo());
return query;
}

View File

@ -23,5 +23,5 @@ import com.baidu.hugegraph.backend.id.Id;
public interface Idfiable {
public Id id();
Id id();
}

View File

@ -25,5 +25,5 @@ import com.baidu.hugegraph.backend.id.Id;
public interface Indexable {
public Set<Id> indexLabels();
Set<Id> indexLabels();
}

View File

@ -25,6 +25,6 @@ public interface Nameable {
*
* @return Name of this entity.
*/
public String name();
String name();
}

View File

@ -25,5 +25,5 @@ import com.baidu.hugegraph.backend.id.Id;
public interface Propertiable {
public Set<Id> properties();
Set<Id> properties();
}

View File

@ -22,5 +22,5 @@ package com.baidu.hugegraph.type;
public interface Typeable {
// Return schema/data type
public HugeType type();
HugeType type();
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -24,15 +24,13 @@ import org.slf4j.Logger;
// 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);
}
}

View File

@ -26,14 +26,14 @@ import java.util.NoSuchElementException;
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<Integer> asIterator() {
default Iterator<Integer> asIterator() {
return new Iterator<Integer>() {
@Override
@ -48,20 +48,20 @@ public interface IntIterator {
};
}
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 interface IntIterator {
}
}
public final class ArrayIntIterator implements IntIterator {
final class ArrayIntIterator implements IntIterator {
private final int[] array;
private int index;
@ -102,7 +102,7 @@ public interface IntIterator {
}
}
public final class EmptyIntIterator implements IntIterator {
final class EmptyIntIterator implements IntIterator {
@Override
public boolean hasNext() {
@ -115,7 +115,7 @@ public interface IntIterator {
}
}
public final class IntIterators implements IntIterator {
final class IntIterators implements IntIterator {
private final List<IntIterator> iters;
private int currentIndex;
@ -158,7 +158,7 @@ public interface IntIterator {
}
}
public final class MapperInt2IntIterator implements IntIterator {
final class MapperInt2IntIterator implements IntIterator {
private final IntIterator originIter;
private final IntMapper intMapper;
@ -180,11 +180,11 @@ public interface IntIterator {
public interface IntMapper {
public int map(int key);
int map(int key);
}
}
public final class MapperInt2ObjectIterator<T> implements Iterator<T> {
final class MapperInt2ObjectIterator<T> implements Iterator<T> {
private final IntIterator originIter;
private final IntMapper<T> intMapper;
@ -207,7 +207,7 @@ public interface IntIterator {
public interface IntMapper<T> {
public T map(int key);
T map(int key);
}
}
}

View File

@ -199,7 +199,7 @@ public interface IntMap {
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 @@ public interface IntMap {
}
}
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 @@ public interface IntMap {
* - 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 interface IntMap {
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 interface IntMap {
}
}
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 interface IntMap {
}
}
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 interface IntMap {
}
}
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;
}

View File

@ -151,7 +151,7 @@ public interface IntSet {
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 @@ public interface IntSet {
}
}
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 @@ public interface IntSet {
* - 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 interface IntSet {
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 @@ public interface IntSet {
}
}
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 interface IntSet {
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 @@ public interface IntSet {
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 @@ public interface IntSet {
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 interface IntSet {
}
}
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 interface IntSet {
}
}
public static final class IntSetByFixedAddrByHppc implements IntSet {
final class IntSetByFixedAddrByHppc implements IntSet {
private final com.carrotsearch.hppc.BitSet bits;
@ -551,13 +551,13 @@ public interface IntSet {
}
}
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 interface IntSet {
return (int) eachSize;
}
public static int sizeToPowerOf2Size(int size) {
static int sizeToPowerOf2Size(int size) {
if (size < 1) {
size = 1;
}
@ -587,7 +587,7 @@ public interface IntSet {
return size;
}
public static int bits2words(long numBits) {
static int bits2words(long numBits) {
return (int) ((numBits - 1) >>> DIV64) + 1;
}
}

View File

@ -21,9 +21,9 @@ package com.baidu.hugegraph.util.collection;
public interface ObjectIntMapping<V> {
public int object2Code(Object object);
int object2Code(Object object);
public V code2Object(int code);
V code2Object(int code);
public void clear();
void clear();
}

View File

@ -231,7 +231,7 @@ public class HbaseSessions extends BackendSessionPool {
}
}
public void createPreSplitTable(String table, List<byte[]> cfs,
public void createPreSplitTable(String table, List<byte[]> cfs,
short numOfPartitions) throws IOException {
TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(
TableName.valueOf(this.namespace, table));
@ -331,20 +331,20 @@ public class HbaseSessions extends BackendSessionPool {
/**
* Add a row record to a table
*/
public abstract void put(String table, byte[] family, byte[] rowkey,
Collection<BackendColumn> columns);
void put(String table, byte[] family, byte[] rowkey,
Collection<BackendColumn> 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 class HbaseSessions extends BackendSessionPool {
* 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<byte[]> rowkeys);
R get(String table, byte[] family, Set<byte[]> 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 class HbaseSessions extends BackendSessionPool {
/**
* 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<byte[]> prefixes) {
default R scan(String table, Set<byte[]> 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 class HbaseSessions extends BackendSessionPool {
/**
* 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 class HbaseSessions extends BackendSessionPool {
/**
* 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 class HbaseSessions extends BackendSessionPool {
/**
* 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<RowIterator> {
implements HbaseSession<RowIterator> {
private final Map<String, List<Row>> batch;
@ -485,7 +483,7 @@ public class HbaseSessions extends BackendSessionPool {
}
private void checkBatchResults(Object[] results, List<Row> 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 class HbaseSessions extends BackendSessionPool {
} 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 @@ public class HbaseSessions extends BackendSessionPool {
byte[] key = CellUtil.cloneQualifier(cell);
byte[] val = CellUtil.cloneValue(cell);
LOG.info(" {}={}", StringEncoding.format(key),
StringEncoding.format(val));
StringEncoding.format(val));
}
}
}

View File

@ -440,7 +440,7 @@ public abstract class HbaseStore extends AbstractBackendStore<Session> {
session.rollback();
}
private final void checkConnectionOpened() {
private void checkConnectionOpened() {
E.checkState(this.sessions != null && this.sessions.opened(),
"HBase store has not been initialized");
}

View File

@ -133,6 +133,6 @@ public abstract class RocksDBSessions extends BackendSessionPool {
public interface Countable {
public long count();
long count();
}
}

View File

@ -797,13 +797,13 @@ public abstract class RocksDBStore extends AbstractBackendStore<Session> {
}
}
private final void useSessions() {
private void useSessions() {
for (RocksDBSessions sessions : this.sessions()) {
sessions.useSession();
}
}
private final void closeSessions() {
private void closeSessions() {
Iterator<Map.Entry<String, RocksDBSessions>> iter = this.dbs.entrySet()
.iterator();
while (iter.hasNext()) {
@ -816,7 +816,7 @@ public abstract class RocksDBStore extends AbstractBackendStore<Session> {
}
}
private final List<Session> session() {
private List<Session> session() {
this.checkOpened();
if (this.tableDiskMapping.isEmpty()) {
@ -832,12 +832,13 @@ public abstract class RocksDBStore extends AbstractBackendStore<Session> {
return list;
}
private final Collection<RocksDBSessions> sessions() {
private Collection<RocksDBSessions> sessions() {
return this.dbs.values();
}
private final void parseTableDiskMapping(Map<String, String> disks,
String dataPath) {
private void parseTableDiskMapping(Map<String, String> disks,
String dataPath) {
this.tableDiskMapping.clear();
for (Map.Entry<String, String> disk : disks.entrySet()) {
// The format of `disk` like: `graph/vertex: /path/to/disk1`
@ -884,7 +885,7 @@ public abstract class RocksDBStore extends AbstractBackendStore<Session> {
return diskTableKey;
}
private final void checkDbOpened() {
private void checkDbOpened() {
E.checkState(this.sessions != null && !this.sessions.closed(),
"RocksDB has not been opened");
}

View File

@ -66,7 +66,6 @@ import com.baidu.hugegraph.unit.serializer.TableBackendEntryTest;
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;

View File

@ -52,6 +52,10 @@
<!-- </module>-->
<module name="AvoidStarImport"/>
<module name="RedundantImport"/>
<module name="RedundantModifier">
<property name="tokens"
value="METHOD_DEF,VARIABLE_DEF,ANNOTATION_FIELD_DEF,INTERFACE_DEF,CLASS_DEF,ENUM_DEF,RESOURCE"/>
</module>
<module name="UnusedImports"/>
<module name="EmptyLineSeparator">
<property name="allowMultipleEmptyLines" value="false"/>
@ -214,7 +218,6 @@
</module>
<module name="OneStatementPerLine"/>
<module name="MultipleVariableDeclarations"/>
<module name="MissingSwitchDefault"/>
<module name="FallThrough"/>
<module name="OuterTypeFilename">
<!-- <property name="severity" value="error"/>-->