Skip to content

Commit 53d6dc0

Browse files
committed
Deprecate the include metadata export argument and depend on ScalarDB config
# Conflicts: # data-loader/cli/src/main/java/com/scalar/db/dataloader/cli/command/dataexport/ExportCommand.java # data-loader/core/src/test/java/com/scalar/db/dataloader/core/dataexport/CsvExportManagerTest.java
1 parent 0ccc67b commit 53d6dc0

File tree

17 files changed

+62
-109
lines changed

17 files changed

+62
-109
lines changed

data-loader/cli/src/main/java/com/scalar/db/dataloader/cli/command/dataexport/ExportCommand.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private void validateOutputDirectory() throws DirectoryValidationException {
162162
private ExportManager createExportManager(
163163
TransactionFactory transactionFactory, ScalarDbDao scalarDbDao, FileFormat fileFormat) {
164164
ProducerTaskFactory taskFactory =
165-
new ProducerTaskFactory(delimiter, includeTransactionMetadata, prettyPrintJson);
165+
new ProducerTaskFactory(delimiter, prettyPrintJson);
166166
DistributedTransactionManager manager = transactionFactory.getTransactionManager();
167167
switch (fileFormat) {
168168
case JSON:
@@ -181,7 +181,6 @@ private ExportOptions buildExportOptions(Key partitionKey, ScanRange scanRange)
181181
ExportOptions.builder(namespace, table, partitionKey, outputFormat)
182182
.sortOrders(sortOrders)
183183
.excludeHeaderRow(excludeHeader)
184-
.includeTransactionMetadata(includeTransactionMetadata)
185184
.delimiter(delimiter)
186185
.limit(limit)
187186
.maxThreadCount(maxThreads)

data-loader/cli/src/main/java/com/scalar/db/dataloader/cli/command/dataexport/ExportCommandOptions.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,16 @@ public class ExportCommandOptions {
6969
defaultValue = "json")
7070
protected FileFormat outputFormat;
7171

72+
/**
73+
* @deprecated As of release 3.16.2 This option is no longer used and will be removed in release
74+
* 4.0.0.
75+
*/
76+
@Deprecated
7277
@CommandLine.Option(
7378
names = {"--include-metadata", "-m"},
74-
description = "Include transaction metadata in the exported data (default: false)",
75-
defaultValue = "false")
79+
description = "Deprecated: This option is no longer used",
80+
defaultValue = "false",
81+
hidden = true)
7682
protected boolean includeTransactionMetadata;
7783

7884
@CommandLine.Option(

data-loader/core/src/main/java/com/scalar/db/dataloader/core/dataexport/CsvExportManager.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.scalar.db.dataloader.core.dataexport.producer.ProducerTaskFactory;
66
import com.scalar.db.dataloader.core.dataimport.dao.ScalarDbDao;
77
import com.scalar.db.dataloader.core.util.CsvUtil;
8-
import com.scalar.db.transaction.consensuscommit.ConsensusCommitUtils;
98
import java.io.IOException;
109
import java.io.Writer;
1110
import java.util.Iterator;
@@ -77,8 +76,7 @@ private String createCsvHeaderRow(ExportOptions exportOptions, TableMetadata tab
7776
Iterator<String> iterator = tableMetadata.getColumnNames().iterator();
7877
while (iterator.hasNext()) {
7978
String columnName = iterator.next();
80-
if (shouldIgnoreColumn(
81-
exportOptions.isIncludeTransactionMetadata(), columnName, tableMetadata, projections)) {
79+
if (shouldIgnoreColumn(columnName, projections)) {
8280
continue;
8381
}
8482
headerRow.append(columnName);
@@ -92,22 +90,13 @@ private String createCsvHeaderRow(ExportOptions exportOptions, TableMetadata tab
9290
}
9391

9492
/**
95-
* To ignore a column or not based on conditions such as if it is a metadata column or if it is
96-
* not include in selected projections
93+
* To ignore a column or not based on if it is not included in selected projections
9794
*
98-
* @param isIncludeTransactionMetadata to include transaction metadata or not
9995
* @param columnName column name
100-
* @param tableMetadata table metadata
10196
* @param projections selected columns for projection
102-
* @return ignore the column or not
97+
* @return true if the column should be ignored, false otherwise
10398
*/
104-
private boolean shouldIgnoreColumn(
105-
boolean isIncludeTransactionMetadata,
106-
String columnName,
107-
TableMetadata tableMetadata,
108-
List<String> projections) {
109-
return (!isIncludeTransactionMetadata
110-
&& ConsensusCommitUtils.isTransactionMetaColumn(columnName, tableMetadata))
111-
|| (!projections.isEmpty() && !projections.contains(columnName));
99+
private boolean shouldIgnoreColumn(String columnName, List<String> projections) {
100+
return !projections.isEmpty() && !projections.contains(columnName);
112101
}
113102
}

data-loader/core/src/main/java/com/scalar/db/dataloader/core/dataexport/ExportManager.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ private void validateExportOptions(ExportOptions exportOptions, TableMetadata ta
205205
* @param tableMetadata metadata of the table
206206
*/
207207
private void handleTransactionMetadata(ExportOptions exportOptions, TableMetadata tableMetadata) {
208-
if (exportOptions.isIncludeTransactionMetadata()
209-
&& !exportOptions.getProjectionColumns().isEmpty()) {
208+
if (!exportOptions.getProjectionColumns().isEmpty()) {
210209
List<String> projectionMetadata =
211210
TableMetadataUtil.populateProjectionsWithMetadata(
212211
tableMetadata, exportOptions.getProjectionColumns());

data-loader/core/src/main/java/com/scalar/db/dataloader/core/dataexport/ExportOptions.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public class ExportOptions {
2727
@Builder.Default private final int maxThreadCount = Runtime.getRuntime().availableProcessors();
2828
@Builder.Default private final String delimiter = ";";
2929
@Builder.Default private final boolean excludeHeaderRow = false;
30-
@Builder.Default private final boolean includeTransactionMetadata = false;
3130
@Builder.Default private List<String> projectionColumns = Collections.emptyList();
3231
private List<Scan.Ordering> sortOrders;
3332

data-loader/core/src/main/java/com/scalar/db/dataloader/core/dataexport/producer/CsvProducerTask.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.scalar.db.dataloader.core.util.CsvUtil;
77
import com.scalar.db.dataloader.core.util.DecimalUtil;
88
import com.scalar.db.io.DataType;
9-
import com.scalar.db.transaction.consensuscommit.ConsensusCommitUtils;
109
import java.nio.charset.Charset;
1110
import java.time.Instant;
1211
import java.time.LocalDate;
@@ -33,19 +32,17 @@ public class CsvProducerTask extends ProducerTask {
3332
/**
3433
* Class constructor
3534
*
36-
* @param includeMetadata Include metadata in the exported data
3735
* @param projectColumns list of columns that is required in export data
3836
* @param tableMetadata Metadata for a single ScalarDB table
3937
* @param columnDataTypes Map of data types for the all columns in a ScalarDB table
4038
* @param delimiter Delimiter used in csv content
4139
*/
4240
public CsvProducerTask(
43-
boolean includeMetadata,
4441
List<String> projectColumns,
4542
TableMetadata tableMetadata,
4643
Map<String, DataType> columnDataTypes,
4744
String delimiter) {
48-
super(includeMetadata, projectColumns, tableMetadata, columnDataTypes);
45+
super(projectColumns, tableMetadata, columnDataTypes);
4946
this.delimiter = delimiter;
5047
}
5148

@@ -82,12 +79,10 @@ private String convertResultToCsv(Result result) {
8279
while (iterator.hasNext()) {
8380
String columnName = iterator.next();
8481

85-
// Skip the field if it can be ignored based on check
82+
// Skip the field if it's not in the projection list (when projections are specified)
8683
boolean columnNotProjected =
8784
!projectedColumnsSet.isEmpty() && !projectedColumnsSet.contains(columnName);
88-
boolean isMetadataColumn =
89-
ConsensusCommitUtils.isTransactionMetaColumn(columnName, tableMetadata);
90-
if (columnNotProjected || (!includeMetadata && isMetadataColumn)) {
85+
if (columnNotProjected) {
9186
continue;
9287
}
9388

data-loader/core/src/main/java/com/scalar/db/dataloader/core/dataexport/producer/JsonLineProducerTask.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.scalar.db.api.TableMetadata;
77
import com.scalar.db.dataloader.core.DataLoaderObjectMapper;
88
import com.scalar.db.io.DataType;
9-
import com.scalar.db.transaction.consensuscommit.ConsensusCommitUtils;
109
import java.nio.charset.Charset;
1110
import java.time.Instant;
1211
import java.time.LocalDate;
@@ -28,17 +27,15 @@ public class JsonLineProducerTask extends ProducerTask {
2827
/**
2928
* Class constructor
3029
*
31-
* @param includeMetadata Include metadata in the exported data
3230
* @param projectionColumns list of columns that is required in export data
3331
* @param tableMetadata Metadata for a single ScalarDB table
3432
* @param columnDataTypes Map of data types for the all columns in a ScalarDB table
3533
*/
3634
public JsonLineProducerTask(
37-
boolean includeMetadata,
3835
List<String> projectionColumns,
3936
TableMetadata tableMetadata,
4037
Map<String, DataType> columnDataTypes) {
41-
super(includeMetadata, projectionColumns, tableMetadata, columnDataTypes);
38+
super(projectionColumns, tableMetadata, columnDataTypes);
4239
}
4340

4441
/**
@@ -72,12 +69,10 @@ private ObjectNode generateJsonForResult(Result result) {
7269

7370
// Loop through all the columns and to the json object
7471
for (String columnName : tableColumns) {
75-
// Skip the field if it can be ignored based on check
72+
// Skip the field if it's not in the projection list (when projections are specified)
7673
boolean columnNotProjected =
7774
!projectedColumnsSet.isEmpty() && !projectedColumnsSet.contains(columnName);
78-
boolean isMetadataColumn =
79-
ConsensusCommitUtils.isTransactionMetaColumn(columnName, tableMetadata);
80-
if (columnNotProjected || (!includeMetadata && isMetadataColumn)) {
75+
if (columnNotProjected) {
8176
continue;
8277
}
8378

data-loader/core/src/main/java/com/scalar/db/dataloader/core/dataexport/producer/JsonProducerTask.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.scalar.db.api.TableMetadata;
88
import com.scalar.db.dataloader.core.DataLoaderObjectMapper;
99
import com.scalar.db.io.DataType;
10-
import com.scalar.db.transaction.consensuscommit.ConsensusCommitUtils;
1110
import java.nio.charset.Charset;
1211
import java.time.Instant;
1312
import java.time.LocalDate;
@@ -30,19 +29,17 @@ public class JsonProducerTask extends ProducerTask {
3029
/**
3130
* Class constructor
3231
*
33-
* @param includeMetadata Include metadata in the exported data
3432
* @param projectionColumns list of columns that is required in export data
3533
* @param tableMetadata Metadata for a single ScalarDB table
3634
* @param columnDataTypes Map of data types for the all columns in a ScalarDB table
3735
* @param prettyPrintJson Json data should be formatted or not
3836
*/
3937
public JsonProducerTask(
40-
boolean includeMetadata,
4138
List<String> projectionColumns,
4239
TableMetadata tableMetadata,
4340
Map<String, DataType> columnDataTypes,
4441
boolean prettyPrintJson) {
45-
super(includeMetadata, projectionColumns, tableMetadata, columnDataTypes);
42+
super(projectionColumns, tableMetadata, columnDataTypes);
4643
this.prettyPrintJson = prettyPrintJson;
4744
}
4845

@@ -84,12 +81,10 @@ private ObjectNode generateJsonForResult(Result result) {
8481

8582
// Loop through all the columns and to the json object
8683
for (String columnName : tableColumns) {
87-
// Skip the field if it can be ignored based on check
84+
// Skip the field if it's not in the projection list (when projections are specified)
8885
boolean columnNotProjected =
8986
!projectedColumnsSet.isEmpty() && !projectedColumnsSet.contains(columnName);
90-
boolean isMetadataColumn =
91-
ConsensusCommitUtils.isTransactionMetaColumn(columnName, tableMetadata);
92-
if (columnNotProjected || (!includeMetadata && isMetadataColumn)) {
87+
if (columnNotProjected) {
9388
continue;
9489
}
9590

data-loader/core/src/main/java/com/scalar/db/dataloader/core/dataexport/producer/ProducerTask.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ public abstract class ProducerTask {
3232
*/
3333
protected final Map<String, DataType> dataTypeByColumnName;
3434

35-
/**
36-
* Flag indicating whether to include internal metadata columns (e.g., transaction metadata) in
37-
* the output.
38-
*/
39-
protected final boolean includeMetadata;
40-
4135
/**
4236
* A set of column names to include in the exported output. If empty, all columns are included by
4337
* default.
@@ -47,17 +41,14 @@ public abstract class ProducerTask {
4741
/**
4842
* Class constructor
4943
*
50-
* @param includeMetadata Include metadata in the exported data
5144
* @param projectionColumns List of column name for projection
5245
* @param tableMetadata Metadata of the ScalarDB table
5346
* @param columnDataTypes Map of data types for the all columns in a ScalarDB table
5447
*/
5548
protected ProducerTask(
56-
boolean includeMetadata,
5749
List<String> projectionColumns,
5850
TableMetadata tableMetadata,
5951
Map<String, DataType> columnDataTypes) {
60-
this.includeMetadata = includeMetadata;
6152
this.projectedColumnsSet = new HashSet<>(projectionColumns);
6253
this.tableMetadata = tableMetadata;
6354
this.dataTypeByColumnName = columnDataTypes;

data-loader/core/src/main/java/com/scalar/db/dataloader/core/dataexport/producer/ProducerTaskFactory.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
public class ProducerTaskFactory {
1515

1616
private final String delimiter;
17-
private final boolean includeMetadata;
1817
private final boolean prettyPrintJson;
1918

2019
/**
@@ -36,21 +35,15 @@ public ProducerTask createProducerTask(
3635
case JSON:
3736
producerTask =
3837
new JsonProducerTask(
39-
includeMetadata,
40-
projectionColumns,
41-
tableMetadata,
42-
dataTypeByColumnName,
43-
prettyPrintJson);
38+
projectionColumns, tableMetadata, dataTypeByColumnName, prettyPrintJson);
4439
break;
4540
case JSONL:
4641
producerTask =
47-
new JsonLineProducerTask(
48-
includeMetadata, projectionColumns, tableMetadata, dataTypeByColumnName);
42+
new JsonLineProducerTask(projectionColumns, tableMetadata, dataTypeByColumnName);
4943
break;
5044
case CSV:
5145
producerTask =
52-
new CsvProducerTask(
53-
includeMetadata, projectionColumns, tableMetadata, dataTypeByColumnName, delimiter);
46+
new CsvProducerTask(projectionColumns, tableMetadata, dataTypeByColumnName, delimiter);
5447
break;
5548
default:
5649
throw new IllegalArgumentException(

0 commit comments

Comments
 (0)