-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export options and basic export report dto #2397
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
df78881
Enum, constants for data loader
inv-jishnu 5343891
Removed error messages
inv-jishnu 64b0334
spotless applied
inv-jishnu b0ae7d9
Merge branch 'master' into feat/dataloader/enum
ypeckstadt ca15aab
Export report added [skip ci]
inv-jishnu f9c81b6
Merge branch 'master' into feat/dataloader/enum
ypeckstadt 59d2be0
Merge branch 'feat/dataloader/enum' into feat/data-loader/export-data-1
inv-jishnu e64c816
Export options class
inv-jishnu be26ee2
Applied sportless on data loader core
inv-jishnu b9c823b
Merge branch 'master' into feat/data-loader/export-data-1
inv-jishnu 93d1c18
Suppress warning added for same name but different
inv-jishnu 34581ee
Merge branch 'master' into feat/data-loader/export-data-1
ypeckstadt 177cbf2
Spotbug ignore added for data loader
inv-jishnu 0a9f91f
Changes
inv-jishnu 2c3798c
Removed public from test class
inv-jishnu aca0918
Merge branch 'master' into feat/data-loader/export-data-1
ypeckstadt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
data-loader/core/src/main/java/com/scalar/db/dataloader/core/dataexport/ExportOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.scalar.db.dataloader.core.dataexport; | ||
|
||
import com.scalar.db.api.Scan; | ||
import com.scalar.db.dataloader.core.FileFormat; | ||
import com.scalar.db.dataloader.core.ScanRange; | ||
import com.scalar.db.io.Key; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
/** Options for a ScalarDB export data operation */ | ||
@SuppressWarnings("SameNameButDifferent") | ||
@Builder(builderMethodName = "hiddenBuilder") | ||
@Data | ||
public class ExportOptions { | ||
|
||
private final String namespace; | ||
private final String tableName; | ||
private final Key scanPartitionKey; | ||
private final FileFormat outputFileFormat; | ||
private final ScanRange scanRange; | ||
private final int limit; | ||
private final int maxThreadCount; | ||
private final boolean prettyPrintJson; | ||
|
||
@Builder.Default private final int dataChunkSize = 200; | ||
@Builder.Default private final String delimiter = ";"; | ||
@Builder.Default private final boolean excludeHeaderRow = false; | ||
@Builder.Default private final boolean includeTransactionMetadata = false; | ||
@Builder.Default private List<String> projectionColumns = Collections.emptyList(); | ||
private List<Scan.Ordering> sortOrders; | ||
|
||
public static ExportOptionsBuilder builder( | ||
String namespace, String tableName, Key scanPartitionKey, FileFormat outputFileFormat) { | ||
return hiddenBuilder() | ||
.namespace(namespace) | ||
.tableName(tableName) | ||
.scanPartitionKey(scanPartitionKey) | ||
.outputFileFormat(outputFileFormat); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
data-loader/core/src/main/java/com/scalar/db/dataloader/core/dataexport/ExportReport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.scalar.db.dataloader.core.dataexport; | ||
|
||
import java.util.concurrent.atomic.LongAdder; | ||
|
||
/** | ||
* Represents the report of exported data from a table | ||
* | ||
* @author Jishnu J | ||
*/ | ||
public class ExportReport { | ||
|
||
/** | ||
* The field is used to get the total number of rows exported from the table and written to the | ||
* exported file. LongAdder is used because it is thread-safe and optimized for high contention | ||
* scenarios where multiple threads are incrementing the counter. | ||
*/ | ||
private final LongAdder exportedRowCount = new LongAdder(); | ||
|
||
public long getExportedRowCount() { | ||
return exportedRowCount.sum(); | ||
} | ||
|
||
public void increaseExportedRowCount() { | ||
this.exportedRowCount.increment(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...-loader/core/src/test/java/com/scalar/db/dataloader/core/dataexport/ExportReportTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.scalar.db.dataloader.core.dataexport; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class ExportReportTest { | ||
|
||
@Test | ||
void getExportedRowCount_afterInitialisation_ShouldBeZero() { | ||
ExportReport exportReport = new ExportReport(); | ||
Assertions.assertEquals(0, exportReport.getExportedRowCount()); | ||
} | ||
|
||
@Test | ||
void getExportedRowCount_afterIncrementingTwice_ShouldBeTwo() { | ||
ExportReport exportReport = new ExportReport(); | ||
exportReport.increaseExportedRowCount(); | ||
exportReport.increaseExportedRowCount(); | ||
Assertions.assertEquals(2, exportReport.getExportedRowCount()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lombok does not work well with Spotbugs. To avoid having to disable the bug patterns for all projects, the rules are only disabled for the
com.scalar.db.dataloader.core.*
package.