diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/Charsets.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/Charsets.java index 2429385f2..7c89d0b02 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/Charsets.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/Charsets.java @@ -146,22 +146,6 @@ public class Charsets { */ @Deprecated public static final Charset UTF_8 = StandardCharsets.UTF_8; - /** - * Constructs a sorted map from canonical charset names to charset objects required of every - * implementation of the Java platform. - * - *

From the Java documentation Standard - * charsets: - * - * @return An immutable, case-insensitive map from canonical charset names to charset objects. - * @see Charset#availableCharsets() - * @since 2.5 - */ - public static SortedMap requiredCharsets() { - return STANDARD_CHARSET_MAP; - } - /** * Returns the given Charset or the default Charset if the given Charset is null. * diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/IOExceptionList.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/IOExceptionList.java index 30d8e35cd..f1c4e6791 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/IOExceptionList.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/IOExceptionList.java @@ -66,15 +66,6 @@ private static String toMessage(final List causeList) { /** List of causes. */ private final List causeList; - /** - * Constructs a new exception caused by a list of exceptions. - * - * @param causeList a list of cause exceptions. - */ - public IOExceptionList(final List causeList) { - this(toMessage(causeList), causeList); - } - /** * Constructs a new exception caused by a list of exceptions. * @@ -89,29 +80,6 @@ public IOExceptionList(final String message, final List cau this.causeList = causeList == null ? Collections.emptyList() : causeList; } - /** - * Gets the cause exception at the given index. - * - * @param type of exception to return. - * @param index index in the cause list. - * @return The list of causes. - */ - public T getCause(final int index) { - return (T) causeList.get(index); - } - - /** - * Gets the cause exception at the given index. - * - * @param type of exception to return. - * @param index index in the cause list. - * @param clazz type of exception to return. - * @return The list of causes. - */ - public T getCause(final int index, final Class clazz) { - return clazz.cast(getCause(index)); - } - /** * Gets the cause list. * diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/RandomAccessFileMode.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/RandomAccessFileMode.java deleted file mode 100644 index 13a1b3143..000000000 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/RandomAccessFileMode.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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.io; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.RandomAccessFile; -import java.nio.file.Path; - -/** - * Access modes and factory methods for {@link RandomAccessFile}. - * - * @since 2.12.0 - */ -public enum RandomAccessFileMode { - - /** Mode {@code "r"} opens for reading only. */ - READ_ONLY("r"), - - /** Mode {@code "rw"} opens for reading and writing. */ - READ_WRITE("rw"), - - /** - * Mode {@code "rws"} opens for reading and writing, as with {@code "rw"}, and also require that - * every update to the file's content or metadata be written synchronously to the underlying - * storage device. - */ - READ_WRITE_SYNC_ALL("rws"), - - /** - * Mode {@code "rwd"} open for reading and writing, as with {@code "rw"}, and also require that - * every update to the file's content be written synchronously to the underlying storage device. - */ - READ_WRITE_SYNC_CONTENT("rwd"); - - private final String mode; - - RandomAccessFileMode(final String mode) { - this.mode = mode; - } - - /** - * Constructs a random access file stream to read from, and optionally to write to, the file - * specified by the {@link File} argument. - * - * @param file the file object - * @return a random access file stream - * @throws FileNotFoundException See {@link RandomAccessFile#RandomAccessFile(File, String)}. - */ - public RandomAccessFile create(final File file) throws FileNotFoundException { - return new RandomAccessFile(file, mode); - } - - /** - * Constructs a random access file stream to read from, and optionally to write to, the file - * specified by the {@link File} argument. - * - * @param file the file object - * @return a random access file stream - * @throws FileNotFoundException See {@link RandomAccessFile#RandomAccessFile(File, String)}. - */ - public RandomAccessFile create(final Path file) throws FileNotFoundException { - return create(file.toFile()); - } - - /** - * Constructs a random access file stream to read from, and optionally to write to, the file - * specified by the {@link File} argument. - * - * @param file the file object - * @return a random access file stream - * @throws FileNotFoundException See {@link RandomAccessFile#RandomAccessFile(File, String)}. - */ - public RandomAccessFile create(final String file) throws FileNotFoundException { - return new RandomAccessFile(file, mode); - } - - @Override - public String toString() { - return mode; - } -} diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/RandomAccessFiles.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/RandomAccessFiles.java deleted file mode 100644 index e69f79a1d..000000000 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/RandomAccessFiles.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.io; - -import java.io.IOException; -import java.io.RandomAccessFile; - -/** - * Works on RandomAccessFile. - * - * @since 2.13.0 - */ -public class RandomAccessFiles { - - /** - * Reads a byte array starting at "position" for "length" bytes. - * - * @param input The source RandomAccessFile. - * @param position The offset position, measured in bytes from the beginning of the file, at which - * to set the file pointer. - * @param length How many bytes to read. - * @return a new byte array. - * @throws IOException If the first byte cannot be read for any reason other than end of file, or - * if the random access file has been closed, or if some other I/O error occurs. - */ - public static byte[] read(final RandomAccessFile input, final long position, final int length) - throws IOException { - input.seek(position); - return IOUtils.toByteArray(input::read, length); - } -} diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/build/AbstractOrigin.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/build/AbstractOrigin.java index 5189dfa81..cd95d2360 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/build/AbstractOrigin.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/build/AbstractOrigin.java @@ -104,12 +104,6 @@ public byte[] getByteArray() { return origin.toString().getBytes(Charset.defaultCharset()); } - @Override - public CharSequence getCharSequence(final Charset charset) { - // No conversion - return get(); - } - @Override public InputStream getInputStream(final OpenOption... options) throws IOException { // TODO Pass in a Charset? Consider if call sites actually need this. @@ -271,11 +265,6 @@ public byte[] getByteArray() throws IOException { return IOUtils.toByteArray(origin, Charset.defaultCharset()); } - @Override - public CharSequence getCharSequence(final Charset charset) throws IOException { - return IOUtils.toString(origin); - } - @Override public InputStream getInputStream(final OpenOption... options) throws IOException { // TODO Pass in a Charset? Consider if call sites actually need this. @@ -380,18 +369,6 @@ public byte[] getByteArray() throws IOException { return Files.readAllBytes(getPath()); } - /** - * Gets this origin as a byte array, if possible. - * - * @param charset The charset to use if conversion from bytes is needed. - * @return this origin as a byte array, if possible. - * @throws IOException if an I/O error occurs. - * @throws UnsupportedOperationException if the origin cannot be converted to a Path. - */ - public CharSequence getCharSequence(final Charset charset) throws IOException { - return new String(getByteArray(), charset); - } - /** * Gets this origin as a Path, if possible. * diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/file/Counters.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/file/Counters.java index 3c2fcf60e..82a00fcb1 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/file/Counters.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/file/Counters.java @@ -162,15 +162,6 @@ public String toString() { } } - /** Counts files, directories, and sizes, as a visit proceeds, using BigInteger numbers. */ - private static final class BigIntegerPathCounters extends AbstractPathCounters { - - /** Constructs a new initialized instance. */ - protected BigIntegerPathCounters() { - super(bigIntegerCounter(), bigIntegerCounter(), bigIntegerCounter()); - } - } - /** Counts using a number. */ public interface Counter { @@ -370,15 +361,6 @@ public static Counter bigIntegerCounter() { return new BigIntegerCounter(); } - /** - * Returns a new BigInteger PathCounters. - * - * @return a new BigInteger PathCounters. - */ - public static PathCounters bigIntegerPathCounters() { - return new BigIntegerPathCounters(); - } - /** * Returns a new long Counter. * @@ -406,14 +388,4 @@ public static PathCounters longPathCounters() { public static Counter noopCounter() { return NoopCounter.INSTANCE; } - - /** - * Returns the no-op PathCounters. - * - * @return the no-op PathCounters. - * @since 2.9.0 - */ - public static PathCounters noopPathCounters() { - return NoopPathCounters.INSTANCE; - } } diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/file/DeletingPathVisitor.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/file/DeletingPathVisitor.java index dcf56933a..c48ffef66 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/file/DeletingPathVisitor.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/file/DeletingPathVisitor.java @@ -38,22 +38,6 @@ public class DeletingPathVisitor extends CountingPathVisitor { private final boolean overrideReadOnly; private final LinkOption[] linkOptions; - /** - * Constructs a new visitor that deletes files except for the files and directories explicitly - * given. - * - * @param pathCounter How to count visits. - * @param deleteOption How deletion is handled. - * @param skip The files to skip deleting. - * @since 2.8.0 - */ - public DeletingPathVisitor( - final Counters.PathCounters pathCounter, - final DeleteOption[] deleteOption, - final String... skip) { - this(pathCounter, PathUtils.noFollowLinkOptionArray(), deleteOption, skip); - } - /** * Constructs a new visitor that deletes files except for the files and directories explicitly * given. diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/filefilter/AbstractFileFilter.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/filefilter/AbstractFileFilter.java index 9b184a914..60a25f916 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/filefilter/AbstractFileFilter.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/filefilter/AbstractFileFilter.java @@ -19,7 +19,6 @@ import org.apache.tsfile.external.commons.io.file.PathFilter; import org.apache.tsfile.external.commons.io.file.PathVisitor; -import org.apache.tsfile.external.commons.io.function.IOSupplier; import java.io.File; import java.io.FileFilter; @@ -112,14 +111,6 @@ void append(final Object[] array, final StringBuilder buffer) { } } - FileVisitResult get(final IOSupplier supplier) { - try { - return supplier.get(); - } catch (final IOException e) { - return handle(e); - } - } - /** * Handles exceptions caught while accepting. * diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/filefilter/FalseFileFilter.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/filefilter/FalseFileFilter.java deleted file mode 100644 index 94864427e..000000000 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/filefilter/FalseFileFilter.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.io.filefilter; - -import java.io.File; -import java.io.Serializable; -import java.nio.file.FileVisitResult; -import java.nio.file.Path; -import java.nio.file.attribute.BasicFileAttributes; - -/** - * A file filter that always returns false. - * - *

Deprecating Serialization

- * - *

Serialization is deprecated and will be removed in 3.0. - * - * @since 1.0 - * @see FileFilterUtils#falseFileFilter() - */ -public class FalseFileFilter implements IOFileFilter, Serializable { - - private static final String TO_STRING = Boolean.FALSE.toString(); - - /** - * Singleton instance of false filter. - * - * @since 1.3 - */ - public static final IOFileFilter FALSE = new FalseFileFilter(); - - /** - * Singleton instance of false filter. Please use the identical FalseFileFilter.FALSE constant. - * The new name is more JDK 1.5 friendly as it doesn't clash with other values when using static - * imports. - */ - public static final IOFileFilter INSTANCE = FALSE; - - private static final long serialVersionUID = 6210271677940926200L; - - /** Restrictive constructor. */ - protected FalseFileFilter() {} - - /** - * Returns false. - * - * @param file the file to check (ignored) - * @return false - */ - @Override - public boolean accept(final File file) { - return false; - } - - /** - * Returns false. - * - * @param dir the directory to check (ignored) - * @param name the file name (ignored) - * @return false - */ - @Override - public boolean accept(final File dir, final String name) { - return false; - } - - /** - * Returns false. - * - * @param file the file to check (ignored) - * @return false - * @since 2.9.0 - */ - @Override - public FileVisitResult accept(final Path file, final BasicFileAttributes attributes) { - return FileVisitResult.TERMINATE; - } - - @Override - public IOFileFilter and(final IOFileFilter fileFilter) { - // FALSE AND expression <=> FALSE - return INSTANCE; - } - - @Override - public IOFileFilter or(final IOFileFilter fileFilter) { - // FALSE OR expression <=> expression - return fileFilter; - } - - @Override - public String toString() { - return TO_STRING; - } -} diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/filefilter/IOFileFilter.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/filefilter/IOFileFilter.java index 3dea15de3..a18330674 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/filefilter/IOFileFilter.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/filefilter/IOFileFilter.java @@ -35,9 +35,6 @@ */ public interface IOFileFilter extends FileFilter, FilenameFilter, PathFilter, PathMatcher { - /** An empty String array. */ - String[] EMPTY_STRING_ARRAY = {}; - /** * Tests if a File should be accepted by this filter. * diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/filefilter/NotFileFilter.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/filefilter/NotFileFilter.java deleted file mode 100644 index 8a81915ea..000000000 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/filefilter/NotFileFilter.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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.io.filefilter; - -import java.io.File; -import java.io.Serializable; -import java.nio.file.FileVisitResult; -import java.nio.file.Path; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.Objects; - -/** - * This filter produces a logical NOT of the filters specified. - * - *

Deprecating Serialization

- * - *

Serialization is deprecated and will be removed in 3.0. - * - * @since 1.0 - * @see FileFilterUtils#notFileFilter(IOFileFilter) - */ -public class NotFileFilter extends AbstractFileFilter implements Serializable { - - private static final long serialVersionUID = 6131563330944994230L; - - /** The filter */ - private final IOFileFilter filter; - - /** - * Constructs a new file filter that NOTs the result of another filter. - * - * @param filter the filter, must not be null - * @throws NullPointerException if the filter is null - */ - public NotFileFilter(final IOFileFilter filter) { - Objects.requireNonNull(filter, "filter"); - this.filter = filter; - } - - /** - * Returns the logical NOT of the underlying filter's return value for the same File. - * - * @param file the File to check - * @return true if the filter returns false - */ - @Override - public boolean accept(final File file) { - return !filter.accept(file); - } - - /** - * Returns the logical NOT of the underlying filter's return value for the same arguments. - * - * @param file the File directory - * @param name the file name - * @return true if the filter returns false - */ - @Override - public boolean accept(final File file, final String name) { - return !filter.accept(file, name); - } - - /** - * Returns the logical NOT of the underlying filter's return value for the same File. - * - * @param file the File to check - * @return true if the filter returns false - * @since 2.9.0 - */ - @Override - public FileVisitResult accept(final Path file, final BasicFileAttributes attributes) { - return not(filter.accept(file, attributes)); - } - - private FileVisitResult not(final FileVisitResult accept) { - return accept == FileVisitResult.CONTINUE - ? FileVisitResult.TERMINATE - : FileVisitResult.CONTINUE; - } - - /** - * Provide a String representation of this file filter. - * - * @return a String representation - */ - @Override - public String toString() { - return "NOT (" + filter.toString() + ")"; - } -} diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/Constants.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/Constants.java deleted file mode 100644 index 1041a3286..000000000 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/Constants.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.io.function; - -/** Defines package-private constants. */ -final class Constants { - - /** No-op singleton. */ - @SuppressWarnings("rawtypes") - static final IOBiConsumer IO_BI_CONSUMER = - (t, u) -> { - /* No-op */ - }; - - /** No-op singleton. */ - static final IORunnable IO_RUNNABLE = - () -> { - /* No-op */ - }; - - /** No-op singleton. */ - @SuppressWarnings("rawtypes") - static final IOBiFunction IO_BI_FUNCTION = (t, u) -> null; - - /** No-op singleton. */ - @SuppressWarnings("rawtypes") - static final IOFunction IO_FUNCTION_ID = t -> t; - - /** Always false. */ - static final IOPredicate IO_PREDICATE_FALSE = t -> false; - - /** Always true. */ - static final IOPredicate IO_PREDICATE_TRUE = t -> true; - - /** No-op singleton. */ - @SuppressWarnings("rawtypes") - static final IOTriConsumer IO_TRI_CONSUMER = - (t, u, v) -> { - /* No-op */ - }; - - private Constants() { - // We don't want instances - } -} diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOBaseStream.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOBaseStream.java index 9de5dd8c4..b477788d3 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOBaseStream.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOBaseStream.java @@ -43,17 +43,6 @@ default void close() { unwrap().close(); } - /** - * Like {@link BaseStream#isParallel()}. - * - * @return See {@link BaseStream#isParallel() delegate}. - * @see BaseStream#isParallel() - */ - @SuppressWarnings("resource") // for unwrap() - default boolean isParallel() { - return unwrap().isParallel(); - } - /** * Like {@link BaseStream#iterator()}. * @@ -78,50 +67,6 @@ default S onClose(final IORunnable closeHandler) throws IOException { return wrap(unwrap().onClose(() -> Erase.run(closeHandler))); } - /** - * Like {@link BaseStream#parallel()}. - * - * @return See {@link BaseStream#parallel() delegate}. - * @see BaseStream#parallel() - */ - @SuppressWarnings({"resource", "unchecked"}) // for unwrap(), this - default S parallel() { - return isParallel() ? (S) this : wrap(unwrap().parallel()); - } - - /** - * Like {@link BaseStream#sequential()}. - * - * @return See {@link BaseStream#sequential() delegate}. - * @see BaseStream#sequential() - */ - @SuppressWarnings({"resource", "unchecked"}) // for unwrap(), this - default S sequential() { - return isParallel() ? wrap(unwrap().sequential()) : (S) this; - } - - /** - * Like {@link BaseStream#spliterator()}. - * - * @return See {@link BaseStream#spliterator() delegate}. - * @see BaseStream#spliterator() - */ - @SuppressWarnings("resource") // for unwrap() - default IOSpliterator spliterator() { - return IOSpliteratorAdapter.adapt(unwrap().spliterator()); - } - - /** - * Like {@link BaseStream#unordered()}. - * - * @return See {@link BaseStream#unordered() delegate}. - * @see java.util.stream.BaseStream#unordered() - */ - @SuppressWarnings("resource") // for unwrap() - default S unordered() { - return wrap(unwrap().unordered()); - } - /** * Unwraps this instance and returns the underlying {@link Stream}. * diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOBiConsumer.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOBiConsumer.java index 90b8cc879..390725bd4 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOBiConsumer.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOBiConsumer.java @@ -18,7 +18,6 @@ package org.apache.tsfile.external.commons.io.function; import java.io.IOException; -import java.io.UncheckedIOException; import java.util.function.BiConsumer; /** @@ -40,16 +39,4 @@ public interface IOBiConsumer { * @throws IOException if an I/O error occurs. */ void accept(T t, U u) throws IOException; - - /** - * Creates a {@link BiConsumer} for this instance that throws {@link UncheckedIOException} instead - * of {@link IOException}. - * - * @return an UncheckedIOException BiConsumer. - * @throws UncheckedIOException Wraps an {@link IOException}. - * @since 2.12.0 - */ - default BiConsumer asBiConsumer() { - return (t, u) -> Uncheck.accept(this, t, u); - } } diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOBiFunction.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOBiFunction.java index bd1dad52a..42ac600e4 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOBiFunction.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOBiFunction.java @@ -18,7 +18,6 @@ package org.apache.tsfile.external.commons.io.function; import java.io.IOException; -import java.util.Objects; import java.util.function.BiFunction; import java.util.function.Function; @@ -37,22 +36,6 @@ @FunctionalInterface public interface IOBiFunction { - /** - * Creates a composed function that first applies this function to its input, and then applies the - * {@code after} function to the result. If evaluation of either function throws an exception, it - * is relayed to the caller of the composed function. - * - * @param the type of output of the {@code after} function, and of the composed function - * @param after the function to apply after this function is applied - * @return a composed function that first applies this function and then applies the {@code after} - * function - * @throws NullPointerException if after is null - */ - default IOBiFunction andThen(final IOFunction after) { - Objects.requireNonNull(after); - return (final T t, final U u) -> after.apply(apply(t, u)); - } - /** * Applies this function to the given arguments. * diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOComparator.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOComparator.java index 7a6fdc0c8..342737dc7 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOComparator.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOComparator.java @@ -18,7 +18,6 @@ package org.apache.tsfile.external.commons.io.function; import java.io.IOException; -import java.io.UncheckedIOException; import java.util.Comparator; /** @@ -31,16 +30,6 @@ @FunctionalInterface public interface IOComparator { - /** - * Creates a {@link Comparator} for this instance that throws {@link UncheckedIOException} instead - * of {@link IOException}. - * - * @return an UncheckedIOException BiFunction. - */ - default Comparator asComparator() { - return (t, u) -> Uncheck.compare(this, t, u); - } - /** * Like {@link Comparator#compare(Object, Object)} but throws {@link IOException}. * diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOConsumer.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOConsumer.java index fe043875b..baf186a88 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOConsumer.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOConsumer.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.io.UncheckedIOException; -import java.util.Objects; import java.util.function.Consumer; import java.util.stream.Stream; @@ -113,25 +112,6 @@ static IOConsumer noop() { */ void accept(T t) throws IOException; - /** - * Returns a composed {@link IOConsumer} that performs, in sequence, this operation followed by - * the {@code after} operation. If performing either operation throws an exception, it is relayed - * to the caller of the composed operation. If performing this operation throws an exception, the - * {@code after} operation will not be performed. - * - * @param after the operation to perform after this operation - * @return a composed {@link Consumer} that performs in sequence this operation followed by the - * {@code after} operation - * @throws NullPointerException if {@code after} is null - */ - default IOConsumer andThen(final IOConsumer after) { - Objects.requireNonNull(after, "after"); - return (final T t) -> { - accept(t); - after.accept(t); - }; - } - /** * Creates a {@link Consumer} for this instance that throws {@link UncheckedIOException} instead * of {@link IOException}. diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOSpliterator.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOSpliterator.java deleted file mode 100644 index 3b77590de..000000000 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOSpliterator.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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.io.function; - -import java.io.IOException; -import java.util.Objects; -import java.util.Spliterator; -import java.util.function.Consumer; - -/** - * Like {@link Spliterator} but throws {@link IOException}. - * - * @param the type of elements returned by this IOSpliterator. - * @since 2.12.0 - */ -public interface IOSpliterator { - - /** - * Adapts the given Spliterator as an IOSpliterator. - * - * @param the type of the stream elements. - * @param iterator The iterator to adapt - * @return A new IOSpliterator - */ - static IOSpliterator adapt(final Spliterator iterator) { - return IOSpliteratorAdapter.adapt(iterator); - } - - /** - * Like {@link Spliterator#characteristics()}. - * - * @return a representation of characteristics - */ - default int characteristics() { - return unwrap().characteristics(); - } - - /** - * Like {@link Spliterator#estimateSize()}. - * - * @return the estimated size, or {@code Long.MAX_VALUE} if infinite, unknown, or too expensive to - * compute. - */ - default long estimateSize() { - return unwrap().estimateSize(); - } - - /** - * Like {@link Spliterator#forEachRemaining(Consumer)}. - * - * @param action The action - * @throws NullPointerException if the specified action is null - */ - default void forEachRemaining(final IOConsumer action) { - while (tryAdvance(action)) { // NOPMD - } - } - - /** - * Like {@link Spliterator#getComparator()}. - * - * @return a Comparator, or {@code null} if the elements are sorted in the natural order. - * @throws IllegalStateException if the spliterator does not report a characteristic of {@code - * SORTED}. - */ - @SuppressWarnings("unchecked") - default IOComparator getComparator() { - return (IOComparator) unwrap().getComparator(); - } - - /** - * Like {@link Spliterator#getExactSizeIfKnown()}. - * - * @return the exact size, if known, else {@code -1}. - */ - default long getExactSizeIfKnown() { - return unwrap().getExactSizeIfKnown(); - } - - /** - * Like {@link Spliterator#hasCharacteristics(int)}. - * - * @param characteristics the characteristics to check for - * @return {@code true} if all the specified characteristics are present, else {@code false} - */ - default boolean hasCharacteristics(final int characteristics) { - return unwrap().hasCharacteristics(characteristics); - } - - /** - * Like {@link Spliterator#tryAdvance(Consumer)}. - * - * @param action The action - * @return {@code false} if no remaining elements existed upon entry to this method, else {@code - * true}. - * @throws NullPointerException if the specified action is null - */ - default boolean tryAdvance(final IOConsumer action) { - return unwrap().tryAdvance(Objects.requireNonNull(action, "action").asConsumer()); - } - - /** - * Like {@link Spliterator#trySplit()}. - * - * @return a {@code Spliterator} covering some portion of the elements, or {@code null} if this - * spliterator cannot be split - */ - default IOSpliterator trySplit() { - return adapt(unwrap().trySplit()); - } - - /** - * Unwraps this instance and returns the underlying {@link Spliterator}. - * - *

Implementations may not have anything to unwrap and that behavior is undefined for now. - * - * @return the underlying Spliterator. - */ - Spliterator unwrap(); -} diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOSpliteratorAdapter.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOSpliteratorAdapter.java deleted file mode 100644 index 06463b3eb..000000000 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/function/IOSpliteratorAdapter.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.io.function; - -import java.util.Objects; -import java.util.Spliterator; - -/** - * Adapts an {@link Spliterator} as an {@link IOSpliterator}. - * - * @param the type of the stream elements. - */ -final class IOSpliteratorAdapter implements IOSpliterator { - - static IOSpliteratorAdapter adapt(final Spliterator delegate) { - return new IOSpliteratorAdapter<>(delegate); - } - - private final Spliterator delegate; - - IOSpliteratorAdapter(final Spliterator delegate) { - this.delegate = Objects.requireNonNull(delegate, "delegate"); - } - - @Override - public Spliterator unwrap() { - return delegate; - } -} diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/output/AbstractByteArrayOutputStream.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/output/AbstractByteArrayOutputStream.java index a75302bcc..43e90c029 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/output/AbstractByteArrayOutputStream.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/output/AbstractByteArrayOutputStream.java @@ -17,16 +17,13 @@ package org.apache.tsfile.external.commons.io.output; import org.apache.tsfile.external.commons.io.IOUtils; -import org.apache.tsfile.external.commons.io.input.ClosedInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.SequenceInputStream; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import static org.apache.tsfile.external.commons.io.IOUtils.EOF; @@ -52,25 +49,6 @@ */ public abstract class AbstractByteArrayOutputStream extends OutputStream { - /** - * Constructor for an InputStream subclass. - * - * @param the type of the InputStream. - */ - @FunctionalInterface - protected interface InputStreamConstructor { - - /** - * Constructs an InputStream subclass. - * - * @param buffer the buffer - * @param offset the offset into the buffer - * @param length the length of the buffer - * @return the InputStream subclass. - */ - T construct(final byte[] buffer, final int offset, final int length); - } - static final int DEFAULT_SIZE = 1024; /** The list of buffers, which grows and never reduces. */ @@ -200,51 +178,6 @@ protected byte[] toByteArrayImpl() { return newBuf; } - /** - * Gets the current contents of this byte stream as an Input Stream. The returned stream is backed - * by buffers of {@code this} stream, avoiding memory allocation and copy, thus saving space and - * time.
- * - * @return the current contents of this output stream. - * @see java.io.ByteArrayOutputStream#toByteArray() - * @see #reset() - * @since 2.5 - */ - public abstract InputStream toInputStream(); - - /** - * Gets the current contents of this byte stream as an Input Stream. The returned stream is backed - * by buffers of {@code this} stream, avoiding memory allocation and copy, thus saving space and - * time.
- * - * @param the type of the InputStream which makes up the {@link SequenceInputStream}. - * @param isConstructor A constructor for an InputStream which makes up the {@link - * SequenceInputStream}. - * @return the current contents of this output stream. - * @see java.io.ByteArrayOutputStream#toByteArray() - * @see #reset() - * @since 2.7 - */ - @SuppressWarnings("resource") // The result InputStream MUST be managed by the call site. - protected InputStream toInputStream( - final InputStreamConstructor isConstructor) { - int remaining = count; - if (remaining == 0) { - return ClosedInputStream.INSTANCE; - } - final List list = new ArrayList<>(buffers.size()); - for (final byte[] buf : buffers) { - final int c = Math.min(buf.length, remaining); - list.add(isConstructor.construct(buf, 0, c)); - remaining -= c; - if (remaining == 0) { - break; - } - } - reuseBuffers = false; - return new SequenceInputStream(Collections.enumeration(list)); - } - /** * Gets the current contents of this byte stream as a string using the platform default charset. * diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/output/ByteArrayOutputStream.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/output/ByteArrayOutputStream.java index 9d3f014bd..2e8f9c33a 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/output/ByteArrayOutputStream.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/output/ByteArrayOutputStream.java @@ -69,11 +69,6 @@ public synchronized byte[] toByteArray() { return toByteArrayImpl(); } - @Override - public synchronized InputStream toInputStream() { - return toInputStream(java.io.ByteArrayInputStream::new); - } - @Override public void write(final byte[] b, final int off, final int len) { if (off < 0 || off > b.length || len < 0 || off + len > b.length || off + len < 0) { diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/output/UnsynchronizedByteArrayOutputStream.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/output/UnsynchronizedByteArrayOutputStream.java index ee4e767ef..6dc5377a3 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/output/UnsynchronizedByteArrayOutputStream.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/output/UnsynchronizedByteArrayOutputStream.java @@ -18,8 +18,6 @@ import org.apache.tsfile.external.commons.io.build.AbstractOrigin; import org.apache.tsfile.external.commons.io.build.AbstractStreamBuilder; -import org.apache.tsfile.external.commons.io.function.Uncheck; -import org.apache.tsfile.external.commons.io.input.UnsynchronizedByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -129,21 +127,6 @@ public byte[] toByteArray() { return toByteArrayImpl(); } - @Override - public InputStream toInputStream() { - // @formatter:off - return toInputStream( - (buffer, offset, length) -> - Uncheck.get( - () -> - UnsynchronizedByteArrayInputStream.builder() - .setByteArray(buffer) - .setOffset(offset) - .setLength(length) - .get())); - // @formatter:on - } - @Override public void write(final byte[] b, final int off, final int len) { if (off < 0 || off > b.length || len < 0 || off + len > b.length || off + len < 0) { diff --git a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/output/WriterOutputStream.java b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/output/WriterOutputStream.java index 5eaa86979..822c17f92 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/output/WriterOutputStream.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/external/commons/io/output/WriterOutputStream.java @@ -139,36 +139,6 @@ public Builder setCharset(final String charset) { this.charsetDecoder = getCharset().newDecoder(); return this; } - - /** - * Sets the charset decoder. - * - * @param charsetDecoder the charset decoder. - * @return this - */ - public Builder setCharsetDecoder(final CharsetDecoder charsetDecoder) { - this.charsetDecoder = - charsetDecoder != null ? charsetDecoder : getCharsetDefault().newDecoder(); - super.setCharset(this.charsetDecoder.charset()); - return this; - } - - /** - * Sets whether the output buffer will be flushed after each write operation ({@code true}), - * i.e. all available data will be written to the underlying {@link Writer} immediately. If - * {@code false}, the output buffer will only be flushed when it overflows or when {@link - * #flush()} or {@link #close()} is called. - * - * @param writeImmediately If {@code true} the output buffer will be flushed after each write - * operation, i.e. all available data will be written to the underlying {@link Writer} - * immediately. If {@code false}, the output buffer will only be flushed when it overflows - * or when {@link #flush()} or {@link #close()} is called. - * @return this - */ - public Builder setWriteImmediately(final boolean writeImmediately) { - this.writeImmediately = writeImmediately; - return this; - } } private static final int BUFFER_SIZE = IOUtils.DEFAULT_BUFFER_SIZE;