Skip to content

Commit 76dbc58

Browse files
feeblefakieinv-jishnuypeckstadt
authored
Backport to branch(3.13) : Add data chunk and task result enums and dtos (#2498)
Co-authored-by: inv-jishnu <[email protected]> Co-authored-by: Peckstadt Yves <[email protected]>
1 parent e92d15d commit 76dbc58

File tree

12 files changed

+213
-0
lines changed

12 files changed

+213
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.scalar.db.dataloader.core.dataimport.datachunk;
2+
3+
import java.util.List;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
7+
/** * Import data chunk data */
8+
@Data
9+
@Builder
10+
public class ImportDataChunk {
11+
12+
int dataChunkId;
13+
List<ImportRow> sourceData;
14+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.scalar.db.dataloader.core.dataimport.datachunk;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
5+
import java.time.Instant;
6+
import lombok.Builder;
7+
import lombok.Data;
8+
9+
/** * A DTO to store import data chunk details */
10+
@Data
11+
@Builder
12+
@JsonDeserialize(builder = ImportDataChunkStatus.ImportDataChunkStatusBuilder.class)
13+
public class ImportDataChunkStatus {
14+
15+
@JsonProperty("dataChunkId")
16+
private final int dataChunkId;
17+
18+
@JsonProperty("startTime")
19+
private final Instant startTime;
20+
21+
@JsonProperty("endTime")
22+
private final Instant endTime;
23+
24+
@JsonProperty("totalRecords")
25+
private final int totalRecords;
26+
27+
@JsonProperty("successCount")
28+
private final int successCount;
29+
30+
@JsonProperty("failureCount")
31+
private final int failureCount;
32+
33+
@JsonProperty("batchCount")
34+
private final int batchCount;
35+
36+
@JsonProperty("totalDurationInMilliSeconds")
37+
private final int totalDurationInMilliSeconds;
38+
39+
@JsonProperty("status")
40+
private final ImportDataChunkStatusState status;
41+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.scalar.db.dataloader.core.dataimport.datachunk;
2+
3+
/** * Status of the import data chunk during the import process */
4+
public enum ImportDataChunkStatusState {
5+
START,
6+
IN_PROGRESS,
7+
COMPLETE
8+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.scalar.db.dataloader.core.dataimport.datachunk;
2+
3+
import com.fasterxml.jackson.databind.JsonNode;
4+
import lombok.Value;
5+
6+
/** Stores data related to a single row on import file */
7+
@Value
8+
public class ImportRow {
9+
int rowNumber;
10+
JsonNode sourceData;
11+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.scalar.db.dataloader.core.dataimport.task;
2+
3+
/** * Import task actions */
4+
public enum ImportTaskAction {
5+
INSERT,
6+
UPDATE,
7+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.scalar.db.dataloader.core.dataimport.task.result;
2+
3+
public enum ImportResultStatus {
4+
SUCCESS,
5+
PARTIAL_SUCCESS,
6+
FAILURE,
7+
VALIDATION_FAILED,
8+
RETRIEVAL_FAILED,
9+
MAPPING_FAILED,
10+
TIMEOUT,
11+
CANCELLED
12+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.scalar.db.dataloader.core.dataimport.task.result;
2+
3+
import com.fasterxml.jackson.databind.JsonNode;
4+
import com.scalar.db.dataloader.core.dataimport.task.ImportTaskAction;
5+
import java.util.List;
6+
import lombok.Builder;
7+
import lombok.Value;
8+
9+
@Builder
10+
@Value
11+
public class ImportTargetResult {
12+
String namespace;
13+
String tableName;
14+
ImportTaskAction importAction;
15+
List<String> errors;
16+
boolean dataMapped;
17+
JsonNode importedRecord;
18+
ImportTargetResultStatus status;
19+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.scalar.db.dataloader.core.dataimport.task.result;
2+
3+
public enum ImportTargetResultStatus {
4+
VALIDATION_FAILED,
5+
RETRIEVAL_FAILED,
6+
MISSING_COLUMNS,
7+
DATA_ALREADY_EXISTS,
8+
DATA_NOT_FOUND,
9+
SAVE_FAILED,
10+
SAVED,
11+
ABORTED
12+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.scalar.db.dataloader.core.dataimport.task.result;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.fasterxml.jackson.databind.JsonNode;
5+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
6+
import java.util.List;
7+
import lombok.Builder;
8+
import lombok.Value;
9+
10+
@Builder
11+
@Value
12+
@JsonDeserialize(builder = ImportTaskResult.ImportTaskResultBuilder.class)
13+
public class ImportTaskResult {
14+
@JsonProperty("rowNumber")
15+
int rowNumber;
16+
17+
@JsonProperty("targets")
18+
List<ImportTargetResult> targets;
19+
20+
@JsonProperty("rawRecord")
21+
JsonNode rawRecord;
22+
23+
@JsonProperty("dataChunkId")
24+
int dataChunkId;
25+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.scalar.db.dataloader.core.dataimport.transactionbatch;
2+
3+
import com.scalar.db.dataloader.core.dataimport.datachunk.ImportRow;
4+
import java.util.List;
5+
import lombok.Builder;
6+
import lombok.Value;
7+
8+
/** Transaction batch details */
9+
@Builder
10+
@Value
11+
public class ImportTransactionBatch {
12+
int transactionBatchId;
13+
List<ImportRow> sourceData;
14+
}

0 commit comments

Comments
 (0)