Skip to content

Commit 18ae76b

Browse files
liuxiaocs7imbajin
andauthored
fix: checkstyle && add suppressions.xml (#500)
continue for this pr: #385 --------- Co-authored-by: imbajin <jin@apache.org>
1 parent e19d951 commit 18ae76b

25 files changed

Lines changed: 139 additions & 111 deletions

File tree

hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/JaccardSimilarityAPI.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.apache.hugegraph.structure.constant.Direction;
2929
import org.apache.hugegraph.structure.traverser.SingleSourceJaccardSimilarityRequest;
3030

31-
3231
import org.apache.hugegraph.util.E;
3332

3433
public class JaccardSimilarityAPI extends TraversersAPI {

hugegraph-client/src/main/java/org/apache/hugegraph/exception/InvalidOperationException.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package org.apache.hugegraph.exception;
1919

20-
2120
import org.apache.hugegraph.rest.ClientException;
2221

2322
public class InvalidOperationException extends ClientException {

hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@
2020
import java.util.Map;
2121

2222
import org.apache.hugegraph.rest.RestResult;
23+
import org.slf4j.Logger;
24+
import org.slf4j.LoggerFactory;
2325

2426
import jakarta.ws.rs.core.Response;
2527

2628
public class ServerException extends RuntimeException {
2729

30+
private static final Logger LOG = LoggerFactory.getLogger(ServerException.class);
31+
2832
private static final long serialVersionUID = 6335623004322652358L;
2933

3034
private static final String[] EXCEPTION_KEYS = {"exception",
@@ -52,6 +56,7 @@ public static ServerException fromResponse(Response response) {
5256
exception.cause = (String) getByKeys(json, CAUSE_KEYS);
5357
exception.trace = getByKeys(json, TRACE_KEYS);
5458
} catch (Exception ignored) {
59+
LOG.error("ServerException fromResponse excepiton");
5560
}
5661

5762
return exception;

hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/HBaseSerializer.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ public class HBaseSerializer {
4040
private HugeClient client;
4141
private GraphSchema graphSchema;
4242

43-
44-
public HBaseSerializer(HugeClient client, int vertexPartitions, int edgePartitions){
43+
public HBaseSerializer(HugeClient client, int vertexPartitions, int edgePartitions) {
4544
this.client = client;
4645
this.graphSchema = new GraphSchema(client);
4746
this.edgeLogicPartitions = edgePartitions;
@@ -50,12 +49,12 @@ public HBaseSerializer(HugeClient client, int vertexPartitions, int edgePartitio
5049

5150
public byte[] getKeyBytes(GraphElement e) {
5251
byte[] array = null;
53-
if(e.type() == "vertex" && e.id() != null){
52+
if (e.type() == "vertex" && e.id() != null) {
5453
BytesBuffer buffer = BytesBuffer.allocate(2 + 1 + e.id().toString().length());
5554
buffer.writeShort(getPartition(HugeType.VERTEX, IdGenerator.of(e.id())));
5655
buffer.writeId(IdGenerator.of(e.id()));
5756
array = buffer.bytes();
58-
}else if ( e.type() == "edge" ){
57+
} else if (e.type() == "edge") {
5958
BytesBuffer buffer = BytesBuffer.allocate(BytesBuffer.BUF_EDGE_ID);
6059
Edge edge = (Edge)e;
6160
buffer.writeShort(getPartition(HugeType.EDGE, IdGenerator.of(edge.sourceId())));
@@ -71,22 +70,22 @@ public byte[] getKeyBytes(GraphElement e) {
7170

7271
public byte[] getValueBytes(GraphElement e) {
7372
byte[] array = null;
74-
if(e.type() == "vertex"){
75-
int propsCount = e.properties().size() ; //vertex.sizeOfProperties();
73+
if (e.type() == "vertex") {
74+
int propsCount = e.properties().size(); //vertex.sizeOfProperties();
7675
BytesBuffer buffer = BytesBuffer.allocate(8 + 16 * propsCount);
7776
buffer.writeId(IdGenerator.of(graphSchema.getVertexLabel(e.label()).id()));
7877
buffer.writeVInt(propsCount);
79-
for(Map.Entry<String, Object> entry : e.properties().entrySet()){
78+
for (Map.Entry<String, Object> entry : e.properties().entrySet()) {
8079
PropertyKey propertyKey = graphSchema.getPropertyKey(entry.getKey());
8180
buffer.writeVInt(propertyKey.id().intValue());
8281
buffer.writeProperty(propertyKey.dataType(),entry.getValue());
8382
}
8483
array = buffer.bytes();
85-
} else if ( e.type() == "edge" ){
84+
} else if (e.type() == "edge") {
8685
int propsCount = e.properties().size();
8786
BytesBuffer buffer = BytesBuffer.allocate(4 + 16 * propsCount);
8887
buffer.writeVInt(propsCount);
89-
for(Map.Entry<String, Object> entry : e.properties().entrySet()){
88+
for (Map.Entry<String, Object> entry : e.properties().entrySet()) {
9089
PropertyKey propertyKey = graphSchema.getPropertyKey(entry.getKey());
9190
buffer.writeVInt(propertyKey.id().intValue());
9291
buffer.writeProperty(propertyKey.dataType(),entry.getValue());
@@ -108,15 +107,15 @@ public short getPartition(HugeType type, Id id) {
108107
return partition > 0 ? partition : (short) -partition;
109108
}
110109

111-
public int getEdgeLogicPartitions(){
110+
public int getEdgeLogicPartitions() {
112111
return this.edgeLogicPartitions;
113112
}
114113

115-
public int getVertexLogicPartitions(){
114+
public int getVertexLogicPartitions() {
116115
return this.vertexLogicPartitions;
117116
}
118117

119-
public void close(){
118+
public void close() {
120119
this.client.close();
121120
}
122121
}

hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/reuse/BytesDemo.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class BytesDemo {
3939
static HugeClient client;
4040
boolean bypassServer = true;
4141
RocksDBSerializer ser;
42-
HBaseSerializer HBaseSer;
42+
HBaseSerializer hBaseSer;
4343

4444
public static void main(String[] args) {
4545
BytesDemo ins = new BytesDemo();
@@ -54,7 +54,6 @@ void initGraph() {
5454

5555
SchemaManager schema = client.schema();
5656

57-
5857
schema.propertyKey("name").asText().ifNotExist().create();
5958
schema.propertyKey("age").asInt().ifNotExist().create();
6059
schema.propertyKey("lang").asText().ifNotExist().create();
@@ -97,7 +96,7 @@ void initGraph() {
9796
.ifNotExist()
9897
.create();
9998

100-
HBaseSer = new HBaseSerializer(client, vertexLogicPartitions, edgeLogicPartitions);
99+
hBaseSer = new HBaseSerializer(client, vertexLogicPartitions, edgeLogicPartitions);
101100
writeGraphElements();
102101

103102
client.close();
@@ -130,7 +129,6 @@ private void writeGraphElements() {
130129
add(vadasB);
131130
}};
132131

133-
134132
List<Edge> edges = new ArrayList<Edge>() {{
135133
add(peterCreateLop);
136134
}};
@@ -148,14 +146,14 @@ private void writeGraphElements() {
148146
* */
149147
void writeDirectly(List<Vertex> vertices, List<Edge> edges) {
150148
for (Vertex vertex : vertices) {
151-
byte[] rowkey = HBaseSer.getKeyBytes(vertex);
152-
byte[] values = HBaseSer.getValueBytes(vertex);
149+
byte[] rowkey = hBaseSer.getKeyBytes(vertex);
150+
byte[] values = hBaseSer.getValueBytes(vertex);
153151
sendRpcToHBase("vertex", rowkey, values);
154152
}
155153

156154
for (Edge edge : edges) {
157-
byte[] rowkey = HBaseSer.getKeyBytes(edge);
158-
byte[] values = HBaseSer.getValueBytes(edge);
155+
byte[] rowkey = hBaseSer.getKeyBytes(edge);
156+
byte[] values = hBaseSer.getValueBytes(edge);
159157
sendRpcToHBase("edge", rowkey, values);
160158
}
161159
}
@@ -185,10 +183,8 @@ boolean sendRpcToHBase(String type, byte[] rowkey, byte[] values) {
185183
return flag;
186184
}
187185

188-
189186
boolean put(String type, byte[] rowkey, byte[] values) throws IOException {
190187
// TODO: put to HBase
191188
return true;
192189
}
193-
194190
}

hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/util/IdGenerator.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ public abstract class IdGenerator {
2828

2929
public static final Id ZERO = IdGenerator.of(0L);
3030

31-
public final static Id of(String id) {
31+
public static Id of(String id) {
3232
return new StringId(id);
3333
}
3434

35-
public final static Id of(UUID id) {
35+
public static Id of(UUID id) {
3636
return new UuidId(id);
3737
}
3838

39-
public final static Id of(String id, boolean uuid) {
39+
public static Id of(String id, boolean uuid) {
4040
return uuid ? new UuidId(id) : new StringId(id);
4141
}
4242

43-
public final static Id of(long id) {
43+
public static Id of(long id) {
4444
return new LongId(id);
4545
}
4646

@@ -57,7 +57,7 @@ public static Id of(Object id) {
5757
return new ObjectId(id);
5858
}
5959

60-
public final static Id of(byte[] bytes, Id.IdType type) {
60+
public static Id of(byte[] bytes, Id.IdType type) {
6161
switch (type) {
6262
case LONG:
6363
return new LongId(bytes);
@@ -70,7 +70,7 @@ public final static Id of(byte[] bytes, Id.IdType type) {
7070
}
7171
}
7272

73-
public final static Id ofStoredString(String id, Id.IdType type) {
73+
public static Id ofStoredString(String id, Id.IdType type) {
7474
switch (type) {
7575
case LONG:
7676
return of(LongEncoding.decodeSignedB64(id));
@@ -84,7 +84,7 @@ public final static Id ofStoredString(String id, Id.IdType type) {
8484
}
8585
}
8686

87-
public final static String asStoredString(Id id) {
87+
public static String asStoredString(Id id) {
8888
switch (id.type()) {
8989
case LONG:
9090
return LongEncoding.encodeSignedB64(id.asLong());
@@ -97,7 +97,7 @@ public final static String asStoredString(Id id) {
9797
}
9898
}
9999

100-
public final static Id.IdType idType(Id id) {
100+
public static Id.IdType idType(Id id) {
101101
if (id instanceof LongId) {
102102
return Id.IdType.LONG;
103103
}

hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/util/SplicingIdGenerator.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@ public static SplicingIdGenerator instance() {
5555
/**
5656
* Generate a string id of HugeVertex from Vertex name
5757
*/
58-
// public Id generate(HugeVertex vertex) {
59-
// /*
60-
// * Hash for row-key which will be evenly distributed.
61-
// * We can also use LongEncoding.encode() to encode the int/long hash
62-
// * if needed.
63-
// * id = String.format("%s%s%s", HashUtil.hash(id), ID_SPLITOR, id);
64-
// */
65-
// // TODO: use binary Id with binary fields instead of string id
66-
// return splicing(vertex.schemaLabel().id().asString(), vertex.name());
67-
// }
58+
// public Id generate(HugeVertex vertex) {
59+
// /*
60+
// * Hash for row-key which will be evenly distributed.
61+
// * We can also use LongEncoding.encode() to encode the int/long hash
62+
// * if needed.
63+
// * id = String.format("%s%s%s", HashUtil.hash(id), ID_SPLITOR, id);
64+
// */
65+
// // TODO: use binary Id with binary fields instead of string id
66+
// return splicing(vertex.schemaLabel().id().asString(), vertex.name());
67+
// }
6868

6969
/**
7070
* Concat multiple ids into one composite id with IDS_SPLITOR

hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/HubbleConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
import org.apache.hugegraph.exception.ExternalException;
2424
import org.apache.hugegraph.options.HubbleOptions;
25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
2527
import org.springframework.beans.factory.annotation.Autowired;
2628
import org.springframework.boot.ApplicationArguments;
2729
import org.springframework.context.annotation.Bean;
@@ -32,6 +34,8 @@
3234
@Configuration
3335
public class HubbleConfig {
3436

37+
private static final Logger LOG = LoggerFactory.getLogger(HubbleConfig.class);
38+
3539
@Autowired
3640
private ApplicationArguments arguments;
3741

@@ -56,6 +60,7 @@ public HugeConfig hugeConfig() {
5660
conf = path;
5761
}
5862
} catch (Exception ignored) {
63+
LOG.error("hugeConfig exception");
5964
}
6065
return new HugeConfig(conf);
6166
}

hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/controller/load/LoadTaskController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public LoadTask retry(@PathVariable("connId") int connId,
244244
return this.service.retry(taskId);
245245
} finally {
246246
jobEntity.setJobStatus(JobStatus.LOADING);
247-
jobEntity.setUpdateTime( HubbleUtil.nowDate());
247+
jobEntity.setUpdateTime(HubbleUtil.nowDate());
248248
this.jobService.update(jobEntity);
249249
}
250250
}

hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/license/ServerInfo.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
package org.apache.hugegraph.license;
2020

21-
import org.apache.hugegraph.license.MachineInfo;
22-
2321
public final class ServerInfo {
2422

2523
private final String serverId;

0 commit comments

Comments
 (0)