Search in sources :

Example 1 with DataFactory

use of org.neo4j.internal.batchimport.input.csv.DataFactory in project neo4j by neo4j.

the class ImportPanicIT method shouldExitAndThrowExceptionOnPanic.

/**
 * There was this problem where some steps and in particular parallel CSV input parsing that
 * paniced would hang the import entirely.
 */
@Test
void shouldExitAndThrowExceptionOnPanic() throws Exception {
    try (JobScheduler jobScheduler = new ThreadPoolJobScheduler()) {
        BatchImporter importer = new ParallelBatchImporter(databaseLayout, testDirectory.getFileSystem(), PageCacheTracer.NULL, Configuration.DEFAULT, NullLogService.getInstance(), ExecutionMonitor.INVISIBLE, AdditionalInitialIds.EMPTY, Config.defaults(), StandardV3_4.RECORD_FORMATS, ImportLogic.NO_MONITOR, jobScheduler, Collector.EMPTY, LogFilesInitializer.NULL, IndexImporterFactory.EMPTY, EmptyMemoryTracker.INSTANCE);
        Iterable<DataFactory> nodeData = DataFactories.datas(DataFactories.data(InputEntityDecorators.NO_DECORATOR, fileAsCharReadable(nodeCsvFileWithBrokenEntries())));
        Input brokenCsvInput = new CsvInput(nodeData, DataFactories.defaultFormatNodeFileHeader(), DataFactories.datas(), DataFactories.defaultFormatRelationshipFileHeader(), IdType.ACTUAL, csvConfigurationWithLowBufferSize(), CsvInput.NO_MONITOR, INSTANCE);
        var e = assertThrows(InputException.class, () -> importer.doImport(brokenCsvInput));
        assertTrue(e.getCause() instanceof DataAfterQuoteException);
    }
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) CsvInput(org.neo4j.internal.batchimport.input.csv.CsvInput) Input(org.neo4j.internal.batchimport.input.Input) DataFactory(org.neo4j.internal.batchimport.input.csv.DataFactory) CsvInput(org.neo4j.internal.batchimport.input.csv.CsvInput) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) DataAfterQuoteException(org.neo4j.csv.reader.DataAfterQuoteException) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 DataAfterQuoteException (org.neo4j.csv.reader.DataAfterQuoteException)1 Input (org.neo4j.internal.batchimport.input.Input)1 CsvInput (org.neo4j.internal.batchimport.input.csv.CsvInput)1 DataFactory (org.neo4j.internal.batchimport.input.csv.DataFactory)1 JobScheduler (org.neo4j.scheduler.JobScheduler)1 ThreadPoolJobScheduler (org.neo4j.test.scheduler.ThreadPoolJobScheduler)1