Search in sources :

Example 1 with ExcelReaderExecutor

use of com.dtstack.flinkx.connector.ftp.client.excel.ExcelReaderExecutor in project chunjun by DTStack.

the class ExcelFileReadClient method open.

@Override
public void open(InputStream inputStream, FtpConfig ftpConfig) throws IOException {
    cellCount = ftpConfig.getColumn().size();
    ExcelReadListener listener = new ExcelReadListener();
    queue = listener.getQueue();
    ExcelReaderBuilder builder = EasyExcel.read(inputStream, listener);
    if (!ftpConfig.getIsFirstLineHeader()) {
        builder.headRowNumber(0);
    }
    builder.ignoreEmptyRow(true);
    ExcelReader reader = builder.build();
    sheetNum = reader.excelExecutor().sheetList().size();
    executorService = new ThreadPoolExecutor(1, 1, 0, NANOSECONDS, new LinkedBlockingDeque<>(2), new BasicThreadFactory.Builder().namingPattern("excel-schedule-pool-%d").uncaughtExceptionHandler(new ExcelReaderExceptionHandler()).daemon(false).build());
    ExcelReaderExecutor executor = new ExcelReaderExecutor(reader);
    executorService.execute(executor);
}
Also used : ExcelReader(com.alibaba.excel.ExcelReader) ExcelReadListener(com.dtstack.flinkx.connector.ftp.client.excel.ExcelReadListener) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) ExcelReaderBuilder(com.alibaba.excel.read.builder.ExcelReaderBuilder) ExcelReaderBuilder(com.alibaba.excel.read.builder.ExcelReaderBuilder) ExcelReaderExceptionHandler(com.dtstack.flinkx.connector.ftp.client.excel.ExcelReaderExceptionHandler) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ExcelReaderExecutor(com.dtstack.flinkx.connector.ftp.client.excel.ExcelReaderExecutor)

Aggregations

ExcelReader (com.alibaba.excel.ExcelReader)1 ExcelReaderBuilder (com.alibaba.excel.read.builder.ExcelReaderBuilder)1 ExcelReadListener (com.dtstack.flinkx.connector.ftp.client.excel.ExcelReadListener)1 ExcelReaderExceptionHandler (com.dtstack.flinkx.connector.ftp.client.excel.ExcelReaderExceptionHandler)1 ExcelReaderExecutor (com.dtstack.flinkx.connector.ftp.client.excel.ExcelReaderExecutor)1 LinkedBlockingDeque (java.util.concurrent.LinkedBlockingDeque)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1