Skip to content

Commit ad5aa9f

Browse files
committed
raw record initial changes
1 parent 4110cdb commit ad5aa9f

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

data-loader/core/src/main/java/com/scalar/db/dataloader/core/dataimport/log/SingleFileImportLogger.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public SingleFileImportLogger(ImportLoggerConfig config, LogWriterFactory logWri
7474
*/
7575
@Override
7676
public void onTaskComplete(ImportTaskResult taskResult) {
77-
if (!config.isLogSuccessRecordsEnabled() && !config.isLogRawSourceRecordsEnabled()) return;
7877
try {
7978
writeImportTaskResultDetailToLogs(taskResult);
8079
} catch (Exception e) {
@@ -199,9 +198,7 @@ private void writeImportTaskResultDetailToLogs(ImportTaskResult importTaskResult
199198
&& target.getStatus().equals(ImportTargetResultStatus.SAVED)) {
200199

201200
writeToLogWriter(successLogWriter, OBJECT_MAPPER.valueToTree(target));
202-
}
203-
if (config.isLogRawSourceRecordsEnabled()
204-
&& !target.getStatus().equals(ImportTargetResultStatus.SAVED)) {
201+
} else if (!target.getStatus().equals(ImportTargetResultStatus.SAVED)) {
205202
writeToLogWriter(failureLogWriter, OBJECT_MAPPER.valueToTree(target));
206203
}
207204
}

data-loader/core/src/main/java/com/scalar/db/dataloader/core/dataimport/log/SplitByDataChunkImportLogger.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public SplitByDataChunkImportLogger(
7373
*/
7474
@Override
7575
public void onTaskComplete(ImportTaskResult taskResult) {
76-
if (!config.isLogSuccessRecordsEnabled() && !config.isLogRawSourceRecordsEnabled()) return;
7776
try {
7877
writeImportTaskResultDetailToLogs(taskResult);
7978
} catch (IOException e) {
@@ -94,8 +93,7 @@ private void writeImportTaskResultDetailToLogs(ImportTaskResult importTaskResult
9493
ImportTargetResultStatus status = target.getStatus();
9594
if (status.equals(ImportTargetResultStatus.SAVED) && config.isLogSuccessRecordsEnabled()) {
9695
writeLog(target, LogFileType.SUCCESS, importTaskResult.getDataChunkId());
97-
} else if (!status.equals(ImportTargetResultStatus.SAVED)
98-
&& config.isLogRawSourceRecordsEnabled()) {
96+
} else if (!status.equals(ImportTargetResultStatus.SAVED)) {
9997
writeLog(target, LogFileType.FAILURE, importTaskResult.getDataChunkId());
10098
}
10199
}

data-loader/core/src/main/java/com/scalar/db/dataloader/core/dataimport/task/ImportTask.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ private ImportTargetResult importIntoSingleTable(
183183
.tableName(table)
184184
.status(ImportTargetResultStatus.VALIDATION_FAILED)
185185
.errors(Collections.singletonList(DataLoaderError.TABLE_METADATA_MISSING.buildMessage()))
186+
.importedRecord(importOptions.isLogRawRecord() ? mutableSourceRecord : null)
186187
.build();
187188
}
188189

@@ -209,6 +210,7 @@ private ImportTargetResult importIntoSingleTable(
209210
.tableName(table)
210211
.status(ImportTargetResultStatus.VALIDATION_FAILED)
211212
.errors(validationResult.getErrorMessages())
213+
.importedRecord(importOptions.isLogRawRecord() ? mutableSourceRecord : null)
212214
.build();
213215
}
214216

@@ -223,6 +225,7 @@ private ImportTargetResult importIntoSingleTable(
223225
.errors(
224226
Collections.singletonList(
225227
DataLoaderError.COULD_NOT_FIND_PARTITION_KEY.buildMessage()))
228+
.importedRecord(importOptions.isLogRawRecord() ? mutableSourceRecord : null)
226229
.build();
227230
}
228231
Optional<Key> optionalClusteringKey = Optional.empty();
@@ -238,6 +241,7 @@ private ImportTargetResult importIntoSingleTable(
238241
.errors(
239242
Collections.singletonList(
240243
DataLoaderError.COULD_NOT_FIND_CLUSTERING_KEY.buildMessage()))
244+
.importedRecord(importOptions.isLogRawRecord() ? mutableSourceRecord : null)
241245
.build();
242246
}
243247
}
@@ -254,6 +258,7 @@ private ImportTargetResult importIntoSingleTable(
254258
.tableName(table)
255259
.status(ImportTargetResultStatus.RETRIEVAL_FAILED)
256260
.errors(Collections.singletonList(e.getMessage()))
261+
.importedRecord(importOptions.isLogRawRecord() ? mutableSourceRecord : null)
257262
.build();
258263
}
259264
ImportTaskAction importAction =
@@ -273,6 +278,7 @@ && shouldRevalidateMissingColumns(importOptions, checkForMissingColumns)) {
273278
.errors(
274279
Collections.singletonList(
275280
DataLoaderError.UPSERT_INSERT_MISSING_COLUMNS.buildMessage()))
281+
.importedRecord(importOptions.isLogRawRecord() ? mutableSourceRecord : null)
276282
.build();
277283
}
278284
}
@@ -281,7 +287,7 @@ && shouldRevalidateMissingColumns(importOptions, checkForMissingColumns)) {
281287
return ImportTargetResult.builder()
282288
.namespace(namespace)
283289
.tableName(table)
284-
.importedRecord(mutableSourceRecord)
290+
.importedRecord(importOptions.isLogRawRecord() ? mutableSourceRecord : null)
285291
.importAction(importAction)
286292
.status(ImportTargetResultStatus.DATA_ALREADY_EXISTS)
287293
.errors(Collections.singletonList(DataLoaderError.DATA_ALREADY_EXISTS.buildMessage()))
@@ -292,7 +298,7 @@ && shouldRevalidateMissingColumns(importOptions, checkForMissingColumns)) {
292298
return ImportTargetResult.builder()
293299
.namespace(namespace)
294300
.tableName(table)
295-
.importedRecord(mutableSourceRecord)
301+
.importedRecord(importOptions.isLogRawRecord() ? mutableSourceRecord : null)
296302
.importAction(importAction)
297303
.status(ImportTargetResultStatus.DATA_NOT_FOUND)
298304
.errors(Collections.singletonList(DataLoaderError.DATA_NOT_FOUND.buildMessage()))
@@ -314,7 +320,7 @@ && shouldRevalidateMissingColumns(importOptions, checkForMissingColumns)) {
314320
return ImportTargetResult.builder()
315321
.namespace(namespace)
316322
.tableName(table)
317-
.importedRecord(mutableSourceRecord)
323+
.importedRecord(importOptions.isLogRawRecord() ? mutableSourceRecord : null)
318324
.status(ImportTargetResultStatus.VALIDATION_FAILED)
319325
.errors(Collections.singletonList(e.getMessage()))
320326
.build();
@@ -333,13 +339,14 @@ && shouldRevalidateMissingColumns(importOptions, checkForMissingColumns)) {
333339
.namespace(namespace)
334340
.tableName(table)
335341
.importAction(importAction)
336-
.importedRecord(mutableSourceRecord)
342+
.importedRecord(importOptions.isLogRawRecord() ? mutableSourceRecord : null)
337343
.status(ImportTargetResultStatus.SAVED)
338344
.build();
339345

340346
} catch (ScalarDbDaoException e) {
341347
return ImportTargetResult.builder()
342348
.namespace(namespace)
349+
.importedRecord(importOptions.isLogRawRecord() ? mutableSourceRecord : null)
343350
.tableName(table)
344351
.importAction(importAction)
345352
.status(ImportTargetResultStatus.SAVE_FAILED)

0 commit comments

Comments
 (0)