Skip to content

Commit

Permalink
refactor(core): StringEncoding (#300)
Browse files Browse the repository at this point in the history
* refactor(core): StringEncoding

* chore(notice): remove JanusGraph

* chore(notice): remove all notice about JanusGraph
  • Loading branch information
diaohancai authored Dec 29, 2023
1 parent 0500fec commit 6c07251
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 283 deletions.
1 change: 0 additions & 1 deletion .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ header: # `header` section is configurations for source codes license header.
- 'assembly/**'
- '.github/**/*'
- '**/target/*'
- '**/util/StringEncoding.java'
- '**/go.mod'
- '**/go.sum'
comment: on-failure # on what condition license-eye will comment on the pull request, `on-failure`, `always`, `never`.
Expand Down
9 changes: 0 additions & 9 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,3 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

========================================================================
Apache 2.0 licenses
========================================================================

The following components are provided under the Apache License. See project link for details.
The text of each license is the standard Apache 2.0 license.

computer-core/src/main/java/org/apache/hugegraph/computer/core/util/StringEncoding.java files from https://github.com/JanusGraph
53 changes: 0 additions & 53 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,3 @@ This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).

The initial codebase was donated to the ASF by HugeGraph Authors, copyright 2017-2021.

-----------------------------------------------------------------------
This product contains code form the JanusGraph Project:
-----------------------------------------------------------------------
==============================================================
JanusGraph: Distributed Graph Database
Copyright 2012 and onwards JanusGraph Authors
==============================================================

This product includes software developed by JanusGraph contributors listed
in CONTRIBUTORS.txt; JanusGraph copyright holders are listed in AUTHORS.txt.

This product is based on Titan, originally developed by Aurelius (acquired by
DataStax) and the following individuals:

* Matthias Broecheler
* Dan LaRocque
* Marko A. Rodriguez
* Stephen Mallette
* Pavel Yaskevich

It also includes software from other open source projects including, but not limited to (check pom.xml for complete listing):

* Apache Cassandra [https://cassandra.apache.org/]
* Apache Commons [https://commons.apache.org/]
* Apache Groovy [http://groovy-lang.org/]
* Apache HBase [https://hbase.apache.org/]
* Apache Hadoop [https://hadoop.apache.org/]
* Apache Kerby [https://github.com/apache/directory-kerby]
* Apache Log4j [https://logging.apache.org/log4j]
* Apache Lucene [https://lucene.apache.org/]
* Apache Solr [https://lucene.apache.org/solr/]
* Apache TinkerPop [https://tinkerpop.apache.org/]
* Astyanax [https://github.com/Netflix/astyanax]
* DataStax Driver for Apache Cassandra [https://github.com/datastax/java-driver]
* EasyMock [http://easymock.org/]
* Elasticsearch [https://www.elastic.co/]
* Google Cloud Bigtable [https://github.com/googlecloudplatform/cloud-bigtable-client]
* Google Guava [https://github.com/google/guava]
* HPPC [https://labs.carrotsearch.com/hppc.html]
* JUnit [https://www.junit.org/]
* Jackson [https://github.com/FasterXML/jackson]
* Kryo [https://github.com/EsotericSoftware/kryo]
* Metrics [https://metrics.dropwizard.io]
* Mockito [https://site.mockito.org/]
* Noggit [https://github.com/yonik/noggit]
* OpenRDF [http://rdf4j.org/]
* Oracle BerkeleyDB Java Edition [https://www.oracle.com/technetwork/products/berkeleydb/] (see license below)
* Project Lombok [https://projectlombok.org/]
* Reflections8 [https://github.com/aschoerk/reflections8]
* SLF4J [https://www.slf4j.org/]
* Spatial4j [https://github.com/locationtech/spatial4j]
* Vavr [https://www.vavr.io/]
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.io.IOException;

import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.hugegraph.computer.core.util.StringEncoding;
import org.apache.hugegraph.computer.core.util.StringEncodeUtil;
import org.apache.hugegraph.testutil.Whitebox;

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

@Override
public void write(byte[] b) throws IOException {
this.writeString(StringEncoding.encodeBase64(b));
this.writeString(StringEncodeUtil.encodeBase64(b));
}

@Override
public void write(byte[] b, int off, int len) throws IOException {
byte[] dest = new byte[len];
System.arraycopy(b, off, dest, 0, len);
this.writeString(StringEncoding.encodeBase64(dest));
this.writeString(StringEncodeUtil.encodeBase64(dest));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.List;

import org.apache.hugegraph.computer.core.common.exception.ComputerException;
import org.apache.hugegraph.computer.core.util.StringEncoding;
import org.apache.hugegraph.computer.core.util.StringEncodeUtil;
import org.apache.hugegraph.util.E;
import org.apache.hugegraph.util.Log;
import org.slf4j.Logger;
Expand Down Expand Up @@ -146,12 +146,12 @@ public static String readString(ByteBuf buf) {
}
byte[] bytes = new byte[length];
buf.readBytes(bytes);
return StringEncoding.decode(bytes);
return StringEncodeUtil.decode(bytes);
}

public static void writeString(ByteBuf buf, String value) {
E.checkArgumentNotNull(value, "value");
byte[] encoded = StringEncoding.encode(value);
byte[] encoded = StringEncodeUtil.encode(value);
buf.writeInt(encoded.length);
buf.writeBytes(encoded);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.apache.hugegraph.computer.core.config.Config;
import org.apache.hugegraph.computer.core.graph.vertex.Vertex;
import org.apache.hugegraph.computer.core.output.AbstractComputerOutput;
import org.apache.hugegraph.computer.core.util.StringEncoding;
import org.apache.hugegraph.computer.core.util.StringEncodeUtil;
import org.apache.hugegraph.util.Log;
import org.slf4j.Logger;

Expand Down Expand Up @@ -93,7 +93,7 @@ protected void writeBytes(byte[] bytes) throws IOException {
}

protected void writeString(String string) throws IOException {
this.writeBytes(StringEncoding.encode(string));
this.writeBytes(StringEncodeUtil.encode(string));
}

protected String constructValueString(Vertex vertex) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with this
* work for additional information regarding copyright ownership. The ASF
* licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

package org.apache.hugegraph.computer.core.util;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

public final class StringEncodeUtil {

private static final byte[] BYTES_EMPTY = new byte[0];

private static final Base64.Encoder BASE64_ENCODER = Base64.getEncoder();
private static final Base64.Decoder BASE64_DECODER = Base64.getDecoder();

public static byte[] encode(String value) {
return value.getBytes(StandardCharsets.UTF_8);
}

public static String decode(byte[] bytes) {
return new String(bytes, StandardCharsets.UTF_8);
}

public static String decode(byte[] bytes, int offset, int length) {
return new String(bytes, offset, length, StandardCharsets.UTF_8);
}

public static String encodeBase64(byte[] bytes) {
return BASE64_ENCODER.encodeToString(bytes);
}

public static byte[] decodeBase64(String value) {
if (value.isEmpty()) {
return BYTES_EMPTY;
}
return BASE64_DECODER.decode(value);
}
}

This file was deleted.

2 changes: 0 additions & 2 deletions computer-dist/release-docs/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,6 @@ The following components are provided under the Apache 2.0 License.
(Apache License, Version 2.0) * okio(com.squareup.okio:okio-jvm:3.0.0-https://github.com/square/okio/ )
(Apache License, Version 2.0) * Simple XML (safe)(com.carrotsearch.thirdparty:simple-xml-safe:2.7.1-https://github.com/dweiss/simplexml )

computer-core/src/main/java/org/apache/hugegraph/computer/core/util/StringEncoding.java files from https://github.com/JanusGraph

========================================================================
Third party BSD licenses
========================================================================
Expand Down
Loading

0 comments on commit 6c07251

Please sign in to comment.