-
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
Add table metadata service #2434
base: master
Are you sure you want to change the base?
Conversation
|
||
/** The namespace of the table in ScalarDB. */ | ||
@JsonProperty("namespace") | ||
private String namespace; |
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.
[minor] This seems the name of a namespace as well as the name of a table below. So, this should be namespaceName
for consistency?
@Getter | ||
public class TableMetadataRequest { | ||
|
||
private final String namespace; |
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.
[minor] Same as above
* | ||
* @return A set of predefined metadata column names. | ||
*/ | ||
public static Set<String> getMetadataColumns() { |
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.
How about using com.scalar.db.transaction.consensuscommit.ConsensusCommitUtils#getTransactionMetaColumns
to avoid duplicated logic?
Some other methods might be replaced with ConsensusCommitUtils
methods.
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.
Left a couple comments. Please take a look when you have time!
* @param columnNames A set of all column names in the table. | ||
* @return {@code true} if the column is a metadata column; {@code false} otherwise. | ||
*/ | ||
public static boolean isMetadataColumn( |
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.
You can use ConsensusCommitUtils.isTransactionMetaColumn()
:
scalardb/core/src/main/java/com/scalar/db/transaction/consensuscommit/ConsensusCommitUtils.java
Line 201 in 98b5e1b
public static boolean isTransactionMetaColumn(String columnName, TableMetadata tableMetadata) { |
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.
How about this? Have you made a change for this?
* @param tableMetadata The metadata of the table. | ||
* @return {@code true} if the column is a metadata column; {@code false} otherwise. | ||
*/ | ||
public static boolean isMetadataColumn(String columnName, TableMetadata tableMetadata) { |
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.
Ditto.
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.
LGTM! 👍
private static final String ERROR_MISSING_NAMESPACE_OR_TABLE = | ||
"Missing namespace or table: %s, %s"; |
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.
Please move this to CoreError
. Or we might already have the same message for it in CoreError
. If so, pease use it.
* @param columnNames A set of all column names in the table. | ||
* @return {@code true} if the column is a metadata column; {@code false} otherwise. | ||
*/ | ||
public static boolean isMetadataColumn( |
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.
How about this? Have you made a change for this?
@brfrn169 san, I have removed the code for |
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.
Left a couple of comments. Please take a look!
throw new TableMetadataException( | ||
CoreError.DATA_LOADER_MISSING_NAMESPACE_OR_TABLE.buildMessage(namespace, tableName), | ||
e.getCause()); |
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.
It looks like this exception is thrown when retrieving table metadata fails. In that case, is this error message appropriate?
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.
Thank you.
I have added another message.
public static Map<String, DataType> extractColumnDataTypes(TableMetadata tableMetadata) { | ||
Map<String, DataType> definitions = new HashMap<>(); | ||
for (String columnName : tableMetadata.getColumnNames()) { | ||
definitions.put(columnName, tableMetadata.getColumnDataType(columnName)); | ||
} | ||
return definitions; | ||
} |
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.
I just realized it but we can use TableMetadata.getColumnDataTypes()
for this.
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.
I have removed this code and will use TableMetadata.getColumnDataTypes() instead.
Thank you.
DATA_LOADER_MISSING_NAMESPACE_OR_TABLE( | ||
Category.USER_ERROR, "0165", "Missing namespace or table: %s, %s", "", ""), | ||
DATA_LOADER_TABLE_METADATA_RETRIEVAL_FAILED( | ||
Category.USER_ERROR, "0166", "Failed to retrieve table metadata. Details: %s", "", ""), |
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.
Nit:
Category.USER_ERROR, "0166", "Failed to retrieve table metadata. Details: %s", "", ""), | |
Category.USER_ERROR, "0166", "Failed to retrieve table metadata. Details: %s", "", ""), |
} catch (ExecutionException e) { | ||
throw new TableMetadataException( | ||
CoreError.DATA_LOADER_TABLE_METADATA_RETRIEVAL_FAILED.buildMessage(e.getMessage()), | ||
e.getCause()); |
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.
Why e.getCause()
instead of e
?
e.getCause()); | |
e); |
@brfrn169 san, |
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.
LGTM, thank you.
DATA_LOADER_MISSING_NAMESPACE_OR_TABLE( | ||
Category.USER_ERROR, "0165", "Missing namespace or table: %s, %s", "", ""), | ||
DATA_LOADER_TABLE_METADATA_RETRIEVAL_FAILED( | ||
Category.USER_ERROR, "0166", "Failed to retrieve table metadata. Details: %s", "", ""), |
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.
When updating or creating error messages. Please explicitly ask @josh-wong to review them to check the English phrasing.
@josh-wong Please check the error message when you get the chance.
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.
LGTM! Thank you!🙇🏻♂️
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.
LGTM! Thank you!
Description
Added table metadata service and some related DTO classes
Related issues and/or PRs
NA
Changes made
Checklist
Additional notes (optional)
Road map to merge remaining data loader core files. Current status
General
Export
Import
Release notes
NA