Skip to content

Commit 6c07251

Browse files
authored
refactor(core): StringEncoding (#300)
* refactor(core): StringEncoding * chore(notice): remove JanusGraph * chore(notice): remove all notice about JanusGraph
1 parent 0500fec commit 6c07251

File tree

15 files changed

+78
-283
lines changed

15 files changed

+78
-283
lines changed

.licenserc.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ header: # `header` section is configurations for source codes license header.
7272
- 'assembly/**'
7373
- '.github/**/*'
7474
- '**/target/*'
75-
- '**/util/StringEncoding.java'
7675
- '**/go.mod'
7776
- '**/go.sum'
7877
comment: on-failure # on what condition license-eye will comment on the pull request, `on-failure`, `always`, `never`.

LICENSE

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,3 @@
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201201
limitations under the License.
202-
203-
========================================================================
204-
Apache 2.0 licenses
205-
========================================================================
206-
207-
The following components are provided under the Apache License. See project link for details.
208-
The text of each license is the standard Apache 2.0 license.
209-
210-
computer-core/src/main/java/org/apache/hugegraph/computer/core/util/StringEncoding.java files from https://github.com/JanusGraph

NOTICE

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -5,56 +5,3 @@ This product includes software developed at
55
The Apache Software Foundation (http://www.apache.org/).
66

77
The initial codebase was donated to the ASF by HugeGraph Authors, copyright 2017-2021.
8-
9-
-----------------------------------------------------------------------
10-
This product contains code form the JanusGraph Project:
11-
-----------------------------------------------------------------------
12-
==============================================================
13-
JanusGraph: Distributed Graph Database
14-
Copyright 2012 and onwards JanusGraph Authors
15-
==============================================================
16-
17-
This product includes software developed by JanusGraph contributors listed
18-
in CONTRIBUTORS.txt; JanusGraph copyright holders are listed in AUTHORS.txt.
19-
20-
This product is based on Titan, originally developed by Aurelius (acquired by
21-
DataStax) and the following individuals:
22-
23-
* Matthias Broecheler
24-
* Dan LaRocque
25-
* Marko A. Rodriguez
26-
* Stephen Mallette
27-
* Pavel Yaskevich
28-
29-
It also includes software from other open source projects including, but not limited to (check pom.xml for complete listing):
30-
31-
* Apache Cassandra [https://cassandra.apache.org/]
32-
* Apache Commons [https://commons.apache.org/]
33-
* Apache Groovy [http://groovy-lang.org/]
34-
* Apache HBase [https://hbase.apache.org/]
35-
* Apache Hadoop [https://hadoop.apache.org/]
36-
* Apache Kerby [https://github.com/apache/directory-kerby]
37-
* Apache Log4j [https://logging.apache.org/log4j]
38-
* Apache Lucene [https://lucene.apache.org/]
39-
* Apache Solr [https://lucene.apache.org/solr/]
40-
* Apache TinkerPop [https://tinkerpop.apache.org/]
41-
* Astyanax [https://github.com/Netflix/astyanax]
42-
* DataStax Driver for Apache Cassandra [https://github.com/datastax/java-driver]
43-
* EasyMock [http://easymock.org/]
44-
* Elasticsearch [https://www.elastic.co/]
45-
* Google Cloud Bigtable [https://github.com/googlecloudplatform/cloud-bigtable-client]
46-
* Google Guava [https://github.com/google/guava]
47-
* HPPC [https://labs.carrotsearch.com/hppc.html]
48-
* JUnit [https://www.junit.org/]
49-
* Jackson [https://github.com/FasterXML/jackson]
50-
* Kryo [https://github.com/EsotericSoftware/kryo]
51-
* Metrics [https://metrics.dropwizard.io]
52-
* Mockito [https://site.mockito.org/]
53-
* Noggit [https://github.com/yonik/noggit]
54-
* OpenRDF [http://rdf4j.org/]
55-
* Oracle BerkeleyDB Java Edition [https://www.oracle.com/technetwork/products/berkeleydb/] (see license below)
56-
* Project Lombok [https://projectlombok.org/]
57-
* Reflections8 [https://github.com/aschoerk/reflections8]
58-
* SLF4J [https://www.slf4j.org/]
59-
* Spatial4j [https://github.com/locationtech/spatial4j]
60-
* Vavr [https://www.vavr.io/]

computer-core/src/main/java/org/apache/hugegraph/computer/core/io/StructRandomAccessOutput.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import java.io.IOException;
2121

2222
import org.apache.commons.lang3.StringEscapeUtils;
23-
import org.apache.hugegraph.computer.core.util.StringEncoding;
23+
import org.apache.hugegraph.computer.core.util.StringEncodeUtil;
2424
import org.apache.hugegraph.testutil.Whitebox;
2525

2626
@SuppressWarnings("deprecation") // StringEscapeUtils
@@ -67,14 +67,14 @@ public void write(int b) throws IOException {
6767

6868
@Override
6969
public void write(byte[] b) throws IOException {
70-
this.writeString(StringEncoding.encodeBase64(b));
70+
this.writeString(StringEncodeUtil.encodeBase64(b));
7171
}
7272

7373
@Override
7474
public void write(byte[] b, int off, int len) throws IOException {
7575
byte[] dest = new byte[len];
7676
System.arraycopy(b, off, dest, 0, len);
77-
this.writeString(StringEncoding.encodeBase64(dest));
77+
this.writeString(StringEncodeUtil.encodeBase64(dest));
7878
}
7979

8080
@Override

computer-core/src/main/java/org/apache/hugegraph/computer/core/network/TransportUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import java.util.List;
2828

2929
import org.apache.hugegraph.computer.core.common.exception.ComputerException;
30-
import org.apache.hugegraph.computer.core.util.StringEncoding;
30+
import org.apache.hugegraph.computer.core.util.StringEncodeUtil;
3131
import org.apache.hugegraph.util.E;
3232
import org.apache.hugegraph.util.Log;
3333
import org.slf4j.Logger;
@@ -146,12 +146,12 @@ public static String readString(ByteBuf buf) {
146146
}
147147
byte[] bytes = new byte[length];
148148
buf.readBytes(bytes);
149-
return StringEncoding.decode(bytes);
149+
return StringEncodeUtil.decode(bytes);
150150
}
151151

152152
public static void writeString(ByteBuf buf, String value) {
153153
E.checkArgumentNotNull(value, "value");
154-
byte[] encoded = StringEncoding.encode(value);
154+
byte[] encoded = StringEncodeUtil.encode(value);
155155
buf.writeInt(encoded.length);
156156
buf.writeBytes(encoded);
157157
}

computer-core/src/main/java/org/apache/hugegraph/computer/core/output/hdfs/HdfsOutput.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import org.apache.hugegraph.computer.core.config.Config;
3232
import org.apache.hugegraph.computer.core.graph.vertex.Vertex;
3333
import org.apache.hugegraph.computer.core.output.AbstractComputerOutput;
34-
import org.apache.hugegraph.computer.core.util.StringEncoding;
34+
import org.apache.hugegraph.computer.core.util.StringEncodeUtil;
3535
import org.apache.hugegraph.util.Log;
3636
import org.slf4j.Logger;
3737

@@ -93,7 +93,7 @@ protected void writeBytes(byte[] bytes) throws IOException {
9393
}
9494

9595
protected void writeString(String string) throws IOException {
96-
this.writeBytes(StringEncoding.encode(string));
96+
this.writeBytes(StringEncodeUtil.encode(string));
9797
}
9898

9999
protected String constructValueString(Vertex vertex) {
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with this
4+
* work for additional information regarding copyright ownership. The ASF
5+
* licenses this file to You under the Apache License, Version 2.0 (the
6+
* "License"); you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations
15+
* under the License.
16+
*/
17+
18+
package org.apache.hugegraph.computer.core.util;
19+
20+
import java.nio.charset.StandardCharsets;
21+
import java.util.Base64;
22+
23+
public final class StringEncodeUtil {
24+
25+
private static final byte[] BYTES_EMPTY = new byte[0];
26+
27+
private static final Base64.Encoder BASE64_ENCODER = Base64.getEncoder();
28+
private static final Base64.Decoder BASE64_DECODER = Base64.getDecoder();
29+
30+
public static byte[] encode(String value) {
31+
return value.getBytes(StandardCharsets.UTF_8);
32+
}
33+
34+
public static String decode(byte[] bytes) {
35+
return new String(bytes, StandardCharsets.UTF_8);
36+
}
37+
38+
public static String decode(byte[] bytes, int offset, int length) {
39+
return new String(bytes, offset, length, StandardCharsets.UTF_8);
40+
}
41+
42+
public static String encodeBase64(byte[] bytes) {
43+
return BASE64_ENCODER.encodeToString(bytes);
44+
}
45+
46+
public static byte[] decodeBase64(String value) {
47+
if (value.isEmpty()) {
48+
return BYTES_EMPTY;
49+
}
50+
return BASE64_DECODER.decode(value);
51+
}
52+
}

computer-core/src/main/java/org/apache/hugegraph/computer/core/util/StringEncoding.java

Lines changed: 0 additions & 141 deletions
This file was deleted.

computer-dist/release-docs/LICENSE

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,6 @@ The following components are provided under the Apache 2.0 License.
400400
(Apache License, Version 2.0) * okio(com.squareup.okio:okio-jvm:3.0.0-https://github.com/square/okio/ )
401401
(Apache License, Version 2.0) * Simple XML (safe)(com.carrotsearch.thirdparty:simple-xml-safe:2.7.1-https://github.com/dweiss/simplexml )
402402

403-
computer-core/src/main/java/org/apache/hugegraph/computer/core/util/StringEncoding.java files from https://github.com/JanusGraph
404-
405403
========================================================================
406404
Third party BSD licenses
407405
========================================================================

0 commit comments

Comments
 (0)