Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.apache.paimon.fs.FileIO;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;

import static org.apache.paimon.utils.ThreadPoolUtils.createCachedThreadPool;
Expand All @@ -32,10 +33,13 @@ public class FileOperationThreadPool {
private static ThreadPoolExecutor executorService =
createCachedThreadPool(Runtime.getRuntime().availableProcessors(), THREAD_NAME);

public static synchronized ThreadPoolExecutor getExecutorService(int threadNum) {
if (threadNum <= executorService.getMaximumPoolSize()) {
public static synchronized ExecutorService getExecutorService(int threadNum) {
if (threadNum <= 0 || threadNum == executorService.getMaximumPoolSize()) {
return executorService;
}
if (threadNum < executorService.getMaximumPoolSize()) {
return new SemaphoredDelegatingExecutor(executorService, threadNum, false);
}
// we don't need to close previous pool
// it is just cached pool
executorService = createCachedThreadPool(threadNum, THREAD_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.ExecutorService;

/** List what data files recorded in manifests are missing from the filesystem. */
public class ListUnexistingFiles {

private final FileStoreTable table;
private final FileStorePathFactory pathFactory;
private final ThreadPoolExecutor executor;
private final ExecutorService executor;

public ListUnexistingFiles(FileStoreTable table) {
this.table = table;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import java.util.function.Predicate;
Expand Down Expand Up @@ -89,7 +88,7 @@ public class TableCommitImpl implements InnerTableCommit {
private final AtomicReference<Throwable> maintainError;
private final String tableName;
private final boolean forceCreatingSnapshot;
private final ThreadPoolExecutor fileCheckExecutor;
private final ExecutorService fileCheckExecutor;

@Nullable private Map<String, String> overwritePartitionSpec = null;
@Nullable private List<BinaryRow> overwriteStaticPartitions = null;
Expand Down
Loading