Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,45 @@ The following files include code is copied from lzokay project.
Copyright: (c) 2018 Jack Andersen
Project page: https://github.com/AxioDL/lzokay
License: https://github.com/AxioDL/lzokay/blob/master/LICENSE

--------------------------------------------------------------------------------

The following files include code modified from Apache Commons Lang project.

./java/tsfile/src/main/java/org/apache/tsfile/external/commons/lang3/*

Apache Commons Lang is open source software licensed under the Apache License 2.0 and supported by the Apache Software Foundation.
Project page: https://github.com/apache/commons-lang
License: https://github.com/apache/commons-lang/blob/master/LICENSE.txt

--------------------------------------------------------------------------------

The following files include code modified from Apache Commons IO project.

./java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/*

Apache Commons IO is open source software licensed under the Apache License 2.0 and supported by the Apache Software Foundation.
Project page: https://github.com/apache/commons-io
License: https://github.com/apache/commons-io/blob/master/LICENSE.txt

--------------------------------------------------------------------------------

The following files include code modified from Apache Commons CodeC project.

./java/tsfile/src/main/java/org/apache/tsfile/external/commons/codec/*

Apache Commons CodeC is open source software licensed under the Apache License 2.0 and supported by the Apache Software Foundation.
Project page: https://github.com/apache/commons-codec
License: https://github.com/apache/commons-codec/blob/master/LICENSE.txt

--------------------------------------------------------------------------------

The following files include code modified from Apache Commons Collections project.

./java/tsfile/src/main/java/org/apache/tsfile/external/commons/collections4/*

Apache Commons Collections is open source software licensed under the Apache License 2.0 and supported by the Apache Software Foundation.
Project page: https://github.com/apache/commons-collections
License: https://github.com/apache/commons-collections/blob/master/LICENSE.txt

--------------------------------------------------------------------------------
10 changes: 0 additions & 10 deletions java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@
<artifactId>snappy-java</artifactId>
<version>1.1.10.5</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.18.0</version>
</dependency>
<dependency>
<groupId>org.lz4</groupId>
<artifactId>lz4-java</artifactId>
Expand Down
8 changes: 0 additions & 8 deletions java/tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@
<artifactId>commons-cli</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tsfile</groupId>
<artifactId>tsfile</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.tsfile.tools;

import org.apache.tsfile.enums.ColumnCategory;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.external.commons.io.FilenameUtils;
import org.apache.tsfile.file.metadata.TableSchema;
import org.apache.tsfile.file.metadata.enums.CompressionType;
import org.apache.tsfile.file.metadata.enums.TSEncoding;
Expand All @@ -35,8 +37,6 @@
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -55,6 +55,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -318,7 +319,7 @@ private static void cpFile(String sourceFilePath, String targetDirectoryPath) {

public static void writeToNewCSV(
String headerLine, String fileAbsolutePath, List<String> data, String newFileName) {
if (schema.hasHeader && StringUtils.isNotEmpty(headerLine)) {
if (schema.hasHeader && Objects.nonNull(headerLine) && !headerLine.isEmpty()) {
data.add(0, headerLine);
}
String inputFileAbsolutePath = new File(inputDirectoryStr).getAbsolutePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@

package org.apache.tsfile.tools;

import org.apache.tsfile.external.commons.io.FileUtils;
import org.apache.tsfile.read.TsFileSequenceReader;
import org.apache.tsfile.read.common.block.TsBlock;
import org.apache.tsfile.read.controller.CachedChunkLoaderImpl;
import org.apache.tsfile.read.controller.MetadataQuerierByFileImpl;
import org.apache.tsfile.read.query.executor.TableQueryExecutor;
import org.apache.tsfile.read.reader.block.TsBlockReader;

import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand Down
8 changes: 0 additions & 8 deletions java/tsfile/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.lz4</groupId>
<artifactId>lz4-java</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
* 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.tsfile.external.commons.codec.binary;

/////////////////////////////////////////////////////////////////////////////////////////////////
// IoTDB
/////////////////////////////////////////////////////////////////////////////////////////////////

public class Hex {

/** Used to build output as hex. */
private static final char[] DIGITS_LOWER = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
};

/** Used to build output as hex. */
private static final char[] DIGITS_UPPER = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
};

/**
* Converts an array of bytes into a String representing the hexadecimal values of each byte in
* order. The returned String will be double the length of the passed array, as it takes two
* characters to represent any given byte.
*
* @param data a byte[] to convert to hexadecimal characters
* @return A String containing lower-case hexadecimal characters
* @since 1.4
*/
public static String encodeHexString(final byte[] data) {
return new String(encodeHex(data));
}

/**
* Converts an array of bytes into an array of characters representing the hexadecimal values of
* each byte in order. The returned array will be double the length of the passed array, as it
* takes two characters to represent any given byte.
*
* @param data a byte[] to convert to hexadecimal characters
* @return A char[] containing lower-case hexadecimal characters
*/
public static char[] encodeHex(final byte[] data) {
return encodeHex(data, true);
}

/**
* Converts an array of bytes into an array of characters representing the hexadecimal values of
* each byte in order. The returned array will be double the length of the passed array, as it
* takes two characters to represent any given byte.
*
* @param data a byte[] to convert to Hex characters
* @param toLowerCase {@code true} converts to lowercase, {@code false} to uppercase
* @return A char[] containing hexadecimal characters in the selected case
* @since 1.4
*/
public static char[] encodeHex(final byte[] data, final boolean toLowerCase) {
return encodeHex(data, toLowerCase ? DIGITS_LOWER : DIGITS_UPPER);
}

/**
* Converts an array of bytes into an array of characters representing the hexadecimal values of
* each byte in order. The returned array will be double the length of the passed array, as it
* takes two characters to represent any given byte.
*
* @param data a byte[] to convert to hexadecimal characters
* @param toDigits the output alphabet (must contain at least 16 chars)
* @return A char[] containing the appropriate characters from the alphabet For best results, this
* should be either upper- or lower-case hex.
* @since 1.4
*/
protected static char[] encodeHex(final byte[] data, final char[] toDigits) {
final int dataLength = data.length;
final char[] out = new char[dataLength << 1];
encodeHex(data, 0, dataLength, toDigits, out, 0);
return out;
}

/**
* Converts an array of bytes into an array of characters representing the hexadecimal values of
* each byte in order.
*
* @param data a byte[] to convert to hexadecimal characters
* @param dataOffset the position in {@code data} to start encoding from
* @param dataLen the number of bytes from {@code dataOffset} to encode
* @param toDigits the output alphabet (must contain at least 16 chars)
* @param out a char[] which will hold the resultant appropriate characters from the alphabet.
* @param outOffset the position within {@code out} at which to start writing the encoded
* characters.
*/
private static void encodeHex(
final byte[] data,
final int dataOffset,
final int dataLen,
final char[] toDigits,
final char[] out,
final int outOffset) {
// two characters form the hex value.
for (int i = dataOffset, j = outOffset; i < dataOffset + dataLen; i++) {
out[j++] = toDigits[(0xF0 & data[i]) >>> 4];
out[j++] = toDigits[0x0F & data[i]];
}
}
}
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.tsfile.external.commons.codec.binary;

import java.security.MessageDigest;

/**
* Standard {@link MessageDigest} algorithm names from the <cite>Java Cryptography Architecture
* Standard Algorithm Name Documentation</cite>.
*
* <p>This class is immutable and thread-safe.
*
* <ul>
* <li>Java 8 and up: SHA-224.
* <li>Java 9 and up: SHA3-224, SHA3-256, SHA3-384, SHA3-512.
* </ul>
*
* @see <a
* href="https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#MessageDigest">
* Java 8 Cryptography Architecture Standard Algorithm Name Documentation</a>
* @see <a
* href="https://docs.oracle.com/en/java/javase/11/docs/specs/security/standard-names.html#messagedigest-algorithms">
* Java 11 Cryptography Architecture Standard Algorithm Name Documentation</a>
* @see <a
* href="https://docs.oracle.com/en/java/javase/17/docs/specs/security/standard-names.html#messagedigest-algorithms">
* Java 17 Cryptography Architecture Standard Algorithm Name Documentation</a>
* @see <a
* href="https://docs.oracle.com/en/java/javase/21/docs/specs/security/standard-names.html#messagedigest-algorithms">
* Java 21 Cryptography Architecture Standard Algorithm Name Documentation</a>
* @see <a href="https://dx.doi.org/10.6028/NIST.FIPS.180-4">FIPS PUB 180-4</a>
* @see <a href="https://dx.doi.org/10.6028/NIST.FIPS.202">FIPS PUB 202</a>
* @since 1.7
*/
public class MessageDigestAlgorithms {
/** The MD2 message digest algorithm defined in RFC 1319. */
public static final String MD2 = "MD2";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* 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.tsfile.external.commons.codec.binary;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

/////////////////////////////////////////////////////////////////////////////////////////////////
// IoTDB
/////////////////////////////////////////////////////////////////////////////////////////////////

public class StringUtils {
/**
* Encodes the given string into a sequence of bytes using the UTF-8 charset, storing the result
* into a new byte array.
*
* @param string the String to encode, may be {@code null}
* @return encoded bytes, or {@code null} if the input string was {@code null}
* @throws NullPointerException Thrown if {@link StandardCharsets#UTF_8} is not initialized, which
* should never happen since it is required by the Java platform specification.
* @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException
* @see Charset
* @see #getBytesUnchecked(String, String)
*/
public static byte[] getBytesUtf8(final String string) {
return getBytes(string, StandardCharsets.UTF_8);
}

/**
* Calls {@link String#getBytes(Charset)}
*
* @param string The string to encode (if null, return null).
* @param charset The {@link Charset} to encode the {@code String}
* @return the encoded bytes
*/
private static byte[] getBytes(final String string, final Charset charset) {
return string == null ? null : string.getBytes(charset);
}
}
Loading
Loading