22
33import com .scalar .db .api .DistributedTransaction ;
44import com .scalar .db .dataloader .core .DataLoaderError ;
5- import com .scalar .db .dataloader .core .ScalarDbMode ;
5+ import com .scalar .db .dataloader .core .TransactionMode ;
66import com .scalar .db .dataloader .core .dataimport .ImportEventListener ;
77import com .scalar .db .dataloader .core .dataimport .datachunk .ImportDataChunk ;
88import com .scalar .db .dataloader .core .dataimport .datachunk .ImportDataChunkStatus ;
@@ -55,12 +55,12 @@ public abstract class ImportProcessor {
5555 *
5656 * <p>This method reads data from the provided {@link BufferedReader}, processes it in chunks, and
5757 * batches transactions according to the specified sizes. The processing can be done in either
58- * transactional or storage mode, depending on the configured {@link ScalarDbMode }.
58+ * single CRUD or consensus commit mode, depending on the configured {@link TransactionMode }.
5959 *
6060 * @param dataChunkSize the number of records to include in each data chunk for parallel
6161 * processing
6262 * @param transactionBatchSize the number of records to group together in a single transaction
63- * (only used in transaction mode)
63+ * (only used in consensus commit mode)
6464 * @param reader the {@link BufferedReader} used to read the source file
6565 */
6666 public void process (int dataChunkSize , int transactionBatchSize , BufferedReader reader ) {
@@ -169,11 +169,11 @@ public void removeListener(ImportEventListener listener) {
169169 }
170170
171171 /**
172- * Notify once the task is completed
172+ * Notify once a single CRUD task is completed
173173 *
174174 * @param result task result object
175175 */
176- protected void notifyStorageRecordCompleted (ImportTaskResult result ) {
176+ protected void notifySingleCrudRecordCompleted (ImportTaskResult result ) {
177177 // Add data to summary, success logs with/without raw data
178178 for (ImportEventListener listener : listeners ) {
179179 listener .onTaskComplete (result );
@@ -366,14 +366,14 @@ private void abortTransactionSafely(@Nullable DistributedTransaction transaction
366366 }
367367
368368 /**
369- * Processes a single record in storage mode (non-transactional). Each record is processed
369+ * Processes a single record in single CRUD mode (non-transactional). Each record is processed
370370 * independently without transaction guarantees.
371371 *
372372 * @param dataChunkId the parent data chunk id of the chunk containing this record
373373 * @param importRow the record to process
374374 * @return an {@link ImportTaskResult} containing the processing result for the record
375375 */
376- private ImportTaskResult processStorageRecord (int dataChunkId , ImportRow importRow ) {
376+ private ImportTaskResult processSingleCrudRecord (int dataChunkId , ImportRow importRow ) {
377377 ImportTaskParams taskParams =
378378 ImportTaskParams .builder ()
379379 .sourceRecord (importRow .getSourceData ())
@@ -394,16 +394,17 @@ private ImportTaskResult processStorageRecord(int dataChunkId, ImportRow importR
394394 .targets (importRecordResult .getTargets ())
395395 .dataChunkId (dataChunkId )
396396 .build ();
397- notifyStorageRecordCompleted (modifiedTaskResult );
397+ notifySingleCrudRecordCompleted (modifiedTaskResult );
398398 return modifiedTaskResult ;
399399 }
400400
401401 /**
402- * Processes a complete data chunk using parallel execution. The processing mode (transactional or
403- * storage ) is determined by the configured {@link ScalarDbMode }.
402+ * Processes a complete data chunk using parallel execution. The processing mode (consensus commit
403+ * or single CRUD ) is determined by the configured {@link TransactionMode }.
404404 *
405405 * @param dataChunk the data chunk to process
406- * @param transactionBatchSize the size of transaction batches (used only in transaction mode)
406+ * @param transactionBatchSize the size of transaction batches (used only in consensus commit
407+ * mode)
407408 */
408409 private void processDataChunk (ImportDataChunk dataChunk , int transactionBatchSize ) {
409410 ImportDataChunkStatus status =
@@ -414,23 +415,24 @@ private void processDataChunk(ImportDataChunk dataChunk, int transactionBatchSiz
414415 .build ();
415416 notifyDataChunkStarted (status );
416417 ImportDataChunkStatus importDataChunkStatus ;
417- if (params .getScalarDbMode () == ScalarDbMode .TRANSACTION ) {
418- importDataChunkStatus = processDataChunkWithTransactions (dataChunk , transactionBatchSize );
418+ if (params .getTransactionMode () == TransactionMode .CONSENSUS_COMMIT ) {
419+ importDataChunkStatus =
420+ processDataChunkInConsensusCommitMode (dataChunk , transactionBatchSize );
419421 } else {
420- importDataChunkStatus = processDataChunkWithoutTransactions (dataChunk );
422+ importDataChunkStatus = processDataChunkInSingleCrudMode (dataChunk );
421423 }
422424 notifyDataChunkCompleted (importDataChunkStatus );
423425 }
424426
425427 /**
426- * Processes a data chunk using transaction mode with parallel batch processing. Multiple
428+ * Processes a data chunk using consensus commit mode with parallel batch processing. Multiple
427429 * transaction batches are processed concurrently using a thread pool.
428430 *
429431 * @param dataChunk the data chunk to process
430432 * @param transactionBatchSize the number of records per transaction batch
431433 * @return an {@link ImportDataChunkStatus} containing processing results and metrics
432434 */
433- private ImportDataChunkStatus processDataChunkWithTransactions (
435+ private ImportDataChunkStatus processDataChunkInConsensusCommitMode (
434436 ImportDataChunk dataChunk , int transactionBatchSize ) {
435437 Instant startTime = Instant .now ();
436438 List <ImportTransactionBatch > transactionBatches =
@@ -464,19 +466,19 @@ private ImportDataChunkStatus processDataChunkWithTransactions(
464466 }
465467
466468 /**
467- * Processes a data chunk using storage mode with parallel record processing. Individual records
468- * are processed concurrently without transaction guarantees.
469+ * Processes a data chunk using single CRUD mode with parallel record processing. Individual
470+ * records are processed concurrently without transaction guarantees.
469471 *
470472 * @param dataChunk the data chunk to process
471473 * @return an {@link ImportDataChunkStatus} containing processing results and metrics
472474 */
473- private ImportDataChunkStatus processDataChunkWithoutTransactions (ImportDataChunk dataChunk ) {
475+ private ImportDataChunkStatus processDataChunkInSingleCrudMode (ImportDataChunk dataChunk ) {
474476 Instant startTime = Instant .now ();
475477 AtomicInteger successCount = new AtomicInteger (0 );
476478 AtomicInteger failureCount = new AtomicInteger (0 );
477479
478480 for (ImportRow importRow : dataChunk .getSourceData ()) {
479- ImportTaskResult result = processStorageRecord (dataChunk .getDataChunkId (), importRow );
481+ ImportTaskResult result = processSingleCrudRecord (dataChunk .getDataChunkId (), importRow );
480482 boolean allSaved =
481483 result .getTargets ().stream ()
482484 .allMatch (t -> t .getStatus ().equals (ImportTargetResultStatus .SAVED ));
0 commit comments