You are here

Bulk importing using a program

Code examples show you how to complete a streaming bulk import and an in-place bulk import programmatically.

Streaming

   UserTransaction txn = transactionService.getUserTransaction();
   txn.begin();
            
   AuthenticationUtil.setRunAsUser("admin");
                  
   StreamingNodeImporterFactory streamingNodeImporterFactory = (StreamingNodeImporterFactory)ctx.getBean("streamingNodeImporterFactory");
   NodeImporter nodeImporter = streamingNodeImporterFactory.getNodeImporter(new File("importdirectory"));
   BulkImportParameters bulkImportParameters = new BulkImportParameters();
   bulkImportParameters.setTarget(folderNode);
   bulkImportParameters.setReplaceExisting(true);
   bulkImportParameters.setBatchSize(40);
   bulkImportParameters.setNumThreads(4);
   bulkImporter.bulkImport(bulkImportParameters, nodeImporter);

   txn.commit();